diff --git a/modules/services/sxhkd.nix b/modules/services/sxhkd.nix index 1187b5ed3..9a2027a83 100644 --- a/modules/services/sxhkd.nix +++ b/modules/services/sxhkd.nix @@ -72,10 +72,12 @@ in cfg.extraConfig ]; - xsession.initExtra = '' - systemctl --user stop sxhkd.scope 2> /dev/null || true - systemd-cat -t sxhkd systemd-run --user --scope -u sxhkd \ - ${cfg.package}/bin/sxhkd ${toString cfg.extraOptions} & - ''; + xsession.initExtra = + let + sxhkdCommand = "${cfg.package}/bin/sxhkd ${toString cfg.extraOptions}"; + in '' + systemctl --user stop sxhkd.scope 2> /dev/null || true + systemd-cat -t sxhkd systemd-run --user --scope -u sxhkd ${sxhkdCommand} & + ''; }; } diff --git a/tests/modules/services/sxhkd/service.nix b/tests/modules/services/sxhkd/service.nix index a3ade9dbe..be51f544c 100644 --- a/tests/modules/services/sxhkd/service.nix +++ b/tests/modules/services/sxhkd/service.nix @@ -1,15 +1,5 @@ { config, pkgs, ... }: -let - - expectedFileRegex = '' - systemctl --user stop sxhkd.scope 2> /dev/null || true - systemd-cat -t sxhkd systemd-run --user --scope -u sxhkd \ - @sxhkd@/bin/sxhkd -m 1 & - ''; - -in - { config = { xsession = { @@ -28,7 +18,11 @@ in assertFileExists $xsessionFile - assertFileRegex $xsessionFile ${expectedFileRegex} + assertFileContains $xsessionFile \ + 'systemctl --user stop sxhkd.scope 2> /dev/null || true' + + assertFileContains $xsessionFile \ + 'systemd-cat -t sxhkd systemd-run --user --scope -u sxhkd @sxhkd@/bin/sxhkd -m 1 &' ''; }; }