diff options
author | Benjamin Lee <benjamin@computer.surgery> | 2023-09-30 22:36:30 -0700 |
---|---|---|
committer | Benjamin Lee <benjamin@computer.surgery> | 2023-10-05 18:43:23 -0700 |
commit | f0a8e05a5d95d2b4e08b53e0ae6c3bbe38b98945 (patch) | |
tree | 08fc19833eff68707ef9e31ca0141939efff5553 | |
parent | 8a86b98f0ba1c405358f1b71ff8b5e1d317f5db2 (diff) | |
download | nixpkgs-f0a8e05a5d95d2b4e08b53e0ae6c3bbe38b98945.tar nixpkgs-f0a8e05a5d95d2b4e08b53e0ae6c3bbe38b98945.tar.gz nixpkgs-f0a8e05a5d95d2b4e08b53e0ae6c3bbe38b98945.tar.bz2 nixpkgs-f0a8e05a5d95d2b4e08b53e0ae6c3bbe38b98945.tar.lz nixpkgs-f0a8e05a5d95d2b4e08b53e0ae6c3bbe38b98945.tar.xz nixpkgs-f0a8e05a5d95d2b4e08b53e0ae6c3bbe38b98945.tar.zst nixpkgs-f0a8e05a5d95d2b4e08b53e0ae6c3bbe38b98945.zip |
nixos/gnupg: add agent.settings option
-rw-r--r-- | nixos/doc/manual/release-notes/rl-2311.section.md | 2 | ||||
-rw-r--r-- | nixos/modules/programs/gnupg.nix | 27 |
2 files changed, 25 insertions, 4 deletions
diff --git a/nixos/doc/manual/release-notes/rl-2311.section.md b/nixos/doc/manual/release-notes/rl-2311.section.md index 91715616be4..23e62047f9b 100644 --- a/nixos/doc/manual/release-notes/rl-2311.section.md +++ b/nixos/doc/manual/release-notes/rl-2311.section.md @@ -302,6 +302,8 @@ The module update takes care of the new config syntax and the data itself (user - `programs.gnupg.agent.pinentryFlavor` is now set in `/etc/gnupg/gpg-agent.conf`, and will no longer take precedence over a `pinentry-program` set in `~/.gnupg/gpg-agent.conf`. +- `programs.gnupg` now has the option `agent.settings` to set verbatim config values in `/etc/gnupg/gpg-agent.conf`. + - `dockerTools.buildImage`, `dockerTools.buildLayeredImage` and `dockerTools.streamLayeredImage` now use `lib.makeOverridable` to allow `dockerTools`-based images to be customized more efficiently at the nix-level. - `services.influxdb2` now supports doing an automatic initial setup and provisioning of users, organizations, buckets and authentication tokens, see [#249502](https://github.com/NixOS/nixpkgs/pull/249502) for more details. diff --git a/nixos/modules/programs/gnupg.nix b/nixos/modules/programs/gnupg.nix index 697b6e9a0bd..d67820a824a 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 = { |