blob: 918ec797cc2a961e122949b090ae4c8f0aacaa1d [file] [log] [blame]
Samuel Shuert02ffd1e2024-02-13 21:37:15 -05001{
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 Greyec50d242024-02-15 23:09:46 +000011 stgit.enable = lib.mkEnableOption "Install StGit, a tool that makes working with stacked patches easier";
Samuel Shuert02ffd1e2024-02-13 21:37:15 -050012 auth = {
13 clicksUsername = lib.mkOption {
14 type = lib.types.str;
15 description = "Username for Clicks Gerrit";
16 };
17 };
Skyler Grey695fa632024-02-17 22:45:41 +000018 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 Shuert02ffd1e2024-02-13 21:37:15 -050031 };
32
33 config = {
Skyler Grey695fa632024-02-17 22:45:41 +000034 chimera.gpg.enable = lib.mkIf config.chimera.git.gpg.enable true;
Samuel Shuert02ffd1e2024-02-13 21:37:15 -050035
Skyler Greyd5457a22024-02-15 23:02:32 +000036 home.packages =
Skyler Greyec50d242024-02-15 23:09:46 +000037 (if config.chimera.git.gitReview.enable then [ pkgs.git-review ] else [ ])
Samuel Shuert849a93e2024-02-21 22:38:53 +000038 ++ (if config.chimera.git.stgit.enable then [ pkgs.stgit ] else [ ]);
Samuel Shuert02ffd1e2024-02-13 21:37:15 -050039
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 Greybb7586a2024-02-15 19:15:04 +000049 delta = {
Skyler Greyec50d242024-02-15 23:09:46 +000050 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 Shuert02ffd1e2024-02-13 21:37:15 -050055
56 extraConfig = {
57 init.defaultBranch = "main";
58 advice.skippedcherrypicks = false;
Skyler Grey695fa632024-02-17 22:45:41 +000059 commit.gpgsign = lib.mkIf config.chimera.git.gpg.enable config.chimera.git.gpg.commit;
Samuel Shuert02ffd1e2024-02-13 21:37:15 -050060 credential.helper = "cache";
61 core = {
62 repositoryformatversion = 0;
63 filemode = true;
Samuel Shuert659b5642024-02-23 20:47:43 +000064 # 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 Shuert02ffd1e2024-02-13 21:37:15 -050065 };
66 push = {
67 autoSetupRemote = true;
Samuel Shuert659b5642024-02-23 20:47:43 +000068 gpgSign = lib.mkIf config.chimera.git.gpg.enable (
69 if config.chimera.git.gpg.push then "if-asked" else false
70 );
Samuel Shuert02ffd1e2024-02-13 21:37:15 -050071 };
Skyler Grey9e24d9b2024-03-01 21:12:34 +000072 pull.rebase = "merges";
Samuel Shuert02ffd1e2024-02-13 21:37:15 -050073 url = {
74 "ssh://git@github.com/".pushInsteadOf = "https://github.com/";
Skyler Greybb7586a2024-02-15 19:15:04 +000075 "ssh://${config.chimera.git.auth.clicksUsername}@ssh.clicks.codes:29418/".pushInsteadOf = "https://git.clicks.codes/";
Samuel Shuert02ffd1e2024-02-13 21:37:15 -050076 };
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*/