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; |
Samuel Shuert | 659b564 | 2024-02-23 20:47:43 +0000 | [diff] [blame] | 64 | # 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). |
Samuel Shuert | 02ffd1e | 2024-02-13 21:37:15 -0500 | [diff] [blame] | 65 | }; |
| 66 | push = { |
| 67 | autoSetupRemote = true; |
Samuel Shuert | 659b564 | 2024-02-23 20:47:43 +0000 | [diff] [blame] | 68 | gpgSign = lib.mkIf config.chimera.git.gpg.enable ( |
| 69 | if config.chimera.git.gpg.push then "if-asked" else false |
| 70 | ); |
Samuel Shuert | 02ffd1e | 2024-02-13 21:37:15 -0500 | [diff] [blame] | 71 | }; |
Skyler Grey | 9e24d9b | 2024-03-01 21:12:34 +0000 | [diff] [blame] | 72 | pull.rebase = "merges"; |
Samuel Shuert | 02ffd1e | 2024-02-13 21:37:15 -0500 | [diff] [blame] | 73 | url = { |
| 74 | "ssh://git@github.com/".pushInsteadOf = "https://github.com/"; |
Skyler Grey | bb7586a | 2024-02-15 19:15:04 +0000 | [diff] [blame] | 75 | "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] | 76 | }; |
| 77 | merge.conflictstyle = "diff3"; |
| 78 | trailer.ifexists = "addIfDifferent"; |
| 79 | }; |
| 80 | }; |
| 81 | }; |
| 82 | } |
| 83 | |
| 84 | /* [alias] |
| 85 | recommit = "!git commit --verbose -eF $(git rev-parse --git-dir)/COMMIT_EDITMSG" |
| 86 | stash-working = "!f() { \ |
| 87 | git commit --quiet --no-verify -m \"temp for stash-working\" && \ |
| 88 | git stash push \"$@\" && \ |
| 89 | git reset --quiet --soft HEAD~1; \ |
| 90 | }; f" |
| 91 | checkout-soft = "!f() { \ |
| 92 | hash=$(git hash); \ |
| 93 | git checkout \"$@\"; \ |
| 94 | git reset --soft $hash; \ |
| 95 | }; f" # basically the opposite of a soft reset: change all the files but do not change the HEAD reference |
| 96 | graph = "log --graph --oneline --decorate" |
| 97 | fmt = "clang-format" |
| 98 | hash = "rev-parse HEAD" |
| 99 | fmt-last = "!f() { \ |
| 100 | hash=$(git hash); \ |
| 101 | git reset --soft HEAD^ && \ |
| 102 | git fmt; \ |
| 103 | git reset --soft $hash; \ |
| 104 | }; f" |
| 105 | personal = "config user.email skyler3665@gmail.com" |
| 106 | clicks = "config user.email minion@clicks.codes" |
| 107 | collabora = "config user.email skyler.grey@collabora.com" |
| 108 | # review = "!git-review -T": cannot be set here, set in .zshrc instead |
| 109 | |
| 110 | [credential] |
| 111 | helper = "store" |
| 112 | |
| 113 | /* |
| 114 | [user] |
| 115 | name = "Skyler Grey" |
| 116 | signingkey = "7C868112B5390C5C" |
| 117 | useConfigOnly = true # avoid auto-setting user.email by hostname |
| 118 | |
| 119 | [alias] |
| 120 | recommit = "!git commit --verbose -eF $(git rev-parse --git-dir)/COMMIT_EDITMSG" |
| 121 | stash-working = "!f() { \ |
| 122 | git commit --quiet --no-verify -m \"temp for stash-working\" && \ |
| 123 | git stash push \"$@\" && \ |
| 124 | git reset --quiet --soft HEAD~1; \ |
| 125 | }; f" |
| 126 | checkout-soft = "!f() { \ |
| 127 | hash=$(git hash); \ |
| 128 | git checkout \"$@\"; \ |
| 129 | git reset --soft $hash; \ |
| 130 | }; f" # basically the opposite of a soft reset: change all the files but do not change the HEAD reference |
| 131 | graph = "log --graph --oneline --decorate" |
| 132 | fmt = "clang-format" |
| 133 | hash = "rev-parse HEAD" |
| 134 | fmt-last = "!f() { \ |
| 135 | hash=$(git hash); \ |
| 136 | git reset --soft HEAD^ && \ |
| 137 | git fmt; \ |
| 138 | git reset --soft $hash; \ |
| 139 | }; f" |
| 140 | personal = "config user.email skyler3665@gmail.com" |
| 141 | clicks = "config user.email minion@clicks.codes" |
| 142 | collabora = "config user.email skyler.grey@collabora.com" |
| 143 | # review = "!git-review -T": cannot be set here, set in .zshrc instead |
| 144 | |
| 145 | [init] |
| 146 | defaultBranch = "main" |
| 147 | |
| 148 | [color] |
| 149 | ui = "auto" |
| 150 | |
| 151 | [core] |
| 152 | autocrlf = "input" |
| 153 | splitIndex = true |
| 154 | untrackedCache = true |
| 155 | fsmonitor = true |
| 156 | pager = "delta" |
| 157 | |
| 158 | [pull] |
| 159 | rebase = merges |
| 160 | |
| 161 | [push] |
| 162 | autoSetupRemote = true |
| 163 | useForceIfIncludes = true |
| 164 | gpgSign = if-asked |
| 165 | |
| 166 | [credential] |
| 167 | helper = "store" |
| 168 | |
| 169 | [commit] |
| 170 | gpgsign = true |
| 171 | |
| 172 | [url "ssh://git@github.com/"] |
| 173 | pushInsteadOf = "https://github.com/" |
| 174 | |
| 175 | [interactive] |
| 176 | diffFilter = "delta --color-only" |
| 177 | |
| 178 | [delta] |
| 179 | navigate = true |
| 180 | light = false |
| 181 | line-numbers = true |
| 182 | features = "my-dark-theme zebra-dark" |
| 183 | |
| 184 | [merge] |
| 185 | conflictstyle = "diff3" |
| 186 | |
| 187 | [diff] |
| 188 | colorMoved = "default" |
| 189 | |
| 190 | [trailer] |
| 191 | ifexists = "addIfDifferent" |
| 192 | */ |