-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathgit.nix
159 lines (118 loc) · 3.67 KB
/
git.nix
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
{ self, lib, pkgs, ... }: with lib; merge
(systemConfiguration {
environment.shellAliases = {
g = "git";
ga = "git add";
gaa = "git add ./";
gab = "git absorb";
gabr = "git absorb --and-rebase";
gb = "git branch";
gbv = "git branch --verbose";
gc = "git commit";
gca = "git commit --amend --no-edit";
gcm = "git commit --message";
gcam = "git commit --amend --message";
gcl = "git clone";
gd = "git diff";
gds = "git diff --staged";
gp = "git push";
gpf = "git push --force-with-lease";
gl = "git log";
glo = "git log --oneline --graph";
glp = "git log -p --ext-diff";
gpl = "git pull";
gplr = "git pull --rebase";
gplff = "git pull --ff-only";
gr = "git recent";
grb = "git rebase";
grba = "git rebase --abort";
grbc = "git rebase --continue";
grbi = "git rebase --interactive";
grbm = "git rebase master";
grl = "git reflog";
grm = "git remote";
grma = "git remote add";
grmv = "git remote --verbose";
grmsu = "git remote set-url";
grs = "git reset";
grsh = "git reset --hard";
gs = "git stash";
gsp = "git stash pop";
gsw = "git switch";
gswm = "git switch master";
gsh = "git show --ext-diff";
gst = "git status";
};
})
(let
gitUrl = self.cube.services.forgejo.settings.server.ROOT_URL;
gitDomain = head (strings.match "https://(.*)/" gitUrl);
mailDomain = head self.disk.mailserver.domains;
in homeConfiguration {
programs.nushell.configFile.text = mkAfter ''
# Sets the remote origin to the specified user and repository on my git instance
def gsr [user_and_repo: string] {
let user_and_repo = if ($user_and_repo | str index-of "/") != -1 {
$user_and_repo
} else {
"RGBCube/" + $user_and_repo
}
git remote add origin ("${gitUrl}" + $user_and_repo)
}
'';
programs.git = enabled {
package = pkgs.gitFull;
userName = "RGBCube";
userEmail = "git@${mailDomain}";
lfs = enabled;
difftastic = enabled {
background = "dark";
};
extraConfig = merge {
init.defaultBranch = "master";
commit.verbose = true;
log.date = "iso";
column.ui = "auto";
branch.sort = "-committerdate";
tag.sort = "version:refname";
diff.algorithm = "histogram";
diff.colorMoved = "default";
pull.rebase = true;
push.autoSetupRemote = true;
merge.conflictStyle = "zdiff3";
rebase.autoSquash = true;
rebase.autoStash = true;
rebase.updateRefs = true;
rerere.enabled = true;
fetch.fsckObjects = true;
receive.fsckObjects = true;
transfer.fsckobjects = true;
# https://bernsteinbear.com/git
alias.recent = "! git branch --sort=-committerdate --format=\"%(committerdate:relative)%09%(refname:short)\" | head -10";
} (mkIf isDesktop {
core.sshCommand = "ssh -i ~/.ssh/id";
url."ssh://[email protected]/".insteadOf = "https://github.com/";
url."ssh://forgejo@${gitDomain}:${toString (head self.cube.services.openssh.ports)}/".insteadOf = gitUrl;
commit.gpgSign = true;
tag.gpgSign = true;
gpg.format = "ssh";
user.signingKey = "~/.ssh/id";
});
};
})
(desktopSystemConfiguration {
environment.shellAliases = {
"??" = "gh copilot suggest --target shell";
"gh?" = "gh copilot suggest --target gh";
"git?" = "gh copilot suggest --target git";
};
})
(desktopHomeConfiguration {
programs.gh = enabled {
settings.git_protocol = "ssh";
};
})
(systemPackages (with pkgs; [
git-absorb
tig
]))