1
0
Fork 0
mirror of https://github.com/nix-community/home-manager synced 2024-11-27 13:39:46 +01:00
home-manager/modules/programs/password-store.nix
David Houston 1d94de5604
pass-secret-service: various improvements
Allow setting the application package and storePath used by the
config. Since the `programs.password-store` Home Manager module sets
config values via global environment variables, the default behavior
of the module should continue to behave as before for the user.

Additionally,

- Adds a few tests.

- Use "escapeShellArg" function call to the path parameter call to
  ensure paths with spaces work.

- Allow not setting storePath, which will cause `pass_secret_service`
  to default to using `~/.password-store`.

- If `pass-secret-service` is enabled, set its store path to default
  to the one defined in our password-store environment settings.

- Add myself (houstdav000) as maintainer.
2023-01-31 23:19:09 +01:00

68 lines
1.8 KiB
Nix

{ config, lib, pkgs, ... }:
with lib;
let
cfg = config.programs.password-store;
in {
meta.maintainers = with maintainers; [ pacien ];
options.programs.password-store = {
enable = mkEnableOption "Password store";
package = mkOption {
type = types.package;
default = pkgs.pass;
defaultText = literalExpression "pkgs.pass";
example = literalExpression ''
pkgs.pass.withExtensions (exts: [ exts.pass-otp ])
'';
description = ''
The <literal>pass</literal> package to use.
Can be used to specify extensions.
'';
};
settings = mkOption rec {
type = with types; attrsOf str;
apply = mergeAttrs default;
default = {
PASSWORD_STORE_DIR = "${config.xdg.dataHome}/password-store";
};
defaultText = literalExpression ''
{ PASSWORD_STORE_DIR = "$XDG_DATA_HOME/password-store"; }
'';
example = literalExpression ''
{
PASSWORD_STORE_DIR = "/some/directory";
PASSWORD_STORE_KEY = "12345678";
PASSWORD_STORE_CLIP_TIME = "60";
}
'';
description = ''
The <literal>pass</literal> environment variables dictionary.
</para><para>
See the "Environment variables" section of
<citerefentry>
<refentrytitle>pass</refentrytitle>
<manvolnum>1</manvolnum>
</citerefentry>
and the extension man pages for more information about the
available keys.
'';
};
};
config = mkIf cfg.enable {
home.packages = [ cfg.package ];
home.sessionVariables = cfg.settings;
services.pass-secret-service.storePath =
mkDefault cfg.settings.PASSWORD_STORE_DIR;
xsession.importedVariables = mkIf config.xsession.enable
(mapAttrsToList (name: value: name) cfg.settings);
};
}