2024-01-21 20:56:00 +01:00
|
|
|
{ config, lib, ... }:
|
|
|
|
let
|
|
|
|
inherit (config) jhome;
|
2024-02-02 14:50:26 +01:00
|
|
|
inherit (cfg.defaultIdentity) signingKey;
|
2024-01-21 20:56:00 +01:00
|
|
|
|
|
|
|
cfg = jhome.user;
|
|
|
|
hasConfig = jhome.enable && cfg != null;
|
2024-02-02 14:50:26 +01:00
|
|
|
hasKey = signingKey != null;
|
2024-01-21 20:56:00 +01:00
|
|
|
gpgHome = config.programs.gpg.homedir;
|
2024-02-02 14:50:26 +01:00
|
|
|
unlockKey = hasConfig && cfg.gpg.unlockKeys != [ ];
|
2024-01-21 20:56:00 +01:00
|
|
|
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;
|
2024-02-02 14:50:26 +01:00
|
|
|
key = signingKey;
|
2024-01-21 20:56:00 +01:00
|
|
|
};
|
|
|
|
})
|
|
|
|
(lib.mkIf unlockKey {
|
2024-04-05 11:55:35 +02:00
|
|
|
xdg.configFile.pam-gnupg.text =
|
|
|
|
''
|
|
|
|
${gpgHome}
|
2024-01-21 20:56:00 +01:00
|
|
|
|
2024-04-05 11:55:35 +02:00
|
|
|
''
|
|
|
|
+ (lib.strings.concatLines cfg.gpg.unlockKeys);
|
2024-01-21 20:56:00 +01:00
|
|
|
})
|
|
|
|
];
|
|
|
|
}
|