From 43ea4c5123d9d335ff4eba6341509d45f60ceeec Mon Sep 17 00:00:00 2001 From: Joe Neeman Date: Sun, 3 Jul 2022 11:28:29 -0500 Subject: [PATCH] swayidle: fix systemd service swayidle executes commands using "sh -c" and so its PATH must contain a shell. This adds such PATH entry to the environment of the systemd service. Fixes #2811. --- modules/services/swayidle.nix | 2 ++ tests/modules/services/swayidle/basic-configuration.nix | 3 +++ 2 files changed, 5 insertions(+) diff --git a/modules/services/swayidle.nix b/modules/services/swayidle.nix index 217fb4354..ad31642eb 100644 --- a/modules/services/swayidle.nix +++ b/modules/services/swayidle.nix @@ -108,6 +108,8 @@ in { Service = { Type = "simple"; + # swayidle executes commands using "sh -c", so the PATH needs to contain a shell. + Environment = [ "PATH=${makeBinPath [ pkgs.bash ]}" ]; ExecStart = "${cfg.package}/bin/swayidle -w ${concatStringsSep " " args}"; }; diff --git a/tests/modules/services/swayidle/basic-configuration.nix b/tests/modules/services/swayidle/basic-configuration.nix index d3c6bef73..4ecc13089 100644 --- a/tests/modules/services/swayidle/basic-configuration.nix +++ b/tests/modules/services/swayidle/basic-configuration.nix @@ -47,6 +47,9 @@ assertFileExists $serviceFile assertFileRegex $serviceFile 'ExecStart=.*/bin/swayidle ${expectedArgs}' + assertFileRegex $serviceFile 'Environment=.*PATH=${ + lib.makeBinPath [ pkgs.bash ] + }' ''; }; }