forked from colin/nix-files
cleanup: programs: dont assume sway
is always the wayland/x11 provider
This commit is contained in:
parent
0c456d11d8
commit
4aeb3360d3
|
@ -177,6 +177,9 @@ in
|
|||
];
|
||||
cleanupCommand = ''rm -f "$XDG_RUNTIME_DIR/pulse/{native,pid}"'';
|
||||
};
|
||||
|
||||
# bring up sound by default
|
||||
services."sound".partOf = [ "default" ];
|
||||
};
|
||||
|
||||
# taken from nixos/modules/services/desktops/pipewire/pipewire.nix
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
# sway-config docs: `man 5 sway`
|
||||
let
|
||||
cfg = config.sane.programs.sway;
|
||||
enableXWayland = config.sane.programs.xwayland.enabled;
|
||||
wrapSway = configuredSway: let
|
||||
swayLauncher = pkgs.writeShellScriptBin "sway" ''
|
||||
test -e "$(dirname "$SWAYSOCK")" || \
|
||||
|
@ -66,7 +67,7 @@ let
|
|||
# - when xwayland is enabled, KOreader incorrectly chooses the X11 backend
|
||||
# -> slower; blurrier
|
||||
# - xwayland uses a small amount of memory (like 30MiB, IIRC?)
|
||||
enableXWayland = config.sane.programs.xwayland.enabled;
|
||||
inherit enableXWayland;
|
||||
}).overrideAttrs (upstream: {
|
||||
# fix to create SWAYSOCK and WAYLAND_DISPLAY directly in a sandboxable subdirectory:
|
||||
# i can't simply move it after creation i think because that would
|
||||
|
@ -221,7 +222,7 @@ in
|
|||
mod
|
||||
workspace_layout
|
||||
;
|
||||
xwayland = if config.sane.programs.xwayland.enabled then "enable" else "disable";
|
||||
xwayland = if enableXWayland then "enable" else "disable";
|
||||
};
|
||||
|
||||
env.XDG_CURRENT_DESKTOP = "sway";
|
||||
|
@ -238,7 +239,15 @@ in
|
|||
|
||||
services.sway = {
|
||||
description = "sway: tiling wayland desktop environment";
|
||||
dependencyOf = [ "graphical-session" ]; #< TODO: should be safe to remove this now
|
||||
partOf = [
|
||||
"wayland"
|
||||
] ++ lib.optionals enableXWayland [
|
||||
"x11"
|
||||
];
|
||||
# partOf = lib.mkMerge [
|
||||
# "wayland"
|
||||
# (lib.mkIf enableXWayland "x11")
|
||||
# ];
|
||||
command = pkgs.writeShellScript "sway-start" ''
|
||||
# have to create these directories before launching sway so that they're available in the sandbox
|
||||
mkdir -p "$(dirname "$SWAYSOCK")"
|
||||
|
@ -248,8 +257,8 @@ in
|
|||
'';
|
||||
readiness.waitExists = [ "$SWAYSOCK" "$XDG_RUNTIME_DIR/$WAYLAND_DISPLAY" ];
|
||||
};
|
||||
# link the graphical-session into the default target, so sway gets auto-started
|
||||
services.graphical-session.partOf = [ "default" ];
|
||||
# launch all graphical apps by default
|
||||
services."graphical-session".partOf = [ "default" ];
|
||||
};
|
||||
|
||||
# TODO: this can go elsewhere
|
||||
|
|
|
@ -223,6 +223,7 @@ let
|
|||
acts as noop for root-enabled packages.
|
||||
see `sane.users.<user>.services` for options;
|
||||
'';
|
||||
# TODO: this `apply` should by moved to where we pass the `services` down to `sane.users`
|
||||
apply = lib.mapAttrs (svcName: svcCfg:
|
||||
svcCfg // lib.optionalAttrs (builtins.tryEval svcCfg.description).success {
|
||||
# ensure service dependencies based on what a service's program whitelists.
|
||||
|
@ -231,9 +232,10 @@ let
|
|||
depends = svcCfg.depends
|
||||
++ lib.optionals (svcName != "dbus" && builtins.elem "user" config.sandbox.whitelistDbus) [
|
||||
"dbus"
|
||||
] ++ lib.optionals (svcName != "sway" && (config.sandbox.whitelistWayland || config.sandbox.whitelistX)) [
|
||||
# TODO: i shouldn't assume sway here: factor out a "partOf" like i do for "sound"
|
||||
"sway"
|
||||
] ++ lib.optionals ((!builtins.elem "wayland" svcCfg.partOf) && config.sandbox.whitelistWayland) [
|
||||
"wayland"
|
||||
] ++ lib.optionals ((!builtins.elem "x11" svcCfg.partOf) && config.sandbox.whitelistX) [
|
||||
"x11"
|
||||
] ++ lib.optionals ((!builtins.elem "sound" svcCfg.partOf) && config.sandbox.whitelistAudio) [
|
||||
"sound"
|
||||
];
|
||||
|
|
|
@ -157,7 +157,7 @@ let
|
|||
userModule = let
|
||||
nixConfig = config;
|
||||
in with lib; types.submodule ({ name, config, ... }: {
|
||||
options = userOptions// {
|
||||
options = userOptions // {
|
||||
default = mkOption {
|
||||
type = types.bool;
|
||||
default = false;
|
||||
|
@ -273,16 +273,26 @@ let
|
|||
'')
|
||||
];
|
||||
|
||||
# a few common targets one can depend on or declare a `partOf` to.
|
||||
# for example, a wayland session provider should:
|
||||
# - declare `myService.partOf = [ "wayland" ];`
|
||||
# - and `graphical-session.partOf = [ "default" ];`
|
||||
services."default" = {
|
||||
description = "service (bundle) which is started by default upon login";
|
||||
};
|
||||
services."graphical-session" = {
|
||||
description = "service (bundle) which is started upon successful graphical login";
|
||||
# partOf = [ "default" ]; #< leave it to the DEs to set this
|
||||
# partOf = [ "default" ];
|
||||
};
|
||||
services."sound" = {
|
||||
description = "service (bundle) which represents functional sound input/output when active";
|
||||
partOf = [ "default" ];
|
||||
# partOf = [ "default" ];
|
||||
};
|
||||
services."wayland" = {
|
||||
description = "service (bundle) which provides a wayland session";
|
||||
};
|
||||
services."x11" = {
|
||||
description = "service (bundle) which provides a x11 session (possibly via xwayland)";
|
||||
};
|
||||
}
|
||||
];
|
||||
|
|
Loading…
Reference in New Issue
Block a user