From d1ac88811f0235f9ba0834ab1ac970e6f4e7ffc0 Mon Sep 17 00:00:00 2001 From: Michael Hoang Date: Sat, 26 Mar 2022 11:50:04 +1100 Subject: [PATCH] nixos/_1password: init --- nixos/modules/module-list.nix | 1 + nixos/modules/programs/_1password.nix | 46 +++++++++++++++++++++++++++ 2 files changed, 47 insertions(+) create mode 100644 nixos/modules/programs/_1password.nix diff --git a/nixos/modules/module-list.nix b/nixos/modules/module-list.nix index 71c84fbe6b4b..adeddbf139a3 100644 --- a/nixos/modules/module-list.nix +++ b/nixos/modules/module-list.nix @@ -118,6 +118,7 @@ ./misc/version.nix ./misc/wordlist.nix ./misc/nixops-autoluks.nix + ./programs/_1password.nix ./programs/_1password-gui.nix ./programs/adb.nix ./programs/appgate-sdp.nix diff --git a/nixos/modules/programs/_1password.nix b/nixos/modules/programs/_1password.nix new file mode 100644 index 000000000000..eae518e61ca7 --- /dev/null +++ b/nixos/modules/programs/_1password.nix @@ -0,0 +1,46 @@ +{ config, pkgs, lib, ... }: + +with lib; + +let + cfg = config.programs._1password; +in { + options = { + programs._1password = { + enable = mkEnableOption "The 1Password CLI tool with biometric unlock and integration with the 1Password GUI."; + + groupId = mkOption { + type = types.int; + example = literalExpression "5001"; + description = '' + The GroupID to assign to the onepassword-cli group, which is needed for integration with the 1Password GUI. The group ID must be 1000 or greater. + ''; + }; + + package = mkOption { + type = types.package; + default = pkgs._1password; + defaultText = literalExpression "pkgs._1password"; + example = literalExpression "pkgs._1password"; + description = '' + The 1Password CLI derivation to use. + ''; + }; + }; + }; + + config = mkIf cfg.enable { + environment.systemPackages = [ cfg.package ]; + users.groups.onepassword-cli.gid = cfg.groupId; + + security.wrappers = { + "op" = { + source = "${cfg.package}/bin/op"; + owner = "root"; + group = "onepassword-cli"; + setuid = false; + setgid = true; + }; + }; + }; +}