Samuel Shuert | 02ffd1e | 2024-02-13 21:37:15 -0500 | [diff] [blame] | 1 | { |
| 2 | config, |
| 3 | lib, |
| 4 | pkgs, |
| 5 | ... |
| 6 | }: |
| 7 | { |
| 8 | options.chimera.git = { |
| 9 | gitReview.enable = lib.mkEnableOption "Enable git review"; |
| 10 | delta.enable = lib.mkEnableOption "Enable delta, an alternative pager for git diffs that highlights syntax"; |
Skyler Grey | ec50d24 | 2024-02-15 23:09:46 +0000 | [diff] [blame] | 11 | stgit.enable = lib.mkEnableOption "Install StGit, a tool that makes working with stacked patches easier"; |
Samuel Shuert | d1f727b | 2024-02-20 22:43:10 +0000 | [diff] [blame] | 12 | gitCrypt.enable = lib.mkEnableOption "Install git-crypt, a transparent file encryption tool for git repositories"; |
Samuel Shuert | 02ffd1e | 2024-02-13 21:37:15 -0500 | [diff] [blame] | 13 | auth = { |
| 14 | clicksUsername = lib.mkOption { |
| 15 | type = lib.types.str; |
| 16 | description = "Username for Clicks Gerrit"; |
| 17 | }; |
| 18 | }; |
Skyler Grey | 695fa63 | 2024-02-17 22:45:41 +0000 | [diff] [blame] | 19 | gpg = { |
| 20 | enable = lib.mkEnableOption "Enable signing with gpg"; |
| 21 | commit = lib.mkOption { |
| 22 | type = lib.types.bool; |
| 23 | description = "Enable gpg signing for commits by default"; |
| 24 | default = true; |
| 25 | }; |
| 26 | push = lib.mkOption { |
| 27 | type = lib.types.bool; |
| 28 | description = "Enable gpg signing for pushes by when asked by the server"; |
| 29 | default = true; |
| 30 | }; |
| 31 | }; |
Samuel Shuert | 02ffd1e | 2024-02-13 21:37:15 -0500 | [diff] [blame] | 32 | }; |
| 33 | |
| 34 | config = { |
Skyler Grey | 695fa63 | 2024-02-17 22:45:41 +0000 | [diff] [blame] | 35 | chimera.gpg.enable = lib.mkIf config.chimera.git.gpg.enable true; |
Samuel Shuert | 02ffd1e | 2024-02-13 21:37:15 -0500 | [diff] [blame] | 36 | |
Skyler Grey | d5457a2 | 2024-02-15 23:02:32 +0000 | [diff] [blame] | 37 | home.packages = |
Skyler Grey | ec50d24 | 2024-02-15 23:09:46 +0000 | [diff] [blame] | 38 | (if config.chimera.git.gitReview.enable then [ pkgs.git-review ] else [ ]) |
Samuel Shuert | d1f727b | 2024-02-20 22:43:10 +0000 | [diff] [blame] | 39 | ++ (if config.chimera.git.stgit.enable then [ pkgs.stgit ] else [ ]) |
| 40 | ++ (if config.chimera.git.gitCrypt.enable then [ pkgs.git-crypt ] else [ ]); |
Samuel Shuert | 02ffd1e | 2024-02-13 21:37:15 -0500 | [diff] [blame] | 41 | |
| 42 | programs.zsh.shellAliases = |
| 43 | if config.chimera.git.gitReview.enable then { "gr!" = "git review"; } else { }; |
| 44 | |
| 45 | programs.bash.shellAliases = |
| 46 | if config.chimera.git.gitReview.enable then { "gr!" = "git review"; } else { }; |
| 47 | |
| 48 | programs.git = { |
| 49 | enable = true; |
| 50 | |
Skyler Grey | bb7586a | 2024-02-15 19:15:04 +0000 | [diff] [blame] | 51 | delta = { |
Skyler Grey | ec50d24 | 2024-02-15 23:09:46 +0000 | [diff] [blame] | 52 | enable = config.chimera.git.delta.enable; |
| 53 | options.light = lib.mkIf config.chimera.theme.catppuccin.enable ( |
| 54 | config.chimera.theme.catppuccin.style == "Latte" |
| 55 | ); |
| 56 | }; |
Samuel Shuert | 02ffd1e | 2024-02-13 21:37:15 -0500 | [diff] [blame] | 57 | |
| 58 | extraConfig = { |
| 59 | init.defaultBranch = "main"; |
| 60 | advice.skippedcherrypicks = false; |
Skyler Grey | 695fa63 | 2024-02-17 22:45:41 +0000 | [diff] [blame] | 61 | commit.gpgsign = lib.mkIf config.chimera.git.gpg.enable config.chimera.git.gpg.commit; |
Samuel Shuert | 02ffd1e | 2024-02-13 21:37:15 -0500 | [diff] [blame] | 62 | credential.helper = "cache"; |
| 63 | core = { |
| 64 | repositoryformatversion = 0; |
| 65 | filemode = true; |
| 66 | bare = false; |
| 67 | logallrefupdates = true; |
| 68 | fsmonitor = true; |
| 69 | autocrlf = "input"; |
| 70 | splitIndex = true; |
| 71 | untrackedCache = true; |
| 72 | }; |
| 73 | pull = { |
| 74 | rebase = "merges"; # TODO: from git docs, should we provide an option for this?: NOTE: this is a possibly dangerous operation; do not use it unless you understand the implications (see git-rebase[1] for details). |
| 75 | }; |
| 76 | push = { |
| 77 | autoSetupRemote = true; |
Skyler Grey | 695fa63 | 2024-02-17 22:45:41 +0000 | [diff] [blame] | 78 | gpgSign = lib.mkIf config.chimera.git.gpg.enable (if config.chimera.git.gpg.push then "if-asked" else false); |
Samuel Shuert | 02ffd1e | 2024-02-13 21:37:15 -0500 | [diff] [blame] | 79 | }; |
| 80 | url = { |
| 81 | "ssh://git@github.com/".pushInsteadOf = "https://github.com/"; |
Skyler Grey | bb7586a | 2024-02-15 19:15:04 +0000 | [diff] [blame] | 82 | "ssh://${config.chimera.git.auth.clicksUsername}@ssh.clicks.codes:29418/".pushInsteadOf = "https://git.clicks.codes/"; |
Samuel Shuert | 02ffd1e | 2024-02-13 21:37:15 -0500 | [diff] [blame] | 83 | }; |
| 84 | merge.conflictstyle = "diff3"; |
| 85 | trailer.ifexists = "addIfDifferent"; |
| 86 | }; |
| 87 | }; |
| 88 | }; |
| 89 | } |
| 90 | |
| 91 | /* [alias] |
| 92 | recommit = "!git commit --verbose -eF $(git rev-parse --git-dir)/COMMIT_EDITMSG" |
| 93 | stash-working = "!f() { \ |
| 94 | git commit --quiet --no-verify -m \"temp for stash-working\" && \ |
| 95 | git stash push \"$@\" && \ |
| 96 | git reset --quiet --soft HEAD~1; \ |
| 97 | }; f" |
| 98 | checkout-soft = "!f() { \ |
| 99 | hash=$(git hash); \ |
| 100 | git checkout \"$@\"; \ |
| 101 | git reset --soft $hash; \ |
| 102 | }; f" # basically the opposite of a soft reset: change all the files but do not change the HEAD reference |
| 103 | graph = "log --graph --oneline --decorate" |
| 104 | fmt = "clang-format" |
| 105 | hash = "rev-parse HEAD" |
| 106 | fmt-last = "!f() { \ |
| 107 | hash=$(git hash); \ |
| 108 | git reset --soft HEAD^ && \ |
| 109 | git fmt; \ |
| 110 | git reset --soft $hash; \ |
| 111 | }; f" |
| 112 | personal = "config user.email skyler3665@gmail.com" |
| 113 | clicks = "config user.email minion@clicks.codes" |
| 114 | collabora = "config user.email skyler.grey@collabora.com" |
| 115 | # review = "!git-review -T": cannot be set here, set in .zshrc instead |
| 116 | |
| 117 | [credential] |
| 118 | helper = "store" |
| 119 | |
| 120 | /* |
| 121 | [user] |
| 122 | name = "Skyler Grey" |
| 123 | signingkey = "7C868112B5390C5C" |
| 124 | useConfigOnly = true # avoid auto-setting user.email by hostname |
| 125 | |
| 126 | [alias] |
| 127 | recommit = "!git commit --verbose -eF $(git rev-parse --git-dir)/COMMIT_EDITMSG" |
| 128 | stash-working = "!f() { \ |
| 129 | git commit --quiet --no-verify -m \"temp for stash-working\" && \ |
| 130 | git stash push \"$@\" && \ |
| 131 | git reset --quiet --soft HEAD~1; \ |
| 132 | }; f" |
| 133 | checkout-soft = "!f() { \ |
| 134 | hash=$(git hash); \ |
| 135 | git checkout \"$@\"; \ |
| 136 | git reset --soft $hash; \ |
| 137 | }; f" # basically the opposite of a soft reset: change all the files but do not change the HEAD reference |
| 138 | graph = "log --graph --oneline --decorate" |
| 139 | fmt = "clang-format" |
| 140 | hash = "rev-parse HEAD" |
| 141 | fmt-last = "!f() { \ |
| 142 | hash=$(git hash); \ |
| 143 | git reset --soft HEAD^ && \ |
| 144 | git fmt; \ |
| 145 | git reset --soft $hash; \ |
| 146 | }; f" |
| 147 | personal = "config user.email skyler3665@gmail.com" |
| 148 | clicks = "config user.email minion@clicks.codes" |
| 149 | collabora = "config user.email skyler.grey@collabora.com" |
| 150 | # review = "!git-review -T": cannot be set here, set in .zshrc instead |
| 151 | |
| 152 | [init] |
| 153 | defaultBranch = "main" |
| 154 | |
| 155 | [color] |
| 156 | ui = "auto" |
| 157 | |
| 158 | [core] |
| 159 | autocrlf = "input" |
| 160 | splitIndex = true |
| 161 | untrackedCache = true |
| 162 | fsmonitor = true |
| 163 | pager = "delta" |
| 164 | |
| 165 | [pull] |
| 166 | rebase = merges |
| 167 | |
| 168 | [push] |
| 169 | autoSetupRemote = true |
| 170 | useForceIfIncludes = true |
| 171 | gpgSign = if-asked |
| 172 | |
| 173 | [credential] |
| 174 | helper = "store" |
| 175 | |
| 176 | [commit] |
| 177 | gpgsign = true |
| 178 | |
| 179 | [url "ssh://git@github.com/"] |
| 180 | pushInsteadOf = "https://github.com/" |
| 181 | |
| 182 | [interactive] |
| 183 | diffFilter = "delta --color-only" |
| 184 | |
| 185 | [delta] |
| 186 | navigate = true |
| 187 | light = false |
| 188 | line-numbers = true |
| 189 | features = "my-dark-theme zebra-dark" |
| 190 | |
| 191 | [merge] |
| 192 | conflictstyle = "diff3" |
| 193 | |
| 194 | [diff] |
| 195 | colorMoved = "default" |
| 196 | |
| 197 | [trailer] |
| 198 | ifexists = "addIfDifferent" |
| 199 | */ |