configuration.nix/home/users.nix
Jalil David Salamé Messina 9cd372c4f3
fix(#5): Separate gpg keygrip from keyID
pam-gnupg wants the keygrip, git wants the keyID
2024-02-02 14:54:40 +01:00

29 lines
733 B
Nix

{ config, lib, ... }:
let
inherit (config) jhome;
inherit (cfg.defaultIdentity) signingKey;
cfg = jhome.user;
hasConfig = jhome.enable && cfg != null;
hasKey = signingKey != null;
gpgHome = config.programs.gpg.homedir;
unlockKey = hasConfig && cfg.gpg.unlockKeys != [ ];
in
{
config = lib.mkMerge [
(lib.mkIf hasConfig {
programs.git.userName = cfg.defaultIdentity.name;
programs.git.userEmail = cfg.defaultIdentity.email;
programs.git.signing = lib.mkIf hasKey {
signByDefault = true;
key = signingKey;
};
})
(lib.mkIf unlockKey {
xdg.configFile.pam-gnupg.text = ''
${gpgHome}
'' + (lib.strings.concatLines cfg.gpg.unlockKeys);
})
];
}