Files
nix/hosts/common/user/configs/console/git/default.nix
2024-07-16 17:46:58 +03:00

46 lines
925 B
Nix

{
username ? throw "username argument is required",
}:
{
config,
lib,
pkgs,
...
}:
let
userConfig = config.users.users.${username};
hmConfig = config.home-manager.users.${username};
in
{
home-manager.users.${username} = {
programs.git = {
enable = true;
lfs.enable = true;
userName = userConfig.fullName;
userEmail = userConfig.email;
signing = {
signByDefault = true;
key = null;
};
extraConfig = {
credential.helper = "store";
push.autoSetupRemote = true;
};
hooks = {
commit-msg = lib.meta.getExe (
pkgs.writeShellApplication {
name = "git-commit-msg-hook";
runtimeInputs = with pkgs; [ git ];
text = builtins.readFile ./commit-msg.sh;
}
);
};
};
sops.secrets."git".path = "${hmConfig.xdg.configHome}/git/credentials";
};
}