blob: 23f3d78f2659c4f8a01d70400027009bb875d8ec [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 };
18 };
19
20 config = {
21
Skyler Greyd5457a22024-02-15 23:02:32 +000022 home.packages =
Skyler Greyec50d242024-02-15 23:09:46 +000023 (if config.chimera.git.gitReview.enable then [ pkgs.git-review ] else [ ])
24 ++ (if config.chimera.git.stgit.enable then [ pkgs.stgit ] else [ ]);
Samuel Shuert02ffd1e2024-02-13 21:37:15 -050025
26 programs.zsh.shellAliases =
27 if config.chimera.git.gitReview.enable then { "gr!" = "git review"; } else { };
28
29 programs.bash.shellAliases =
30 if config.chimera.git.gitReview.enable then { "gr!" = "git review"; } else { };
31
32 programs.git = {
33 enable = true;
34
Skyler Greybb7586a2024-02-15 19:15:04 +000035 delta = {
Skyler Greyec50d242024-02-15 23:09:46 +000036 enable = config.chimera.git.delta.enable;
37 options.light = lib.mkIf config.chimera.theme.catppuccin.enable (
38 config.chimera.theme.catppuccin.style == "Latte"
39 );
40 };
Samuel Shuert02ffd1e2024-02-13 21:37:15 -050041
42 extraConfig = {
43 init.defaultBranch = "main";
44 advice.skippedcherrypicks = false;
45 commit.gpgsign = true;
46 credential.helper = "cache";
47 core = {
48 repositoryformatversion = 0;
49 filemode = true;
50 bare = false;
51 logallrefupdates = true;
52 fsmonitor = true;
53 autocrlf = "input";
54 splitIndex = true;
55 untrackedCache = true;
56 };
57 pull = {
58 rebase = "merges"; # 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).
59 };
60 push = {
61 autoSetupRemote = true;
62 gpgSign = "if-asked";
63 };
64 url = {
65 "ssh://git@github.com/".pushInsteadOf = "https://github.com/";
Skyler Greybb7586a2024-02-15 19:15:04 +000066 "ssh://${config.chimera.git.auth.clicksUsername}@ssh.clicks.codes:29418/".pushInsteadOf = "https://git.clicks.codes/";
Samuel Shuert02ffd1e2024-02-13 21:37:15 -050067 };
68 merge.conflictstyle = "diff3";
69 trailer.ifexists = "addIfDifferent";
70 };
71 };
72 };
73}
74
75/* [alias]
76 recommit = "!git commit --verbose -eF $(git rev-parse --git-dir)/COMMIT_EDITMSG"
77 stash-working = "!f() { \
78 git commit --quiet --no-verify -m \"temp for stash-working\" && \
79 git stash push \"$@\" && \
80 git reset --quiet --soft HEAD~1; \
81 }; f"
82 checkout-soft = "!f() { \
83 hash=$(git hash); \
84 git checkout \"$@\"; \
85 git reset --soft $hash; \
86 }; f" # basically the opposite of a soft reset: change all the files but do not change the HEAD reference
87 graph = "log --graph --oneline --decorate"
88 fmt = "clang-format"
89 hash = "rev-parse HEAD"
90 fmt-last = "!f() { \
91 hash=$(git hash); \
92 git reset --soft HEAD^ && \
93 git fmt; \
94 git reset --soft $hash; \
95 }; f"
96 personal = "config user.email skyler3665@gmail.com"
97 clicks = "config user.email minion@clicks.codes"
98 collabora = "config user.email skyler.grey@collabora.com"
99 # review = "!git-review -T": cannot be set here, set in .zshrc instead
100
101 [credential]
102 helper = "store"
103
104 /*
105 [user]
106 name = "Skyler Grey"
107 signingkey = "7C868112B5390C5C"
108 useConfigOnly = true # avoid auto-setting user.email by hostname
109
110 [alias]
111 recommit = "!git commit --verbose -eF $(git rev-parse --git-dir)/COMMIT_EDITMSG"
112 stash-working = "!f() { \
113 git commit --quiet --no-verify -m \"temp for stash-working\" && \
114 git stash push \"$@\" && \
115 git reset --quiet --soft HEAD~1; \
116 }; f"
117 checkout-soft = "!f() { \
118 hash=$(git hash); \
119 git checkout \"$@\"; \
120 git reset --soft $hash; \
121 }; f" # basically the opposite of a soft reset: change all the files but do not change the HEAD reference
122 graph = "log --graph --oneline --decorate"
123 fmt = "clang-format"
124 hash = "rev-parse HEAD"
125 fmt-last = "!f() { \
126 hash=$(git hash); \
127 git reset --soft HEAD^ && \
128 git fmt; \
129 git reset --soft $hash; \
130 }; f"
131 personal = "config user.email skyler3665@gmail.com"
132 clicks = "config user.email minion@clicks.codes"
133 collabora = "config user.email skyler.grey@collabora.com"
134 # review = "!git-review -T": cannot be set here, set in .zshrc instead
135
136 [init]
137 defaultBranch = "main"
138
139 [color]
140 ui = "auto"
141
142 [core]
143 autocrlf = "input"
144 splitIndex = true
145 untrackedCache = true
146 fsmonitor = true
147 pager = "delta"
148
149 [pull]
150 rebase = merges
151
152 [push]
153 autoSetupRemote = true
154 useForceIfIncludes = true
155 gpgSign = if-asked
156
157 [credential]
158 helper = "store"
159
160 [commit]
161 gpgsign = true
162
163 [url "ssh://git@github.com/"]
164 pushInsteadOf = "https://github.com/"
165
166 [interactive]
167 diffFilter = "delta --color-only"
168
169 [delta]
170 navigate = true
171 light = false
172 line-numbers = true
173 features = "my-dark-theme zebra-dark"
174
175 [merge]
176 conflictstyle = "diff3"
177
178 [diff]
179 colorMoved = "default"
180
181 [trailer]
182 ifexists = "addIfDifferent"
183*/