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