summary refs log tree commit diff
path: root/nixos/modules/programs
diff options
context:
space:
mode:
authorMichele Guerini Rocco <rnhmjoj@users.noreply.github.com>2023-10-09 11:12:55 +0200
committerGitHub <noreply@github.com>2023-10-09 11:12:55 +0200
commit2e541873997618b1c258306e798bbfa4c45b7d35 (patch)
tree816dc78c7029618cce4254e6be7a277db9f31fb4 /nixos/modules/programs
parent2b82a1fe8f2704a21c6e15434ac7863aaf48723b (diff)
parentf0a8e05a5d95d2b4e08b53e0ae6c3bbe38b98945 (diff)
downloadnixpkgs-2e541873997618b1c258306e798bbfa4c45b7d35.tar
nixpkgs-2e541873997618b1c258306e798bbfa4c45b7d35.tar.gz
nixpkgs-2e541873997618b1c258306e798bbfa4c45b7d35.tar.bz2
nixpkgs-2e541873997618b1c258306e798bbfa4c45b7d35.tar.lz
nixpkgs-2e541873997618b1c258306e798bbfa4c45b7d35.tar.xz
nixpkgs-2e541873997618b1c258306e798bbfa4c45b7d35.tar.zst
nixpkgs-2e541873997618b1c258306e798bbfa4c45b7d35.zip
Merge pull request #258347 from Benjamin-L/gnupg-agent-extraconfig
nixos/gnupg: add agent.settings option
Diffstat (limited to 'nixos/modules/programs')
-rw-r--r--nixos/modules/programs/gnupg.nix27
1 files changed, 23 insertions, 4 deletions
diff --git a/nixos/modules/programs/gnupg.nix b/nixos/modules/programs/gnupg.nix
index 12ef8671b74..aa1a536247c 100644
--- a/nixos/modules/programs/gnupg.nix
+++ b/nixos/modules/programs/gnupg.nix
@@ -6,6 +6,10 @@ let
 
   cfg = config.programs.gnupg;
 
+  agentSettingsFormat = pkgs.formats.keyValue {
+    mkKeyValue = lib.generators.mkKeyValueDefault { } " ";
+  };
+
   xserverCfg = config.services.xserver;
 
   defaultPinentryFlavor =
@@ -82,6 +86,18 @@ in
       '';
     };
 
+    agent.settings = mkOption {
+      type = agentSettingsFormat.type;
+      default = { };
+      example = {
+        default-cache-ttl = 600;
+      };
+      description = lib.mdDoc ''
+        Configuration for /etc/gnupg/gpg-agent.conf.
+        See {manpage}`gpg-agent(1)` for supported options.
+      '';
+    };
+
     dirmngr.enable = mkOption {
       type = types.bool;
       default = false;
@@ -92,10 +108,13 @@ in
   };
 
   config = mkIf cfg.agent.enable {
-    environment.etc."gnupg/gpg-agent.conf".text =
-      lib.optionalString (cfg.agent.pinentryFlavor != null) ''
-      pinentry-program ${pkgs.pinentry.${cfg.agent.pinentryFlavor}}/bin/pinentry
-    '';
+    programs.gnupg.agent.settings = {
+      pinentry-program = lib.mkIf (cfg.agent.pinentryFlavor != null)
+        "${pkgs.pinentry.${cfg.agent.pinentryFlavor}}/bin/pinentry";
+    };
+
+    environment.etc."gnupg/gpg-agent.conf".source =
+      agentSettingsFormat.generate "gpg-agent.conf" cfg.agent.settings;
 
     # This overrides the systemd user unit shipped with the gnupg package
     systemd.user.services.gpg-agent = {