Something went wrong. Try again.
Personal Nix setup
Something went wrong. Try again.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220{ lib, config, pkgs, ... }:
with lib;let cfg = config.modules.git; claude = config.modules.development.claude; home = config.home.homeDirectory;
excludesFile = pkgs.writeTextFile { name = ".gitignore"; text = '' # macOS: General .DS_Store .AppleDouble .LSOverride ._*
# macOS: Files that might appear in the root of a volume .DocumentRevisions-V100 .fseventsd .Spotlight-V100 .TemporaryItems .Trashes .VolumeIcon.icns .com.apple.timemachine.donotpresent
# Xcode xcuserdata/
# Linux: hidden files *~ .fuse_hidden* .directory .Trash-* .nfs*
# direnv + nix devshell artifacts (no-op when already tracked) .envrc .envrc.local /.direnv/ /.devshell/ '' + (optionalString claude.enable '' .claude/ ''); };
userType = types.submodule { options = { name = mkOption { type = types.str; example = "Sample Name"; }; email = mkOption { type = types.str; example = "sample@name.com"; }; }; };in { options.modules.git = { enable = mkOption { default = true; description = "Git Configuration"; type = types.bool; };
user = mkOption { default = { name = "Phil Pluckthun"; email = "phil@kitten.sh"; }; description = "Git user information"; type = userType; };
signingKey = mkOption { description = "Git Signing key"; type = types.nullOr types.str; }; };
config = mkIf cfg.enable { home.packages = with pkgs; [ git-crypt ];
programs.git = { enable = true;
signing = mkIf (cfg.signingKey != null) { signByDefault = true; key = cfg.signingKey; };
ignores = [ ".DS_Store" "*.sw[nop]" "*.undodir" ".env" "*.orig" ];
lfs = { enable = true; };
settings = let remoteConfig = { partialclonefilter = "blob:none"; tagOpt = "--no-tags"; promisor = true; }; in { user = cfg.user;
alias = { s = "status -s"; last = "log -1"; lol = "log --pretty=longline --decorate --date=relative"; lrel = "log --pretty=longline --pretty=longline --graph --decorate --date=relative --boundary remotes/origin/HEAD...HEAD"; lloc = "log --pretty=longline --graph --decorate --date=relative --boundary ^remotes/origin/HEAD HEAD"; recommit = "commit -a --amend --no-edit"; pushf = "push --force-with-lease"; glog = "log --pretty=longline --decorate --all --graph --date=relative"; base = "!f() { git cherry remotes/origin/HEAD HEAD | awk '/^\\+/ {print $2;exit}'; }; f"; journal = "!f() { git commit -a -m \"$(date +'%Y-%m-%d %H:%M:%S')\"; }; f"; get = "!f() { git clone \"git@github.com:$1.git\" \"$HOME/git/$1\" --no-single-branch --shallow-since=\"1 year ago\"; }; f"; pr = "!f() { git fetch origin \"+refs/pull/$1/head:refs/pull/origin/$1\" && git switch --detach \"refs/pull/origin/$1\"; }; f"; normalize-remotes = "!f() { for r in $(git remote); do git config remote.\"$r\".partialclonefilter blob:none && git config remote.\"$r\".promisor true && echo \"normalized $r\"; done; }; f"; };
commit.gpgSign = true; tag.gpgSign = true; push.gpgSign = "if-asked";
column.ui = "auto"; color.ui = "auto"; init.defaultBranch = "main"; help.autocorrect = "prompt";
branch.sort = "-committerdate"; tag.sort = "-version:refname"; commit.verbose = true;
status = { showUntrackedFiles = "all"; submoduleSummary = true; };
diff = { tool = "vimdiff"; submodule = "log"; algorithm = "histogram"; colorMoved = "plain"; colorMovedWS = "allow-indentation-change"; mnemonicPrefix = true; compactionHeuristic = true; rename = true; };
push = { default = "simple"; recurseSubmodules = "on-demand"; autoSetupRemote = true; atomic = true; };
rebase = { autoSquash = true; autoStash = true; updateRefs = true; missingCommitsCheck = "error"; };
merge = { ff = "only"; tool = "vimdiff"; keepbackup = false; };
fetch = { prune = true; all = true; recurseSubmodules = "on-demand"; };
rerere = { enabled = true; autoupdate = true; };
core = { autocrlf = false; excludesfile = toString excludesFile; fsmonitor = true; untrackedCache = true; };
pull.rebase = true; difftool.prompt = false; mergetool.prompt = true; transfer.fsckobjects = true; fetch.fsckobjects = true; submodule.recurse = true;
receive = { denyNonFastForwards = false; shallowUpdate = true; fsckObjects = true; autogc = true; };
"mergetool \"vimdiff\"".cmd = "nvim -d $LOCAL $REMOTE $MERGED -c '$wincmd w' -c 'wincmd J'"; pretty.longline = "tformat:%C(yellow)%h %Cred%D %Creset%<(50,mtrunc)%s %Cblue(%cd, %al)";
"remote \"origin\"" = remoteConfig; }; }; };}