diff options
author | Benedikt Peetz <benedikt.peetz@b-peetz.de> | 2024-10-24 18:21:22 +0200 |
---|---|---|
committer | Benedikt Peetz <benedikt.peetz@b-peetz.de> | 2024-10-24 18:21:22 +0200 |
commit | 7adbf27b250833d5fc3751d4d348037b24e30442 (patch) | |
tree | 25e54bb63acbd280c2d8f327f554ded8bf4e78cb /modules | |
parent | feat(modules/unison): Auto-ignore all symlinks made with `home.file` (diff) | |
download | nixos-config-7adbf27b250833d5fc3751d4d348037b24e30442.tar.gz nixos-config-7adbf27b250833d5fc3751d4d348037b24e30442.zip |
refactor(modules/git): Migrate and parameterize
Diffstat (limited to 'modules')
-rw-r--r-- | modules/by-name/gi/git/aliases.nix (renamed from modules/home.legacy/conf/git/aliases.nix) | 4 | ||||
-rw-r--r-- | modules/by-name/gi/git/git_ignore.git (renamed from modules/home.legacy/conf/git/git_ignore.git) | 0 | ||||
-rw-r--r-- | modules/by-name/gi/git/git_template.git (renamed from modules/home.legacy/conf/git/git_template.git) | 0 | ||||
-rw-r--r-- | modules/by-name/gi/git/module.nix | 114 | ||||
-rw-r--r-- | modules/home.legacy/conf/default.nix | 1 | ||||
-rw-r--r-- | modules/home.legacy/conf/git/default.nix | 96 |
6 files changed, 116 insertions, 99 deletions
diff --git a/modules/home.legacy/conf/git/aliases.nix b/modules/by-name/gi/git/aliases.nix index 15bf613d..96456bea 100644 --- a/modules/home.legacy/conf/git/aliases.nix +++ b/modules/by-name/gi/git/aliases.nix @@ -1,6 +1,6 @@ { lib, - config, + defaultBranchName, }: { cmr = "commit --file .git/COMMIT_EDITMSG --edit --verbose"; @@ -76,7 +76,7 @@ day = "!git log --stat --since '1 day ago' --author $(git config user.email)"; - unpush = "push --force-with-lease origin HEAD~1:${config.programs.git.extraConfig.init.defaultBranch}"; + unpush = "push --force-with-lease origin HEAD~1:${defaultBranchName}"; wip = "!git add . && git commit --amend && git push --force-with-lease"; } diff --git a/modules/home.legacy/conf/git/git_ignore.git b/modules/by-name/gi/git/git_ignore.git index 8f29815e..8f29815e 100644 --- a/modules/home.legacy/conf/git/git_ignore.git +++ b/modules/by-name/gi/git/git_ignore.git diff --git a/modules/home.legacy/conf/git/git_template.git b/modules/by-name/gi/git/git_template.git index 6af39119..6af39119 100644 --- a/modules/home.legacy/conf/git/git_template.git +++ b/modules/by-name/gi/git/git_template.git diff --git a/modules/by-name/gi/git/module.nix b/modules/by-name/gi/git/module.nix new file mode 100644 index 00000000..8e413e8a --- /dev/null +++ b/modules/by-name/gi/git/module.nix @@ -0,0 +1,114 @@ +{ + lib, + config, + ... +}: let + cfg = config.soispha.programs.git; + + gitIgnoreFile = ./git_ignore.git; + gitTemplateFile = ./git_template.git; +in { + options.soispha.programs.git = { + enable = lib.mkEnableOption "an opinionated git config"; + defaultBranchName = lib.mkOption { + type = lib.types.str; + description = "The Name of the default branch."; + default = "prime"; + }; + }; + + config = lib.mkIf cfg.enable { + home-manager.users.soispha = { + programs.git = { + enable = true; + #package = pkgs.gitAndTools.gitFull; # TODO: for git send-email support + aliases = import ./aliases.nix { + inherit lib; + inherit (cfg) defaultBranchName; + }; + extraConfig = { + core = { + excludesFile = "${gitIgnoreFile}"; + }; + rebase = { + autoStash = true; + autoSquash = true; + }; + init = { + defaultBranch = cfg.defaultBranchName; + }; + user = { + name = "Benedikt Peetz"; + email = "benedikt.peetz@b-peetz.de"; + # signingKey = "[is down below]"; + }; + help = { + autocorrect = 5; + }; + push = { + gpgSign = "if-asked"; + }; + commit = { + template = "${gitTemplateFile}"; + }; + diff = { + colorMoved = "default"; + # Usually leads to better results + algorithm = "patience"; + bin = { + textconv = "hexdump -v -C"; + }; + }; + # Makes it a bit more readable + blame = { + coloring = "repeatedLines"; + markIgnoredLines = true; + markUnblamables = true; + }; + merge = { + conflictstyle = "zdiff3"; + }; + url = { + "git@codeberg.org:" = { + insteadOf = "@cb:"; + }; + "https://codeberg.org/" = { + insteadOf = "cb://"; + }; + + "git@github.com:" = { + insteadOf = "@gh:"; + }; + "https://github.com/" = { + insteadOf = "gh://"; + }; + + "git@gitlab.com:" = { + insteadOf = "@gl:"; + }; + "https://gitlab.com/" = { + insteadOf = "gl://"; + }; + }; + }; + delta = { + enable = true; + options = { + decorations = { + commit-decoration-style = "bold yellow box ul"; + file-decoration-style = "none"; + file-style = "bold yellow ul"; + }; + keep-plus-minus-markers = true; + features = "decorations"; + whitespace-error-style = "22 reverse"; + }; + }; + signing = { + key = "8321ED3A8DB999A51F3BF80FF2682914EA42DE26"; + signByDefault = true; + }; + }; + }; + }; +} diff --git a/modules/home.legacy/conf/default.nix b/modules/home.legacy/conf/default.nix index 161c04a1..39ae1cd3 100644 --- a/modules/home.legacy/conf/default.nix +++ b/modules/home.legacy/conf/default.nix @@ -7,7 +7,6 @@ ./direnv ./firefox ./gammastep - ./git ./gpg ./gtk ./himalaya diff --git a/modules/home.legacy/conf/git/default.nix b/modules/home.legacy/conf/git/default.nix deleted file mode 100644 index 6680c598..00000000 --- a/modules/home.legacy/conf/git/default.nix +++ /dev/null @@ -1,96 +0,0 @@ -{ - lib, - config, - ... -}: let - gitIgnoreFile = ./git_ignore.git; - gitTemplateFile = ./git_template.git; -in { - programs.git = { - enable = true; - #package = pkgs.gitAndTools.gitFull; # TODO: for git send-email support - aliases = import ./aliases.nix {inherit lib config;}; - extraConfig = { - core = { - excludesFile = "${gitIgnoreFile}"; - }; - rebase = { - autoStash = true; - autoSquash = true; - }; - init = { - defaultBranch = "prime"; - }; - user = { - name = "Benedikt Peetz"; - email = "benedikt.peetz@b-peetz.de"; - # signingKey = "[is down below]"; - }; - help = { - autocorrect = 5; - }; - push = { - gpgSign = "if-asked"; - }; - commit = { - template = "${gitTemplateFile}"; - }; - diff = { - colorMoved = "default"; - # Usually leads to better results - algorithm = "patience"; - bin = { - textconv = "hexdump -v -C"; - }; - }; - # Makes it a bit more readable - blame = { - coloring = "repeatedLines"; - markIgnoredLines = true; - markUnblamables = true; - }; - merge = { - conflictstyle = "zdiff3"; - }; - url = { - "git@codeberg.org:" = { - insteadOf = "@cb:"; - }; - "https://codeberg.org/" = { - insteadOf = "cb://"; - }; - - "git@github.com:" = { - insteadOf = "@gh:"; - }; - "https://github.com/" = { - insteadOf = "gh://"; - }; - - "git@gitlab.com:" = { - insteadOf = "@gl:"; - }; - "https://gitlab.com/" = { - insteadOf = "gl://"; - }; - }; - }; - delta = { - enable = true; - options = { - decorations = { - commit-decoration-style = "bold yellow box ul"; - file-decoration-style = "none"; - file-style = "bold yellow ul"; - }; - keep-plus-minus-markers = true; - features = "decorations"; - whitespace-error-style = "22 reverse"; - }; - }; - signing = { - key = "8321ED3A8DB999A51F3BF80FF2682914EA42DE26"; - signByDefault = true; - }; - }; -} |