diff --git a/options/custom/programs/1password.nix b/options/custom/programs/1password.nix index df55e6c..899a7b3 100644 --- a/options/custom/programs/1password.nix +++ b/options/custom/programs/1password.nix @@ -7,7 +7,11 @@ with lib; let cfg = config.custom.programs._1password; in { - options.custom.programs._1password.enable = mkOption {default = false;}; + options.custom.programs._1password = { + enable = mkOption {default = false;}; + agent = mkOption {default = true;}; + browser = mkOption {default = null;}; + }; config = mkIf cfg.enable { programs = { @@ -22,5 +26,23 @@ in { polkitPolicyOwners = [config.custom.username]; # Desktop integration }; }; + + # https://wiki.nixos.org/wiki/1Password#Unlocking_browser_extensions + environment.etc = mkIf (isString cfg.browser) { + "1password/custom_allowed_browsers" = { + mode = "0755"; + + text = '' + ${cfg.browser} + ''; + }; + }; + + home-manager.users.${config.custom.username} = { + programs.ssh.extraConfig = mkIf cfg.agent '' + Host * + IdentityAgent ~/.1password/agent.sock + ''; + }; }; } diff --git a/options/custom/programs/ssh.nix b/options/custom/programs/ssh.nix index d789964..248006c 100644 --- a/options/custom/programs/ssh.nix +++ b/options/custom/programs/ssh.nix @@ -16,14 +16,7 @@ in { ''; home-manager.users.${config.custom.username} = { - programs.ssh = { - enable = true; - - extraConfig = '' - Host * - IdentityAgent ~/.1password/agent.sock - ''; - }; + programs.ssh.enable = true; # Work around FHS permissions # https://github.com/nix-community/home-manager/issues/322#issuecomment-1856128020