git.nix (5923B)
1 { config, lib, pkgs, ... }: 2 3 with lib; 4 let 5 ca-bundle_crt = "/etc/ssl/certs/ca-bundle.crt"; 6 redhat_folders = [ 7 "src/github.com/containers" 8 "src/github.com/google" 9 "src/github.com/knative" 10 "src/github.com/kubernetes" 11 "src/github.com/openshift" 12 "src/github.com/openshift-knative" 13 "src/github.com/openshift-pipelines" 14 "src/github.com/operator-framework" 15 "src/github.com/redhat-developer" 16 "src/github.com/tektoncd" 17 "src/gitlab.cee.redhat.com" 18 "src/gitlab.corp.redhat.com" 19 "src/k8s.io" 20 "src/osp" 21 "src/pkg.devel.redhat.com" 22 "src/tektoncd" 23 "src/backstage" 24 "src/knative.dev" 25 "src/knative-sandbox" 26 ]; 27 in 28 { 29 home.packages = with pkgs; [ 30 gist 31 git-lfs 32 # git-review 33 # gitAndTools.hub 34 gitAndTools.gh 35 gitAndTools.git-appraise 36 mr 37 delta 38 difftastic 39 rs-git-fsmonitor 40 ]; 41 programs.git = { 42 enable = true; 43 package = pkgs.git; 44 45 userName = "Vincent Demeester"; 46 userEmail = "vincent@sbr.pm"; 47 48 signing = { 49 key = "6EB699A3"; 50 signByDefault = false; 51 }; 52 53 aliases = { 54 b = "branch --color -v"; 55 br = "branch"; 56 ca = "commit --amend"; 57 ci = "commit --signoff"; 58 co = "checkout"; 59 conflicts = "!git ls-files --unmerged | cut -c51- | sort -u | xargs $EDITOR"; 60 dft = "difftool"; 61 lg = "log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr)%Creset' --abbrev-commit --date=relative"; 62 lga = "log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr)%Creset' --abbrev-commit --date=relative --branches --remotes"; 63 lol = "log --pretty=oneline --abbrev-commit --graph --decorate"; 64 ls-ignored = "ls-files --exclude-standard --ignored --others"; 65 resolve = "!git ls-files --unmerged | cut -c51- | sort -u | xargs git add"; 66 st = "status"; 67 su = "submodule update --init --recursive"; 68 unstage = "reset HEAD"; 69 w = "status -sb"; 70 wdiff = "diff --color-words"; 71 }; 72 attributes = [ 73 "*.org diff=org" 74 ]; 75 extraConfig = { 76 core = { 77 fsmonitor = "${pkgs.rs-git-fsmonitor}/bin/rs-git-fsmonitor"; 78 pager = "${pkgs.delta}/bin/delta"; 79 abbrev = 12; 80 # pager = "${pkgs.delta}/bin/delta --syntax-theme GitHub"; 81 # editor = "${pkgs.emacs}/bin/emacsclient -t"; 82 }; 83 init = { 84 defaultBranch = "main"; 85 }; 86 color = { 87 status = "auto"; 88 diff = "auto"; 89 branch = "auto"; 90 interactive = "auto"; 91 ui = "auto"; 92 sh = "auto"; 93 }; 94 "color.branch" = { 95 current = "cyan reverse"; 96 local = "cyan"; 97 remote = "green"; 98 }; 99 "color.diff" = { 100 current = "white reverse"; 101 frag = "magenta reverse"; 102 old = "red"; 103 new = "green"; 104 }; 105 "color.status" = { 106 added = "green"; 107 changed = "yellow"; 108 untracked = "red"; 109 }; 110 # Either use this *or* git maintenance 111 # fetch = { 112 # writeCommitGraph = true; 113 # }; 114 diff = { 115 algorithm = "histogram"; 116 colormoved = "default"; 117 colormovedws = "allow-indentation-change"; 118 # external = "difft"; 119 # tool = "difftastic"; 120 }; 121 "diff.org" = { 122 xfuncname = "\"^\\\\*+.*\""; 123 }; 124 difftool = { 125 prompt = false; 126 trustExitCode = true; 127 }; 128 "difftool.difftastic" = { 129 cmd = "difft \"$LOCAL\" \"$REMOTE\""; 130 }; 131 "difftool.kitty" = { 132 cmd = "kitten diff $LOCAL $REMOTE"; 133 }; 134 pager = { 135 difftool = true; 136 }; 137 pretty = { 138 fixes = "Fixes: %h (\"%s\")"; 139 }; 140 forge = { 141 remote = "upstream"; 142 }; 143 rerere = { 144 enabled = true; 145 }; 146 hub = { 147 protocol = true; 148 }; 149 pull = { 150 rebase = true; 151 }; 152 push = { 153 default = "upstream"; 154 recurseSubmodules = "check"; 155 }; 156 rebase = { 157 autosquash = true; 158 }; 159 status = { 160 short = true; 161 branch = true; 162 }; 163 branch = { 164 sort = "-committerdate"; 165 }; 166 advice = { 167 statusHints = false; 168 pushNonFastForward = false; 169 }; 170 http = { 171 sslCAinfo = "${ca-bundle_crt}"; 172 sslverify = true; 173 }; 174 delta = { 175 syntax-theme = "GitHub"; 176 features = "decorations"; 177 }; 178 179 "delta \"decorations\"" = { 180 commit-decoration-style = "blue ol"; 181 commit-style = "raw"; 182 file-style = "omit"; 183 hunk-header-decoration-style = "blue box"; 184 hunk-header-file-style = "red"; 185 hunk-header-line-number-style = "#067a00"; 186 hunk-header-style = "file line-number syntax"; 187 navigate = true; 188 }; 189 190 credential = { 191 "https://github.com" = { 192 helper = "!${pkgs.gh}/bin/gh auth git-credential"; 193 }; 194 "https://gist.github.com" = { 195 helper = "!${pkgs.gh}/bin/gh auth git-credential"; 196 }; 197 }; 198 github.user = "vdemeester"; 199 "filter \"lfs\"" = { 200 clean = "${pkgs.git-lfs}/bin/git-lfs clean -- %f"; 201 smudge = "${pkgs.git-lfs}/bin/git-lfs smudge --skip -- %f"; 202 required = true; 203 }; 204 "url \"git@github.com:\"".insteadOf = "git://github.com/"; 205 }; 206 207 includes = [ ] ++ lists.forEach redhat_folders (x: { 208 path = "${config.xdg.configHome}/git/config.d/redhat.gitconfig"; 209 condition = "gitdir:${config.home.homeDirectory}/${x}/**"; 210 }); 211 ignores = [ 212 "*.elc" 213 "*.vo" 214 "*.aux" 215 "*.v.d" 216 "*.o" 217 "*.a" 218 "*.la" 219 "*.so" 220 "*.dylib" 221 "*.pyc" 222 "*.pyo" 223 ".idea" 224 "*.iml" 225 "*~" 226 "#*#" 227 ".makefile" 228 ".clean" 229 ]; 230 }; 231 xdg.configFile."git/config.d/redhat.gitconfig".source = ./git/redhat.gitconfig; 232 }