chore(home-manager/gpg-agent): template agent configuration from upstream dotfiles

This commit is contained in:
transcaffeine 2024-12-03 20:22:55 +01:00
parent bd46837713
commit a0d0477fa2
Signed by: transcaffeine
GPG Key ID: 03624C433676E465

View File

@ -1,10 +1,14 @@
{ lib, ... }: { { lib, ... }:
let
repo = (builtins.fetchGit {
url = "https://git.finally.coffee/transcaffeine/dotfiles.git";
ref = "main";
shallow = true;
});
utils = import ../../../utils { inherit lib; };
in {
programs.gpg = let programs.gpg = let
repo = (builtins.fetchGit {
url = "https://git.finally.coffee/transcaffeine/dotfiles.git";
ref = "main";
shallow = true;
});
gpgconf = builtins.listToAttrs ( gpgconf = builtins.listToAttrs (
map (entry: { map (entry: {
name = toString (lib.sublist 0 1 (lib.splitString " " entry)); name = toString (lib.sublist 0 1 (lib.splitString " " entry));
@ -21,4 +25,32 @@
enable = true; enable = true;
settings = gpgconf; settings = gpgconf;
}; };
services.gpg-agent = let
gpg_agent_config = builtins.listToAttrs (
map (entry: let
val = toString (lib.sublist 1 100 (lib.splitString " " entry));
emptyStringToTrue = (x: if lib.isBool x then x else if x == "" then true else x);
in {
name = toString (lib.sublist 0 1 (lib.splitString " " entry));
value = emptyStringToTrue val;
}) (
builtins.filter (v: v != "") (
lib.splitString "\n" (
lib.readFile (repo.outPath + "/config/gnupg/gpg-agent.conf")
)
)
)
);
in {
enable = true;
enableSshSupport = gpg_agent_config."enable-ssh-support";
defaultCacheTtl = gpg_agent_config."default-cache-ttl" or 300;
maxCacheTtl = gpg_agent_config."max-cache-ttl" or 900;
defaultCacheTtlSsh = gpg_agent_config."default-cache-ttl-ssh" or 300;
maxCacheTtlSsh = gpg_agent_config."max-cache-ttl-ssh" or 900;
extraConfig = utils.attrsToConfig {
"ignore-cache-for-signing" = gpg_agent_config."ignore-cache-for-signing";
"no-allow-external-cache" = gpg_agent_config."no-allow-external-cache";
};
};
} }