fork/home-manager

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

Robert HelgessonMerge PR #421575790441

master
2.0 KiB69 linesraw
1{ pkgs, config, lib, ... }:
2
3with lib;
4
5let
6  cfg = config.services.pass-secret-service;
7
8  busName = "org.freedesktop.secrets";
9in {
10  meta.maintainers = with maintainers; [ cab404 cyntheticfox ];
11
12  options.services.pass-secret-service = {
13    enable = mkEnableOption "Pass libsecret service";
14
15    package = mkPackageOption pkgs "pass-secret-service" { };
16
17    storePath = mkOption {
18      type = with types; nullOr str;
19      default = null;
20      defaultText = "$HOME/.password-store";
21      example = "/home/user/.local/share/password-store";
22      description = ''
23        Absolute path to password store. Defaults to
24        {file}`$HOME/.password-store` if the
25        {option}`programs.password-store` module is not enabled, and
26        {option}`programs.password-store.settings.PASSWORD_STORE_DIR` if it is.
27      '';
28    };
29  };
30
31  config = mkIf cfg.enable {
32    assertions = [
33      (hm.assertions.assertPlatform "services.pass-secret-service" pkgs
34        platforms.linux)
35      {
36        assertion = !config.services.gnome-keyring.enable;
37        message = ''
38          Only one secrets service per user can be enabled at a time.
39          Other services enabled:
40          - gnome-keyring
41        '';
42      }
43    ];
44
45    systemd.user.services.pass-secret-service =
46      let binPath = "${cfg.package}/bin/pass_secret_service";
47      in {
48        Unit = {
49          AssertFileIsExecutable = "${binPath}";
50          Description = "Pass libsecret service";
51          Documentation = "https://github.com/mdellweg/pass_secret_service";
52          PartOf = [ "default.target" ];
53        };
54
55        Service = {
56          Type = "dbus";
57          ExecStart = "${binPath} ${
58              optionalString (cfg.storePath != null) "--path ${cfg.storePath}"
59            }";
60          BusName = busName;
61        };
62
63        Install.WantedBy = [ "default.target" ];
64      };
65
66    xdg.dataFile."dbus-1/services/${busName}.service".source =
67      "${cfg.package}/share/dbus-1/services/${busName}.service";
68  };
69}