aboutsummaryrefslogtreecommitdiff
path: root/home-manager/modules/programs/password-store.nix
blob: db31146a1ba30bb345a5fb36a808d3548d02ebe1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
{ 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 = literalExample "pkgs.pass";
      example = literalExample ''
        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 = literalExample ''
        { PASSWORD_STORE_DIR = "$XDG_DATA_HOME/password-store"; }
      '';
      example = literalExample ''
        {
          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;
  };
}