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}"'';
|
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
|
# taken from nixos/modules/services/desktops/pipewire/pipewire.nix
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
# sway-config docs: `man 5 sway`
|
# sway-config docs: `man 5 sway`
|
||||||
let
|
let
|
||||||
cfg = config.sane.programs.sway;
|
cfg = config.sane.programs.sway;
|
||||||
|
enableXWayland = config.sane.programs.xwayland.enabled;
|
||||||
wrapSway = configuredSway: let
|
wrapSway = configuredSway: let
|
||||||
swayLauncher = pkgs.writeShellScriptBin "sway" ''
|
swayLauncher = pkgs.writeShellScriptBin "sway" ''
|
||||||
test -e "$(dirname "$SWAYSOCK")" || \
|
test -e "$(dirname "$SWAYSOCK")" || \
|
||||||
|
@ -66,7 +67,7 @@ let
|
||||||
# - when xwayland is enabled, KOreader incorrectly chooses the X11 backend
|
# - when xwayland is enabled, KOreader incorrectly chooses the X11 backend
|
||||||
# -> slower; blurrier
|
# -> slower; blurrier
|
||||||
# - xwayland uses a small amount of memory (like 30MiB, IIRC?)
|
# - xwayland uses a small amount of memory (like 30MiB, IIRC?)
|
||||||
enableXWayland = config.sane.programs.xwayland.enabled;
|
inherit enableXWayland;
|
||||||
}).overrideAttrs (upstream: {
|
}).overrideAttrs (upstream: {
|
||||||
# fix to create SWAYSOCK and WAYLAND_DISPLAY directly in a sandboxable subdirectory:
|
# 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
|
# i can't simply move it after creation i think because that would
|
||||||
|
@ -221,7 +222,7 @@ in
|
||||||
mod
|
mod
|
||||||
workspace_layout
|
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";
|
env.XDG_CURRENT_DESKTOP = "sway";
|
||||||
|
@ -238,7 +239,15 @@ in
|
||||||
|
|
||||||
services.sway = {
|
services.sway = {
|
||||||
description = "sway: tiling wayland desktop environment";
|
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" ''
|
command = pkgs.writeShellScript "sway-start" ''
|
||||||
# have to create these directories before launching sway so that they're available in the sandbox
|
# have to create these directories before launching sway so that they're available in the sandbox
|
||||||
mkdir -p "$(dirname "$SWAYSOCK")"
|
mkdir -p "$(dirname "$SWAYSOCK")"
|
||||||
|
@ -248,8 +257,8 @@ in
|
||||||
'';
|
'';
|
||||||
readiness.waitExists = [ "$SWAYSOCK" "$XDG_RUNTIME_DIR/$WAYLAND_DISPLAY" ];
|
readiness.waitExists = [ "$SWAYSOCK" "$XDG_RUNTIME_DIR/$WAYLAND_DISPLAY" ];
|
||||||
};
|
};
|
||||||
# link the graphical-session into the default target, so sway gets auto-started
|
# launch all graphical apps by default
|
||||||
services.graphical-session.partOf = [ "default" ];
|
services."graphical-session".partOf = [ "default" ];
|
||||||
};
|
};
|
||||||
|
|
||||||
# TODO: this can go elsewhere
|
# TODO: this can go elsewhere
|
||||||
|
|
|
@ -223,6 +223,7 @@ let
|
||||||
acts as noop for root-enabled packages.
|
acts as noop for root-enabled packages.
|
||||||
see `sane.users.<user>.services` for options;
|
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:
|
apply = lib.mapAttrs (svcName: svcCfg:
|
||||||
svcCfg // lib.optionalAttrs (builtins.tryEval svcCfg.description).success {
|
svcCfg // lib.optionalAttrs (builtins.tryEval svcCfg.description).success {
|
||||||
# ensure service dependencies based on what a service's program whitelists.
|
# ensure service dependencies based on what a service's program whitelists.
|
||||||
|
@ -231,9 +232,10 @@ let
|
||||||
depends = svcCfg.depends
|
depends = svcCfg.depends
|
||||||
++ lib.optionals (svcName != "dbus" && builtins.elem "user" config.sandbox.whitelistDbus) [
|
++ lib.optionals (svcName != "dbus" && builtins.elem "user" config.sandbox.whitelistDbus) [
|
||||||
"dbus"
|
"dbus"
|
||||||
] ++ lib.optionals (svcName != "sway" && (config.sandbox.whitelistWayland || config.sandbox.whitelistX)) [
|
] ++ lib.optionals ((!builtins.elem "wayland" svcCfg.partOf) && config.sandbox.whitelistWayland) [
|
||||||
# TODO: i shouldn't assume sway here: factor out a "partOf" like i do for "sound"
|
"wayland"
|
||||||
"sway"
|
] ++ lib.optionals ((!builtins.elem "x11" svcCfg.partOf) && config.sandbox.whitelistX) [
|
||||||
|
"x11"
|
||||||
] ++ lib.optionals ((!builtins.elem "sound" svcCfg.partOf) && config.sandbox.whitelistAudio) [
|
] ++ lib.optionals ((!builtins.elem "sound" svcCfg.partOf) && config.sandbox.whitelistAudio) [
|
||||||
"sound"
|
"sound"
|
||||||
];
|
];
|
||||||
|
|
|
@ -157,7 +157,7 @@ let
|
||||||
userModule = let
|
userModule = let
|
||||||
nixConfig = config;
|
nixConfig = config;
|
||||||
in with lib; types.submodule ({ name, config, ... }: {
|
in with lib; types.submodule ({ name, config, ... }: {
|
||||||
options = userOptions// {
|
options = userOptions // {
|
||||||
default = mkOption {
|
default = mkOption {
|
||||||
type = types.bool;
|
type = types.bool;
|
||||||
default = false;
|
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" = {
|
services."default" = {
|
||||||
description = "service (bundle) which is started by default upon login";
|
description = "service (bundle) which is started by default upon login";
|
||||||
};
|
};
|
||||||
services."graphical-session" = {
|
services."graphical-session" = {
|
||||||
description = "service (bundle) which is started upon successful graphical login";
|
description = "service (bundle) which is started upon successful graphical login";
|
||||||
# partOf = [ "default" ]; #< leave it to the DEs to set this
|
# partOf = [ "default" ];
|
||||||
};
|
};
|
||||||
services."sound" = {
|
services."sound" = {
|
||||||
description = "service (bundle) which represents functional sound input/output when active";
|
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