summaryrefslogtreecommitdiffstats
path: root/modules/programs/_1password.nix
blob: a2fbe6fd97b7d771770ba3b9f0af1a327eb0893d (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
{
  config,
  pkgs,
  lib,
  ...
}:

let
  cfg = config.programs._1password;
in
{
  options = {
    programs._1password = {
      enable = lib.mkEnableOption "the 1Password CLI tool";

      package = lib.mkPackageOption pkgs "1Password CLI" {
        default = [ "_1password-cli" ];
      };
    };
  };

  config = lib.mkIf cfg.enable {
    # Integration with the 1Password GUI will only work if the CLI at `/usr/local/bin/op`
    # Based on https://github.com/reckenrode/nixos-configs/blob/22b8357fc6ffbd0df5ce50dc417c23a807a268a2/modules/by-name/1p/1password/darwin-module.nix
    system.activationScripts.applications.text = lib.mkAfter ''
      install -o root -g wheel -m0555 -D \
        ${lib.getExe cfg.package} /usr/local/bin/op
    '';
  };
}