system/home/progs/git.nix

82 lines
1.8 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";
};
2022-08-29 15:40:41 +03:00
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";
};
2022-09-01 22:04:00 +03:00
git-crypt = {
enable = mkOption {
type = types.bool;
default = false;
description = "Add git-crypt package";
};
};
};
2022-08-29 15:40:41 +03:00
config = mkIf cfg.enable {
2022-09-01 22:04:00 +03:00
home.packages = mkIf cfg.git-crypt.enable [ pkgs.git-crypt ];
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";
};
};
};
}