diff --git a/modules/services/pass-secret-service.nix b/modules/services/pass-secret-service.nix index 8b532f43b..bbaf28a2e 100644 --- a/modules/services/pass-secret-service.nix +++ b/modules/services/pass-secret-service.nix @@ -28,11 +28,10 @@ in defaultText = "$HOME/.password-store"; example = "/home/user/.local/share/password-store"; description = '' - Absolute path to password store, default upstream value of which is - {file}`$HOME/.password-store`. If the - {option}`programs.password-store` module is enabled and - {option}`programs.password-store.settings.PASSWORD_STORE_DIR` is set, - it will inherit the value from the latter. + Absolute path to the password store. If the + {option}`programs.password-store` module is enabled, the + {option}`programs.password-store.settings.PASSWORD_STORE_DIR` option + will be checked, if found it will be inherited as the default. ''; }; }; @@ -56,7 +55,7 @@ in in { Unit = { - AssertFileIsExecutable = "${binPath}"; + AssertFileIsExecutable = binPath; Description = "Pass libsecret service"; Documentation = "https://github.com/mdellweg/pass_secret_service"; PartOf = [ "default.target" ]; @@ -64,7 +63,7 @@ in Service = { Type = "dbus"; - ExecStart = "${binPath} ${lib.optionalString (cfg.storePath != null) "--path ${cfg.storePath}"}"; + ExecStart = binPath + lib.optionalString (cfg.storePath != null) " --path ${cfg.storePath}"; BusName = busName; Environment = [ "GNUPGHOME=${config.programs.gpg.homedir}" ]; }; diff --git a/tests/modules/programs/password-store/default-path.nix b/tests/modules/programs/password-store/default-path.nix new file mode 100644 index 000000000..b9ee3b50d --- /dev/null +++ b/tests/modules/programs/password-store/default-path.nix @@ -0,0 +1,9 @@ +{ + home.stateVersion = "25.11"; # Or any other newer version + programs.password-store.enable = true; + + nmt.script = '' + assertFileNotRegex home-path/etc/profile.d/hm-session-vars.sh \ + '^export PASSWORD_STORE_DIR=' + ''; +} diff --git a/tests/modules/programs/password-store/default.nix b/tests/modules/programs/password-store/default.nix new file mode 100644 index 000000000..9520fea01 --- /dev/null +++ b/tests/modules/programs/password-store/default.nix @@ -0,0 +1,5 @@ +{ + password-store-default-path = ./default-path.nix; + password-store-old-default-path = ./old-default-path.nix; + password-store-nondefault-path = ./nondefault-path.nix; +} diff --git a/tests/modules/programs/password-store/nondefault-path.nix b/tests/modules/programs/password-store/nondefault-path.nix new file mode 100644 index 000000000..a577fbf55 --- /dev/null +++ b/tests/modules/programs/password-store/nondefault-path.nix @@ -0,0 +1,15 @@ +let + somePath = "/some/random/path/I/store/pwds"; +in +{ + home.stateVersion = "25.11"; + programs.password-store = { + enable = true; + settings.PASSWORD_STORE_DIR = somePath; + }; + + nmt.script = '' + assertFileContains home-path/etc/profile.d/hm-session-vars.sh \ + 'export PASSWORD_STORE_DIR="${somePath}"' + ''; +} diff --git a/tests/modules/programs/password-store/old-default-path.nix b/tests/modules/programs/password-store/old-default-path.nix new file mode 100644 index 000000000..08b2c8a3f --- /dev/null +++ b/tests/modules/programs/password-store/old-default-path.nix @@ -0,0 +1,10 @@ +{ config, ... }: +{ + home.stateVersion = "25.05"; # <= 25.11 + programs.password-store.enable = true; + + nmt.script = '' + assertFileContains home-path/etc/profile.d/hm-session-vars.sh \ + 'export PASSWORD_STORE_DIR="${config.xdg.dataHome}/password-store"' + ''; +} diff --git a/tests/modules/services/pass-secret-service/default-configuration.nix b/tests/modules/services/pass-secret-service/default-configuration.nix index cf2bbe693..8483aaf4a 100644 --- a/tests/modules/services/pass-secret-service/default-configuration.nix +++ b/tests/modules/services/pass-secret-service/default-configuration.nix @@ -10,6 +10,6 @@ serviceFile=home-files/.config/systemd/user/pass-secret-service.service assertFileExists $serviceFile - assertFileRegex $serviceFile 'ExecStart=.*/bin/pass_secret_service' + assertFileRegex $serviceFile '^ExecStart=.*/bin/pass_secret_service$' ''; } diff --git a/tests/modules/services/pass-secret-service/default.nix b/tests/modules/services/pass-secret-service/default.nix index dba745f3b..50f6720d7 100644 --- a/tests/modules/services/pass-secret-service/default.nix +++ b/tests/modules/services/pass-secret-service/default.nix @@ -2,5 +2,7 @@ lib.optionalAttrs pkgs.stdenv.hostPlatform.isLinux { pass-secret-service-default-configuration = ./default-configuration.nix; + pass-secret-service-old-default-path = ./old-default-path.nix; + pass-secret-service-nondefault-path = ./nondefault-path.nix; pass-secret-service-basic-configuration = ./basic-configuration.nix; } diff --git a/tests/modules/services/pass-secret-service/nondefault-path.nix b/tests/modules/services/pass-secret-service/nondefault-path.nix new file mode 100644 index 000000000..910af0fa2 --- /dev/null +++ b/tests/modules/services/pass-secret-service/nondefault-path.nix @@ -0,0 +1,20 @@ +{ config, ... }: +let + somePath = "/some/random/path/I/store/pwds"; +in +{ + home.stateVersion = "25.11"; + programs.password-store = { + enable = true; + settings.PASSWORD_STORE_DIR = somePath; + }; + services.pass-secret-service = { + enable = true; + package = config.lib.test.mkStubPackage { }; + }; + + nmt.script = '' + assertFileContains home-files/.config/systemd/user/pass-secret-service.service \ + 'ExecStart=${config.services.pass-secret-service.package}/bin/pass_secret_service --path ${somePath}' + ''; +} diff --git a/tests/modules/services/pass-secret-service/old-default-path.nix b/tests/modules/services/pass-secret-service/old-default-path.nix new file mode 100644 index 000000000..d65a7597c --- /dev/null +++ b/tests/modules/services/pass-secret-service/old-default-path.nix @@ -0,0 +1,17 @@ +{ config, ... }: + +{ + home.stateVersion = "25.05"; # <= 25.11 + programs.password-store.enable = true; + services.pass-secret-service = { + enable = true; + package = config.lib.test.mkStubPackage { }; + }; + + nmt.script = '' + serviceFile=home-files/.config/systemd/user/pass-secret-service.service + + assertFileExists $serviceFile + assertFileRegex $serviceFile '^ExecStart=.*/bin/pass_secret_service --path ${config.xdg.dataHome}/password-store$' + ''; +}