From 5755cafa17d392930bdb34137b304bc163610800 Mon Sep 17 00:00:00 2001 From: Stefan Imhoff Date: Mon, 15 Jul 2024 19:00:58 +0200 Subject: [PATCH] feat(nix): migrate git --- .dotbot.conf.yaml | 2 - git/gitconfig | 127 ---------------------------- git/gitignore | 13 --- nix/home/default.nix | 1 + nix/home/git/default.nix | 177 +++++++++++++++++++++++++++++++++++++++ 5 files changed, 178 insertions(+), 142 deletions(-) delete mode 100644 git/gitconfig delete mode 100644 git/gitignore create mode 100644 nix/home/git/default.nix diff --git a/.dotbot.conf.yaml b/.dotbot.conf.yaml index 43f7ecc..17f37d1 100644 --- a/.dotbot.conf.yaml +++ b/.dotbot.conf.yaml @@ -16,8 +16,6 @@ ~/.config/nvim: nvim ~/.config/starship.toml: prompt/starship.toml ~/.config/tmux/tmux-nerd-font-window-name.yml: tmux/tmux-nerd-font-window-name.yml - ~/.gitconfig: git/gitconfig - ~/.gitignore: git/gitignore ~/.gitmux.conf: tmux/gitmux.conf ~/.tmux-cht-command: tmux/tmux-cht-command ~/.tmux-cht-languages: tmux/tmux-cht-languages diff --git a/git/gitconfig b/git/gitconfig deleted file mode 100644 index bd39af5..0000000 --- a/git/gitconfig +++ /dev/null @@ -1,127 +0,0 @@ -[user] - useConfigOnly = true -[include] - path = ~/.gitconfig.local -[help] - autocorrect = 1 -[core] - editor = code --wait - excludesfile = ~/.gitignore - legacyheaders = false - whitespace = trailing-space,space-before-tab - pager = delta -[interactive] - diffFilter = delta --color-only -[add.interactive] - useBuildtin = false -[delta] - navigate = true - light = false - line-numbers = true - side-by-side = true - syntax-theme = Dracula -[alias] - st = status - ci = commit - co = checkout - br = branch - rb = rebase - cp = cherry-pick - dt = difftool - hist = log --color --graph --decorate --abbrev-commit --date=short --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(blue)[%an]%Creset' --abbrev-commit -- - ls = log --pretty=format:"%C(yellow)%h%Cred%d\\ %Creset%s%Cblue\\ [%cn]" --decorate - local-branches = !git branch -vv | cut -c 3- | awk '$3 !~/\\[/ { print $1 }' - stats = shortlog -sn --all --no-merges - today = log --since=00:00:00 --all --no-merges --oneline - prune = fetch --prune - undo = reset --soft HEAD^ - stash-all = stash save --include-untracked - app-status = !git remote update >/dev/null && git --no-pager log origin/production..origin/master --pretty=oneline >&2 | pbcopy - unstage = "reset HEAD --" - merged = "branch --merged" - unmerged = "branch --no-merge" - branches = for-each-ref --sort=-committerdate --format=\"%(color:blue)%(authordate:relative)\t%(color:red)%(authorname)\t%(color:white)%(color:bold)%(refname:short)\" refs/remotes - ignored = "ls-files --others --directory" - # Assume workflow - assume = "update-index --assume-unchanged" - unassume = "update-index --no-assume-unchanged" - assumed = "!git ls-files -v | grep ^h | cut -c 3-" - unassumeall = "!git assumed | xargs git update-index --no-assume-unchanged" - assumeall = "!git st -s | awk {'print $2'} | xargs git assume" - # Rebase workflow - mainbranch = "!git remote show origin | sed -n '/HEAD branch/s/.*: //p'" - synced = "!git pull origin $(git mainbranch) --rebase" - update = "!git pull origin $(git rev-parse --abbrev-ref HEAD) --rebase" - squash = "!git rebase -v -i $(git mainbranch)" - publish = push origin HEAD --force-with-lease - pub = publish - # GitHub - hub = "!gh repo view --web" -[apply] - whitespace = fix -[color] - status = auto - diff = auto - branch = auto - interactive = auto - ui = 1 -[push] - default = upstream - followTags = true - autoSetupRemote = true -[status] - showUntrackedFiles = all -[transfer] - fsckobjects = true -[i18n] - commitencoding = UTF-8 - logoutputencoding = UTF-8 -[repack] - usedeltabaseoffset = true -[branch] - autosetupmerge = true - sort = -authordate -[diff] - tool = Kaleidoscope - algorithm = patience - colorMoved = default -[difftool] - prompt = false -[difftool "Kaleidoscope"] - cmd = ksdiff --partial-changeset --relative-path \"$MERGED\" -- \"$LOCAL\" \"$REMOTE\" -[merge] - conflictstyle = diff3 - tool = Kaleidoscope -[mergetool] - prompt = false - keepBackup = false -[mergetool "Kaleidoscope"] - cmd = ksdiff --merge --output \"$MERGED\" --base \"$BASE\" -- \"$LOCAL\" --snapshot \"$REMOTE\" --snapshot - trustexitcode = true - trustExitCode = true -[mergetool "nvim"] - cmd = nvim -f -c \"Gdiffsplit!\" \"$MERGED\" -[mergetool "code"] - cmd = "code $MERGED" - keepBackup = false - trustexitcode = true -[rebase] - autosquash = true -[rerere] - enabled = 1 -[fetch] - prune = true - fsckobjects = false -[filter "lfs"] - required = true - smudge = git-lfs smudge -- %f - process = git-lfs filter-process - clean = git-lfs clean -- %f -[web] - browser = open -[hub] - host = source.xing.com -[pull] - ff = only -[commit] - gpgsign = true diff --git a/git/gitignore b/git/gitignore deleted file mode 100644 index 6e29b87..0000000 --- a/git/gitignore +++ /dev/null @@ -1,13 +0,0 @@ -*.lnk -*.pyc -*.pyo -*.session -*.sw[nop] -.BridgeSort -.DS_Store -._* -.agignore -.bundle/ -m~ -tags -.worktrees diff --git a/nix/home/default.nix b/nix/home/default.nix index 9645d70..d2d8b53 100644 --- a/nix/home/default.nix +++ b/nix/home/default.nix @@ -13,6 +13,7 @@ in ./ctags ./curl ./editorconfig + ./git ./gnupg ./hammerspoon ./karabiner diff --git a/nix/home/git/default.nix b/nix/home/git/default.nix new file mode 100644 index 0000000..49a8ef0 --- /dev/null +++ b/nix/home/git/default.nix @@ -0,0 +1,177 @@ +{ pkgs, ... }: + +{ + programs.git = { + enable = true; + delta.enable = true; + aliases = { + st = "status"; + ci = "commit"; + co = "checkout"; + br = "branch"; + rb = "rebase"; + cp = "cherry-pick"; + dt = "difftool"; + hist = "log --color --graph --decorate --abbrev-commit --date=short --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(blue)[%an]%Creset' --abbrev-commit --"; + ls = "log --pretty=format:\"%C(yellow)%h%Cred%d\\ %Creset%s%Cblue\\ [%cn]\" --decorate"; + "local-branches" = "!git branch -vv | cut -c 3- | awk '$3 !~/\\[/ { print $1 }'"; + stats = "shortlog -sn --all --no-merges"; + today = "log --since=00:00:00 --all --no-merges --oneline"; + prune = "fetch --prune"; + undo = "reset --soft HEAD^"; + "stash-all" = "stash save --include-untracked"; + "app-status" = "!git remote update >/dev/null && git --no-pager log origin/production..origin/master --pretty=oneline >&2 | pbcopy"; + unstage = "reset HEAD --"; + merged = "branch --merged"; + unmerged = "branch --no-merge"; + branches = "for-each-ref --sort=-committerdate --format=\"%(color:blue)%(authordate:relative)\t%(color:red)%(authorname)\t%(color:white)%(color:bold)%(refname:short)\" refs/remotes"; + ignored = "ls-files --others --directory"; + # Assume workflow + assume = "update-index --assume-unchanged"; + unassume = "update-index --no-assume-unchanged"; + assumed = "!git ls-files -v | grep ^h | cut -c 3-"; + unassumeall = "!git assumed | xargs git update-index --no-assume-unchanged"; + assumeall = "!git st -s | awk {'print $2'} | xargs git assume"; + # Rebase workflow + mainbranch = "!git remote show origin | sed -n '/HEAD branch/s/.*: //p'"; + synced = "!git pull origin $(git mainbranch) --rebase"; + update = "!git pull origin $(git rev-parse --abbrev-ref HEAD) --rebase"; + squash = "!git rebase -v -i $(git mainbranch)"; + publish = "push origin HEAD --force-with-lease"; + pub = "publish"; + # GitHub + hub = "!gh repo view --web"; + }; + ignores = [ + "*.lnk" + "*.pyc" + "*.pyo" + "*.session" + "*.sw[nop]" + ".BridgeSort" + ".DS_Store" + "._*" + ".agignore" + ".bundle/" + "m~" + "tags" + ".worktrees" + ]; + lfs.enable = true; + includes = [ + { path = "~/.gitconfig.local"; } + ]; + extraConfig = { + user = { + useConfigOnly = true; + }; + core = { + editor = "code --wait"; + legacyheaders = false; + }; + help = { + autocorrect = 1; + }; + delta = { + navigate = true; + light = false; + line-numbers = true; + side-by-side = true; + syntax-theme = "Dracula"; + }; + add = { + interactive = { + useBuildtin = true; + }; + }; + apply = { + whitespace = "fix"; + }; + color = { + status = "auto"; + diff = "auto"; + branch = "auto"; + interactive = "auto"; + ui = 1; + }; + commit = { + gpgsign = true; + }; + branch = { + autosetupmerge = true; + sort = "-authordate"; + }; + push = { + default = "upstream"; + followTags = true; + autoSetupRemote = true; + }; + pull = { + ff = "only"; + }; + fetch = { + prune = true; + fsckobjects = false; + }; + rebase = { + autosquash = true; + }; + status = { + showUntrackedFiles = "all"; + }; + diff = { + tool = "Kaleidoscope"; + algorithm = "patience"; + colorMoved = "default"; + }; + difftool = { + prompt = false; + Kaleidoscope.cmd = "ksdiff --partial-changeset --relative-path \"$MERGED\" -- \"$LOCAL\" \"$REMOTE\""; + }; + merge = { + conflictstyle = "diff3"; + tool = "Kaleidoscope"; + }; + mergetool = { + prompt = false; + keepBackup = false; + Kaleidoscope = { + cmd = "ksdiff --merge --output \"$MERGED\" --base \"$BASE\" -- \"$LOCAL\" --snapshot \"$REMOTE\" --snapshot"; + trustexitcode = true; + trustExitCode = true; + }; + nvim.cmd = "nvim -f -c \"Gdiffsplit!\" \"$MERGED\""; + code = { + cmd = "\"code $MERGED\""; + keepBackup = false; + trustexitcode = true; + }; + }; + rerere.enabled = true; + transfer = { + fsckObjects = true; + }; + i18n = { + commitencoding = "UTF-8"; + logoutputencoding = "UTF-8"; + }; + repack = { + usedeltabaseoffset = true; + }; + "filter \"lfs\"" = { + required = true; + smudge = "git-lfs smudge -- %f"; + process = "git-lfs filter-process"; + clean = "git-lfs clean -- %f"; + }; + web.browser = "open"; + hub.host = "source.xing.com"; + }; + }; + + home.packages = with pkgs; [ + git + delta + gh + ]; +}