From 2905e7bd16f22a941e67fe5bd72254efe340b83c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=8C=97=E9=9B=81=20Cryolitia?= Date: Thu, 9 May 2024 05:27:22 +0800 Subject: [PATCH] gpg: add dirmngrSettings --- modules/programs/gpg.nix | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/modules/programs/gpg.nix b/modules/programs/gpg.nix index 8e48a614d..18ba557b5 100644 --- a/modules/programs/gpg.nix +++ b/modules/programs/gpg.nix @@ -18,6 +18,11 @@ let listsAsDuplicateKeys = true; } cfg.scdaemonSettings; + dirmngrCfgText = generators.toKeyValue { + inherit mkKeyValue; + listsAsDuplicateKeys = true; + } cfg.dirmngrSettings; + primitiveType = types.oneOf [ types.str types.bool ]; publicKeyOpts = { config, ... }: { @@ -187,6 +192,24 @@ in { ''; }; + dirmngrSettings = mkOption { + type = + types.attrsOf (types.either primitiveType (types.listOf types.str)); + example = literalExpression '' + { + keyserver = "keyserver.ubuntu.com"; + disable-ipv6 = true; + } + ''; + description = '' + Dirmngr configuration options. Available options are described + in + [ + {manpage}`dirmngr(8)` + ](https://www.gnupg.org/documentation/manuals/gnupg/Dirmngr-Options.html). + ''; + }; + homedir = mkOption { type = types.path; example = literalExpression ''"''${config.xdg.dataHome}/gnupg"''; @@ -247,6 +270,9 @@ in { programs.gpg.scdaemonSettings = { # no defaults for scdaemon }; + programs.gpg.dirmngrSettings = { + # no defaults for dirmngr + }; home.packages = [ cfg.package ]; home.sessionVariables = { GNUPGHOME = cfg.homedir; }; @@ -255,6 +281,8 @@ in { home.file."${cfg.homedir}/scdaemon.conf".text = scdaemonCfgText; + home.file."${cfg.homedir}/dirmngr.conf".text = dirmngrCfgText; + # Link keyring if keys are not mutable home.file."${cfg.homedir}/pubring.kbx" = mkIf (!cfg.mutableKeys && cfg.publicKeys != [ ]) {