From b2358a096c2aaa17c37634d4baf0a682023585a4 Mon Sep 17 00:00:00 2001 From: Christoph Urlacher Date: Tue, 8 Jul 2025 22:47:10 +0200 Subject: [PATCH] Modules: Add git module --- home/modules/default.nix | 1 + home/modules/git/default.nix | 116 +++++++++++++++++++++++++++++++++++ home/modules/git/options.nix | 25 ++++++++ 3 files changed, 142 insertions(+) create mode 100644 home/modules/git/default.nix create mode 100644 home/modules/git/options.nix diff --git a/home/modules/default.nix b/home/modules/default.nix index 1bfe2a14..3a9a7baf 100644 --- a/home/modules/default.nix +++ b/home/modules/default.nix @@ -8,6 +8,7 @@ ./docs ./firefox ./fish + ./git ./hyprland ./hyprpanel ./kitty diff --git a/home/modules/git/default.nix b/home/modules/git/default.nix new file mode 100644 index 00000000..66aea33c --- /dev/null +++ b/home/modules/git/default.nix @@ -0,0 +1,116 @@ +{ + config, + nixosConfig, + lib, + mylib, + pkgs, + ... +}: let + inherit (config.modules) git; +in { + options.modules.git = import ./options.nix {inherit lib mylib;}; + + config = lib.mkIf git.enable { + home.programs.git = { + enable = true; + + # userEmail = "christoph.urlacher@protonmail.com"; + # userName = "Christoph Urlacher"; + + userEmail = git.userEmail; + userName = git.userName; + + signing = { + signByDefault = git.signCommits; + format = "ssh"; + key = "~/.ssh/id_ed25519.pub"; + }; + + lfs.enable = true; + diff-so-fancy = { + enable = true; + changeHunkIndicators = true; + markEmptyLines = false; + stripLeadingSymbols = true; + }; + + extraConfig = { + core = { + compression = 9; + # whitespace = "error"; + preloadindex = true; + }; + + init = { + defaultBranch = "main"; + }; + + gpg = { + ssh = { + allowedSignersFile = "~/.ssh/allowed_signers"; + }; + }; + + status = { + branch = true; + showStash = true; + showUntrackedFiles = "all"; + }; + + pull = { + default = "current"; + rebase = true; + }; + + push = { + autoSetupRemote = true; + default = "current"; + followTags = true; + }; + + rebase = { + autoStash = true; + missingCommitsCheck = "warn"; + }; + + diff = { + context = 3; + renames = "copies"; + interHunkContext = 10; + }; + + interactive = { + diffFilter = "${pkgs.diff-so-fancy}/bin/diff-so-fancy --patch"; + singlekey = true; + }; + + log = { + abbrevCommit = true; + graphColors = "blue,yellow,cyan,magenta,green,red"; + }; + + branch = { + sort = "-committerdate"; + }; + + tag = { + sort = "-taggerdate"; + }; + + pager = { + branch = false; + tag = false; + }; + + url = { + "ssh://git@gitea.local.chriphost.de:222/christoph/" = { + insteadOf = "gitea:"; + }; + "git@github.com:" = { + insteadOf = "github:"; + }; + }; + }; + }; + }; +} diff --git a/home/modules/git/options.nix b/home/modules/git/options.nix new file mode 100644 index 00000000..4f6d8c40 --- /dev/null +++ b/home/modules/git/options.nix @@ -0,0 +1,25 @@ +{ + lib, + mylib, + ... +}: { + enable = lib.mkEnableOption "Enable git"; + + userName = lib.mkOption { + type = lib.types.str; + description = "The user's name"; + example = '' + "John Doe" + ''; + }; + + userEmail = lib.mkOption { + type = lib.types.str; + description = "The user's email address"; + example = '' + "john@doe.com" + ''; + }; + + signCommits = lib.mkEnableOption "Enable commit signing"; +}