configuration.nix/home/users.nix

44 lines
1 KiB
Nix
Raw Normal View History

2024-05-04 20:57:33 +02:00
{
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;
2024-05-04 20:57:33 +02:00
unlockKey = hasConfig && cfg.gpg.unlockKeys != [];
in {
config = lib.mkMerge [
(lib.mkIf hasConfig {
2024-04-19 18:38:01 +02:00
programs.git = {
userName = cfg.defaultIdentity.name;
userEmail = cfg.defaultIdentity.email;
signing = lib.mkIf hasKey {
signByDefault = true;
key = signingKey;
};
};
programs.jujutsu.settings = {
2024-05-04 20:57:33 +02:00
user = lib.mkIf (cfg.defaultIdentity != null) {inherit (cfg.defaultIdentity) name email;};
2024-04-19 18:38:01 +02:00
signing = lib.mkIf hasKey {
2024-04-19 20:08:24 +02:00
sign-all = true;
2024-04-19 21:06:18 +02:00
backend = "gpg";
2024-04-19 18:38:01 +02:00
key = signingKey;
};
};
})
(lib.mkIf unlockKey {
xdg.configFile.pam-gnupg.text =
''
${gpgHome}
''
+ (lib.strings.concatLines cfg.gpg.unlockKeys);
})
];
}