feat(git): move custom config out of git module

This commit is contained in:
Felix Schröter 2020-08-15 03:18:48 +02:00
parent 134d6a3556
commit 522d18fea0
No known key found for this signature in database
GPG key ID: 910ACB9F6BD26F58
4 changed files with 29 additions and 26 deletions

View file

@ -36,7 +36,7 @@ with pkgs;
programs.gpg.enable = true;
programs.git.custom = {
programs.git = {
defaultProfile = "work";
};

View file

@ -40,7 +40,7 @@
programs.gpg.enable = true;
programs.git.custom = {
programs.git = {
defaultProfile = "private";
};

View file

@ -7,7 +7,8 @@ in
./modules/git.nix
];
programs.git.custom = {
programs.git = {
enable = true;
profiles = {
private = {
name = "Felix Tenley";
@ -23,5 +24,28 @@ in
};
};
defaultProfile = "private";
ignores = [".direnv"];
signing = {
signByDefault = true;
};
extraConfig = {
init = {
defaultBranch = "main";
};
pull = {
rebase = true;
};
rebase = {
autoStash = true;
autoSquash = true;
abbreviateCommands = true;
missingCommitsCheck = "warn";
};
};
aliases = {
mr = "!sh -c 'git fetch $1 merge-requests/$2/head:mr-$1-$2 && git checkout mr-$1-$2' -";
pr = "!sh -c 'git fetch $1 refs/pull/$2/head:pr/$1 && git checkout pr/$2'";
};
};
}

View file

@ -2,10 +2,10 @@
with lib;
let
cfg = config.programs.git.custom;
cfg = config.programs.git;
in
{
options.programs.git.custom = {
options.programs.git = {
profiles = mkOption {
type = types.attrsOf (types.submodule ({ name, config, ... }: {
options = {
@ -33,31 +33,10 @@ in
profiles = cfg.profiles;
in {
programs.git = {
enable = true;
userName = profiles."${cfg.defaultProfile}".name;
userEmail = profiles."${cfg.defaultProfile}".email;
ignores = [".direnv"];
signing = {
key = profiles."${cfg.defaultProfile}".signingKey;
signByDefault = true;
};
extraConfig = {
init = {
defaultBranch = "main";
};
pull = {
rebase = true;
};
rebase = {
autoStash = true;
autoSquash = true;
abbreviateCommands = true;
missingCommitsCheck = "warn";
};
};
aliases = {
mr = "!sh -c 'git fetch $1 merge-requests/$2/head:mr-$1-$2 && git checkout mr-$1-$2' -";
pr = "!sh -c 'git fetch $1 refs/pull/$2/head:pr/$1 && git checkout pr/$2'";
};
includes = flatten (mapAttrsToList (name: profile: map (dir: {
condition = "gitdir:${dir}";