password-store: do not set non-default dir

This commit is contained in:
octvs 2025-09-18 00:53:37 +02:00 committed by Austin Horstman
parent 295d90e22d
commit 14bc4c56fc
3 changed files with 22 additions and 11 deletions

View file

@ -77,4 +77,7 @@ The state version in this release includes the changes below. These
changes are only active if the `home.stateVersion` option is set to
\"25.11\" or later.
- No changes.
- The `programs.password-store.settings` option does not set
`{ PASSWORD_STORE_DIR = $XDG_DATA_HOME/password-store; }` anymore by its
default value. This will revert to the default behaviour of the program,
namely `$HOME/.password-store` to be used as the store path.

View file

@ -24,15 +24,20 @@ in
settings = mkOption rec {
type = with types; attrsOf str;
apply = lib.mergeAttrs default;
default = {
PASSWORD_STORE_DIR = "${config.xdg.dataHome}/password-store";
};
default =
if lib.versionOlder config.home.stateVersion "25.11" then
{
PASSWORD_STORE_DIR = "${config.xdg.dataHome}/password-store";
}
else
{ };
defaultText = literalExpression ''
{ PASSWORD_STORE_DIR = "$XDG_DATA_HOME/password-store"; }
{ } for state version 25.11
{ PASSWORD_STORE_DIR = "$XDG_DATA_HOME/password-store"; } for state version < 25.11
'';
example = literalExpression ''
{
PASSWORD_STORE_DIR = "/some/directory";
PASSWORD_STORE_DIR = "$\{config.xdg.dataHome\}/password-store";
PASSWORD_STORE_KEY = "12345678";
PASSWORD_STORE_CLIP_TIME = "60";
}
@ -52,7 +57,9 @@ in
home.packages = [ cfg.package ];
home.sessionVariables = cfg.settings;
services.pass-secret-service.storePath = lib.mkDefault cfg.settings.PASSWORD_STORE_DIR;
services.pass-secret-service = lib.mkIf (builtins.hasAttr "PASSWORD_STORE_DIR" cfg.settings) {
storePath = cfg.settings.PASSWORD_STORE_DIR;
};
xsession.importedVariables = lib.mkIf config.xsession.enable (
lib.mapAttrsToList (name: value: name) cfg.settings

View file

@ -28,10 +28,11 @@ in
defaultText = "$HOME/.password-store";
example = "/home/user/.local/share/password-store";
description = ''
Absolute path to password store. Defaults to
{file}`$HOME/.password-store` if the
{option}`programs.password-store` module is not enabled, and
{option}`programs.password-store.settings.PASSWORD_STORE_DIR` if it is.
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.
'';
};
};