system/users/modules/git.nix

74 lines
1.6 KiB
Nix
Raw Normal View History

{ lib, config, pkgs, ... }:
let
2022-10-12 01:41:32 +03:00
cfg = config.local.git;
in
{
2022-10-12 01:41:32 +03:00
options.local.git = with lib; {
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
2022-10-12 01:41:32 +03:00
config = {
home.packages = lib.mkIf cfg.git-crypt.enable [ pkgs.git-crypt ];
2022-09-01 22:04:00 +03:00
programs.git = {
enable = true;
2022-10-12 01:41:32 +03:00
inherit (cfg) userName userEmail;
signing = lib.mkIf (cfg.gpgKey != null) {
2022-06-01 16:48:29 +03:00
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";
2022-10-12 01:41:32 +03:00
lo = "log --pretty=oneline";
};
};
};
}