blob: 7bbc04098dbbaa0623408fdb43f914eb2729ab55 [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 };
72 url = {
73 "ssh://git@github.com/".pushInsteadOf = "https://github.com/";
Skyler Greybb7586a2024-02-15 19:15:04 +000074 "ssh://${config.chimera.git.auth.clicksUsername}@ssh.clicks.codes:29418/".pushInsteadOf = "https://git.clicks.codes/";
Samuel Shuert02ffd1e2024-02-13 21:37:15 -050075 };
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*/