fork/home-manager

git clone https://git.julia.blue/fork/home-manager

Robert HelgessonMerge PR #421575790441

master
1.7 KiB65 linesraw
1{ config, lib, pkgs, ... }:
2
3with lib;
4
5let
6
7  cfg = config.programs.password-store;
8
9in {
10  meta.maintainers = with maintainers; [ pacien ];
11
12  options.programs.password-store = {
13    enable = mkEnableOption "Password store";
14
15    package = mkOption {
16      type = types.package;
17      default = pkgs.pass;
18      defaultText = literalExpression "pkgs.pass";
19      example = literalExpression ''
20        pkgs.pass.withExtensions (exts: [ exts.pass-otp ])
21      '';
22      description = ''
23        The `pass` package to use.
24        Can be used to specify extensions.
25      '';
26    };
27
28    settings = mkOption rec {
29      type = with types; attrsOf str;
30      apply = mergeAttrs default;
31      default = {
32        PASSWORD_STORE_DIR = "${config.xdg.dataHome}/password-store";
33      };
34      defaultText = literalExpression ''
35        { PASSWORD_STORE_DIR = "$XDG_DATA_HOME/password-store"; }
36      '';
37      example = literalExpression ''
38        {
39          PASSWORD_STORE_DIR = "/some/directory";
40          PASSWORD_STORE_KEY = "12345678";
41          PASSWORD_STORE_CLIP_TIME = "60";
42        }
43      '';
44      description = ''
45        The `pass` environment variables dictionary.
46
47        See the "Environment variables" section of
48        {manpage}`pass(1)`
49        and the extension man pages for more information about the
50        available keys.
51      '';
52    };
53  };
54
55  config = mkIf cfg.enable {
56    home.packages = [ cfg.package ];
57    home.sessionVariables = cfg.settings;
58
59    services.pass-secret-service.storePath =
60      mkDefault cfg.settings.PASSWORD_STORE_DIR;
61
62    xsession.importedVariables = mkIf config.xsession.enable
63      (mapAttrsToList (name: value: name) cfg.settings);
64  };
65}