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