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