Skip to content

Commit 643b18f

Browse files
committed
Add git configs
1 parent 815a155 commit 643b18f

File tree

3 files changed

+70
-11
lines changed

3 files changed

+70
-11
lines changed

flake.lock

+9-9
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

modules/sysconf.nix

+2-1
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,9 @@
66
default = {
77
userName = "Rick Sanchez";
88
email = "[email protected]";
9+
defaultBranch = "main";
910
};
10-
description = "The git configs for commits: userName and email";
11+
description = "The git configs for commits: userName, email and default branch";
1112
};
1213

1314
keyboardCCedilla = lib.mkOption {

src/users.nix

+59-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,20 @@
1-
{ config, pkgs, ... }:
1+
{ config, lib, pkgs, ... }:
22

33
let
44
mainUser = config.environment.sysConf.mainUser;
5+
git_create_workspaces = true;
6+
git_workspaces = [
7+
{
8+
folder_name = "workspace1";
9+
email = "[email protected]";
10+
username = "Dev One";
11+
}
12+
{
13+
folder_name = "workspace2";
14+
email = "[email protected]";
15+
username = "Dev Two";
16+
}
17+
];
518
in
619
{
720
# Define a user account. Don't forget to set a password with ‘passwd’.
@@ -26,7 +39,52 @@ in
2639
programs.git = {
2740
userName = config.environment.sysConf.git.userName;
2841
userEmail = config.environment.sysConf.git.email;
42+
extraConfig = {
43+
credential.helper = "cache --timeout=36000";
44+
core = {
45+
editor = "vi";
46+
autocrlf = "input";
47+
};
48+
color.ui = "always";
49+
init.defaultBranch = config.environment.sysConf.git.defaultBranch;
50+
alias = {
51+
ac = "commit --amend --no-edit --all";
52+
fp = "push --force-with-lease";
53+
c = "commit";
54+
ca = "commit -a";
55+
cm = "commit -m";
56+
cam = "commit -am";
57+
d = "diff";
58+
dc = "diff --cached";
59+
graph = "log --graph --all --oneline";
60+
l = ''log --graph --pretty=format:"%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset" --abbrev-commit'';
61+
acommit = "commit --amend --no-edit --all";
62+
fpush = "push --force-with-lease";
63+
};
64+
pull.rebase = true;
65+
66+
};
67+
includes = lib.optionals git_create_workspaces (
68+
map (ws: {
69+
condition = "gitdir:~/${ws.folder_name}/";
70+
path = "~/${ws.folder_name}/.gitconfig";
71+
}) git_workspaces
72+
);
2973
};
74+
75+
home.file = lib.mkIf git_create_workspaces (
76+
lib.listToAttrs (map (ws:
77+
{
78+
name = "${ws.folder_name}/.gitconfig";
79+
value = {
80+
text = ''
81+
[user]
82+
email = ${ws.email}
83+
name = ${ws.username}
84+
'';
85+
};
86+
}) git_workspaces)
87+
);
3088
};
3189
};
3290
}

0 commit comments

Comments
 (0)