From 92ec5a59fd1703ce91eb2ce095f3568bc09a20e1 Mon Sep 17 00:00:00 2001 From: alejandro-angulo Date: Thu, 1 Aug 2024 21:21:31 -0700 Subject: [PATCH] Converted gpg from nixos module to home module --- homes/x86_64-linux/alejandro/default.nix | 1 + modules/home/programs/gpg/default.nix | 44 ++++++++++++++++++++ modules/nixos/suites/development/default.nix | 4 -- modules/nixos/suites/utils/default.nix | 1 + modules/nixos/tools/gpg/default.nix | 43 ------------------- systems/x86_64-linux/node/default.nix | 1 - 6 files changed, 46 insertions(+), 48 deletions(-) create mode 100644 modules/home/programs/gpg/default.nix delete mode 100644 modules/nixos/tools/gpg/default.nix diff --git a/homes/x86_64-linux/alejandro/default.nix b/homes/x86_64-linux/alejandro/default.nix index 224a2a0..dbb197b 100644 --- a/homes/x86_64-linux/alejandro/default.nix +++ b/homes/x86_64-linux/alejandro/default.nix @@ -16,6 +16,7 @@ programs = { firefox.enable = true; + gpg.enable = true; kitty.enable = true; }; diff --git a/modules/home/programs/gpg/default.nix b/modules/home/programs/gpg/default.nix new file mode 100644 index 0000000..90b155c --- /dev/null +++ b/modules/home/programs/gpg/default.nix @@ -0,0 +1,44 @@ +{ + config, + pkgs, + lib, + namespace, + system, + ... +}: let + inherit (lib) mkIf mkEnableOption; + + cfg = config.${namespace}.programs.gpg; +in { + options.${namespace}.programs.gpg = { + enable = mkEnableOption "gpg"; + }; + + config = mkIf cfg.enable { + programs.gpg = { + enable = true; + scdaemonSettings = { + # Fix conflicts with config in common/yubikey.nix + disable-ccid = true; + }; + }; + + programs.ssh.matchBlocks = { + # Fix for pinentry showing up in wrong terminal + "*".match = "host * exec \"gpg-connect-agent UPDATESTARTUPTTY /bye\""; + }; + + # gpg-agent configuration does not work on darwin + # see here: https://github.com/nix-community/home-manager/issues/3864 + services.gpg-agent = mkIf (system == "x86_64-linux") { + enable = true; + pinentryPackage = pkgs.pinentry-curses; + enableZshIntegration = true; + enableSshSupport = true; + sshKeys = [ + # run `gpg-connect-agent 'keyinfo --list' /bye` to get these values for existing keys + "E274D5078327CB6C8C83CFF102CC12A2D493C77F" + ]; + }; + }; +} diff --git a/modules/nixos/suites/development/default.nix b/modules/nixos/suites/development/default.nix index e83c1d3..ed347af 100644 --- a/modules/nixos/suites/development/default.nix +++ b/modules/nixos/suites/development/default.nix @@ -13,10 +13,6 @@ in { config = mkIf cfg.enable { aa = { - tools = { - gpg.enable = true; - }; - apps = { neovim.enable = true; }; diff --git a/modules/nixos/suites/utils/default.nix b/modules/nixos/suites/utils/default.nix index 8546047..ba6460a 100644 --- a/modules/nixos/suites/utils/default.nix +++ b/modules/nixos/suites/utils/default.nix @@ -24,6 +24,7 @@ in { du-dust fd file + gnupg htop jq killall diff --git a/modules/nixos/tools/gpg/default.nix b/modules/nixos/tools/gpg/default.nix deleted file mode 100644 index e8b688f..0000000 --- a/modules/nixos/tools/gpg/default.nix +++ /dev/null @@ -1,43 +0,0 @@ -{ - config, - pkgs, - lib, - ... -}: -with lib; let - cfg = config.aa.tools.gpg; -in { - options.aa.tools.gpg = with types; { - enable = mkEnableOption "gpg"; - }; - - config = mkIf cfg.enable { - environment.systemPackages = [pkgs.gnupg ]; - - aa.home.extraOptions = { - programs.gpg = { - enable = true; - scdaemonSettings = { - # Fix conflicts with config in common/yubikey.nix - disable-ccid = true; - }; - }; - - programs.ssh.matchBlocks = { - # Fix for pinentry showing up in wrong terminal - "*".match = "host * exec \"gpg-connect-agent UPDATESTARTUPTTY /bye\""; - }; - - services.gpg-agent = { - enable = true; - pinentryPackage = pkgs.pinentry-curses; - enableZshIntegration = true; # TODO: Only set if using zsh - enableSshSupport = true; - sshKeys = [ - # run `gpg-connect-agent 'keyinfo --list' /bye` to get these values for existing keys - "E274D5078327CB6C8C83CFF102CC12A2D493C77F" - ]; - }; - }; - }; -} diff --git a/systems/x86_64-linux/node/default.nix b/systems/x86_64-linux/node/default.nix index ce83cea..7bec2f1 100644 --- a/systems/x86_64-linux/node/default.nix +++ b/systems/x86_64-linux/node/default.nix @@ -83,7 +83,6 @@ suites.utils.enable = true; - tools.gpg.enable = true; apps.yubikey.enable = true; };