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