system/nix/progs/git.nix

72 lines
1.6 KiB
Nix
Raw Normal View History

{ lib, config, pkgs, ... }:
with lib;
let
cfg = config.progs.git;
in
{
options.progs.git = {
enable = mkOption {
type = types.bool;
default = false;
description = "Add git with my personal settings";
};
userName = mkOption {
type = types.str;
description = "Set your global name";
};
userEmail = mkOption {
type = types.str;
description = "Set your global email";
};
2022-06-01 16:48:29 +03:00
gpgKey = mkOption {
type = types.nullOr types.str;
default = null;
description = "The default GnuPG signing key fingerprint";
};
};
config = mkIf cfg.enable {
programs.git = {
enable = true;
userName = cfg.userName;
userEmail = cfg.userEmail;
2022-06-01 16:48:29 +03:00
signing = mkIf (cfg.gpgKey != null) {
key = cfg.gpgKey;
signByDefault = true;
};
extraConfig = {
init.defaultBranch = "main";
pull.rebase = true;
};
aliases = {
co = "checkout";
cob = "checkout -b";
cobf = "checkout -B";
st = "status -sb";
d = "diff";
dc = "diff --cached";
aa = "add .";
ai = "add -i";
c = "commit";
cm = "commit -m";
ca = "commit --amend";
cam = "commit --amend -m";
can = "commit --amend --no-edit";
p = "push";
po = "push origin";
pf = "push --force-with-lease";
pfo = "push --force-with-lease origin";
pl = "pull";
plo = "pull origin";
rb = "rebase";
rbi = "rebase -i";
};
};
};
}