63 lines
1.9 KiB
Nix
63 lines
1.9 KiB
Nix
|
{ options, config, pkgs, lib, ... }:
|
||
|
|
||
|
with lib;
|
||
|
with lib.plusultra;
|
||
|
let
|
||
|
cfg = config.plusultra.tools.git;
|
||
|
gpg = config.plusultra.security.gpg;
|
||
|
user = config.plusultra.user;
|
||
|
in
|
||
|
{
|
||
|
options.plusultra.tools.git = with types; {
|
||
|
enable = mkEnableOption "Git";
|
||
|
userName = mkOpt types.str user.fullName "The name to configure git with.";
|
||
|
userEmail = mkOpt types.str user.email "The email to configure git with.";
|
||
|
signingKey =
|
||
|
mkOpt types.str "7F3D64824AC0B6B8009E50504BC0896FB5693595" "The key ID to sign commits with.";
|
||
|
signByDefault = mkOpt types.bool false "Whether to sign commits by default.";
|
||
|
};
|
||
|
|
||
|
config = mkIf cfg.enable {
|
||
|
environment.systemPackages = with pkgs; [ git ];
|
||
|
plusultra.home.extraOptions = {
|
||
|
programs.git = {
|
||
|
enable = true;
|
||
|
inherit (cfg) userName userEmail;
|
||
|
lfs = enabled;
|
||
|
signing = {
|
||
|
key = cfg.signingKey;
|
||
|
signByDefault = mkIf gpg.enable true;
|
||
|
};
|
||
|
|
||
|
extraConfig = {
|
||
|
init = { defaultBranch = "main"; };
|
||
|
pull = { rebase = true; };
|
||
|
push = { autoSetupRemote = true; };
|
||
|
core = { whitespace = "trailing-space,space-before-tab"; };
|
||
|
safe = {
|
||
|
directory = "${config.users.users.${user.name}.home}/git";
|
||
|
};
|
||
|
"credential \"https://github.com\"" = {
|
||
|
helper = "!gh auth git-credential";
|
||
|
};
|
||
|
alias = {
|
||
|
co = "checkout";
|
||
|
ci = "commit --signoff";
|
||
|
};
|
||
|
pull.ff = "only";
|
||
|
core.pager = "${pkgs.delta}/bin/delta";
|
||
|
delta = {
|
||
|
features = "decorations";
|
||
|
syntax-theme = "Dracula";
|
||
|
light = "false";
|
||
|
navigate = "true";
|
||
|
};
|
||
|
interactive.diffFilter = "${pkgs.delta}/bin/delta --color-only";
|
||
|
merge.conflictStyle = "diff3";
|
||
|
diff.colorMoved = "default";
|
||
|
};
|
||
|
};
|
||
|
};
|
||
|
};
|
||
|
}
|