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