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