about summary refs log tree commit diff
path: root/nixpkgs/nixos/modules/programs/_1password-gui.nix
blob: f57de44bb9e268f5f74ee8e12e4f4131333d305b (plain) (blame)
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
63
64
65
66
67
68
69
{ config, pkgs, lib, ... }:

with lib;

let
  cfg = config.programs._1password-gui;

in {
  options = {
    programs._1password-gui = {
      enable = mkEnableOption "The 1Password Desktop application with browser integration";

      groupId = mkOption {
        type = types.int;
        example = literalExpression "5000";
        description = ''
          The GroupID to assign to the onepassword group, which is needed for browser integration. The group ID must be 1000 or greater.
          '';
      };

      polkitPolicyOwners = mkOption {
        type = types.listOf types.str;
        default = [];
        example = literalExpression "[\"user1\" \"user2\" \"user3\"]";
        description = ''
          A list of users who should be able to integrate 1Password with polkit-based authentication mechanisms. By default, no users will have such access.
          '';
      };

      package = mkOption {
        type = types.package;
        default = pkgs._1password-gui;
        defaultText = literalExpression "pkgs._1password-gui";
        example = literalExpression "pkgs._1password-gui";
        description = ''
          The 1Password derivation to use. This can be used to upgrade from the stable release that we keep in nixpkgs to the betas.
          '';
      };
    };
  };

  config = let
    package = cfg.package.override {
      polkitPolicyOwners = cfg.polkitPolicyOwners;
    };
  in mkIf cfg.enable {
    environment.systemPackages = [ package ];
    users.groups.onepassword.gid = cfg.groupId;

    security.wrappers = {
      "1Password-BrowserSupport" =
        { source = "${cfg.package}/share/1password/1Password-BrowserSupport";
          owner = "root";
          group = "onepassword";
          setuid = false;
          setgid = true;
        };

      "1Password-KeyringHelper" =
        { source = "${cfg.package}/share/1password/1Password-KeyringHelper";
          owner = "root";
          group = "onepassword";
          setuid = true;
          setgid = true;
        };
    };

  };
}