1
0
Fork 0
mirror of https://github.com/nix-community/home-manager synced 2024-11-23 11:39:46 +01:00

sway: do not use pkgs.sway when cfg.package = null

- Implicitly disable checkConfig when `cfg.package = null` as we don’t
  have any exe to use for the check
- Implicitly disable `swaymsg reload` on activation, since we have no
  exe to use for running it

See https://github.com/nix-community/home-manager/issues/5307
This commit is contained in:
Andrew Marshall 2024-04-20 12:51:15 -04:00 committed by Robert Helgesson
parent 76bf779881
commit a9c9cc6e50
No known key found for this signature in database
GPG key ID: 96E745BD17AA17ED

View file

@ -258,7 +258,6 @@ let
variables = concatStringsSep " " cfg.systemd.variables; variables = concatStringsSep " " cfg.systemd.variables;
extraCommands = concatStringsSep " && " cfg.systemd.extraCommands; extraCommands = concatStringsSep " && " cfg.systemd.extraCommands;
swayPackage = if cfg.package == null then pkgs.sway else cfg.package;
systemdActivation = '' systemdActivation = ''
exec "${pkgs.dbus}/bin/dbus-update-activation-environment --systemd ${variables}; ${extraCommands}"''; exec "${pkgs.dbus}/bin/dbus-update-activation-environment --systemd ${variables}; ${extraCommands}"'';
@ -269,7 +268,7 @@ let
checkPhase = lib.optionalString cfg.checkConfig '' checkPhase = lib.optionalString cfg.checkConfig ''
export DBUS_SESSION_BUS_ADDRESS=/dev/null export DBUS_SESSION_BUS_ADDRESS=/dev/null
export XDG_RUNTIME_DIR=$(mktemp -d) export XDG_RUNTIME_DIR=$(mktemp -d)
${pkgs.xvfb-run}/bin/xvfb-run ${swayPackage}/bin/sway --config "$target" --validate --unsupported-gpu ${pkgs.xvfb-run}/bin/xvfb-run ${cfg.package}/bin/sway --config "$target" --validate --unsupported-gpu
''; '';
text = concatStringsSep "\n" text = concatStringsSep "\n"
@ -362,7 +361,8 @@ in {
'wrapperFeatures', 'extraSessionCommands', and 'extraOptions'. 'wrapperFeatures', 'extraSessionCommands', and 'extraOptions'.
Set to `null` to not add any Sway package to your Set to `null` to not add any Sway package to your
path. This should be done if you want to use the NixOS Sway path. This should be done if you want to use the NixOS Sway
module to install Sway. module to install Sway. Beware setting to `null` will also disable
reloading Sway when new config is activated.
''; '';
}; };
@ -483,9 +483,10 @@ in {
checkConfig = mkOption { checkConfig = mkOption {
type = types.bool; type = types.bool;
default = true; default = cfg.package != null;
description = defaultText =
"If enabled (the default), validates the generated config file."; literalExpression "wayland.windowManager.sway.package != null";
description = "If enabled, validates the generated config file.";
}; };
extraConfig = mkOption { extraConfig = mkOption {
@ -520,6 +521,11 @@ in {
assertions = [ assertions = [
(hm.assertions.assertPlatform "wayland.windowManager.sway" pkgs (hm.assertions.assertPlatform "wayland.windowManager.sway" pkgs
platforms.linux) platforms.linux)
{
assertion = cfg.checkConfig -> cfg.package != null;
message =
"programs.sway.checkConfig requires non-null programs.sway.package";
}
]; ];
home.packages = optional (cfg.package != null) cfg.package home.packages = optional (cfg.package != null) cfg.package
@ -527,10 +533,10 @@ in {
xdg.configFile."sway/config" = { xdg.configFile."sway/config" = {
source = configFile; source = configFile;
onChange = '' onChange = lib.optionalString (cfg.package != null) ''
swaySocket="''${XDG_RUNTIME_DIR:-/run/user/$UID}/sway-ipc.$UID.$(${pkgs.procps}/bin/pgrep --uid $UID -x sway || true).sock" swaySocket="''${XDG_RUNTIME_DIR:-/run/user/$UID}/sway-ipc.$UID.$(${pkgs.procps}/bin/pgrep --uid $UID -x sway || true).sock"
if [ -S "$swaySocket" ]; then if [ -S "$swaySocket" ]; then
${swayPackage}/bin/swaymsg -s $swaySocket reload ${cfg.package}/bin/swaymsg -s $swaySocket reload
fi fi
''; '';
}; };