nixos/home/modules/git.nix
2025-01-11 17:18:50 +08:00

61 lines
1.3 KiB
Nix

{ config, lib, ... }:
{
options = {
youthlic.programs.git = {
email = lib.mkOption {
type = lib.types.str;
description = ''
git email
'';
};
name = lib.mkOption {
type = lib.types.str;
example = ''youthlic'';
description = ''
git name
'';
};
signKey = lib.mkOption {
type = lib.types.addCheck (lib.types.nullOr lib.types.str) (
x: (x == null || config.youthlic.programs.gpg.enable)
);
default = null;
description = ''
key fingerprint for sign commit
'';
};
};
};
config =
let
cfg = config.youthlic.programs.git;
in
{
programs.lazygit = {
enable = true;
};
programs.gh = {
enable = true;
gitCredentialHelper.enable = true;
settings = {
git_protocol = "ssh";
};
};
programs.git = lib.mkMerge [
{
enable = true;
userEmail = cfg.email;
userName = cfg.name;
delta = {
enable = true;
};
}
(lib.mkIf (cfg.signKey != null) {
signing = {
signByDefault = true;
key = cfg.signKey;
};
})
];
};
}