Skip to content

Commit 8a69642

Browse files
committed
Add git to sysconf
1 parent 643b18f commit 8a69642

13 files changed

+109
-249
lines changed

README.md

+1-7
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
- Browsers: [Brave] and [Mullvad Browser] (via Nix).
1414
- Containers and virtualization: [Docker], [Podman] and [libvirtd].
1515
- Office: installs [OnlyOffice] (via Nixpkgs).
16-
- Assorted FOSS programs: [Cryptomator], [KeyPass], [OBS] (via Nixpkgs), [OpenRGB], [RClone], and [Signal] (via Nixpkgs) messenger installation.
16+
- Your favorite programs via Nixpkgss.
1717
- Configurations: dotfiles, zsh (via Nix), terminals, [Gnome], [Git], ssh, keyboard...
1818

1919
Note: this is an opinionated setup I personally use for software development on [NixOS](https://nixos.org). You can customize all the changes following instructions in [Overriding Defaults](#overriding-defaults).
@@ -117,7 +117,6 @@ This project was inspired by [@geerlingguy]'s [Mac Development Ansible Playbook]
117117
[@geerlingguy]: https://github.com/geerlingguy
118118
[brave]: https://brave.com/
119119
[contributor guide]: https://github.com/staticdev/linux-workstation-playbook/blob/main/CONTRIBUTING.md
120-
[cryptomator]: https://cryptomator.org/
121120
[debian]: https://www.debian.org/
122121
[docker]: https://www.docker.com/
123122
[dotfiles eg. repo]: https://github.com/staticdev/dotfiles-eg
@@ -127,19 +126,14 @@ This project was inspired by [@geerlingguy]'s [Mac Development Ansible Playbook]
127126
[gnome]: https://www.gnome.org/
128127
[home manager]: https://github.com/nix-community/home-manager
129128
[libvirtd]: https://libvirt.org/manpages/libvirtd.html
130-
[keypass]: https://keepass.info/
131129
[mac development ansible playbook]: https://github.com/geerlingguy/mac-dev-playbook
132130
[mit]: https://opensource.org/licenses/MIT
133131
[mullvad browser]: https://mullvad.net/en/browser
134132
[neovim]: https://github.com/neovim/neovim
135133
[nix]: https://nixos.org/
136134
[nixos download iso page]: https://nixos.org/download/#nixos-iso
137135
[nixvim]: https://github.com/nix-community/nixvim
138-
[obs]: https://obsproject.com/
139136
[onlyoffice]: https://github.com/ONLYOFFICE/
140-
[openrgb]: https://gitlab.com/CalcProgrammer1/OpenRGB
141137
[pep-668]: https://peps.python.org/pep-0668/
142138
[podman]: https://podman.io/
143-
[rclone]: https://rclone.org/
144-
[signal]: https://signal.org
145139
[vscodium]: https://vscodium.com/

default.config.yml

-15
Original file line numberDiff line numberDiff line change
@@ -60,20 +60,5 @@ gnome_favorite_apps:
6060
# enable entire screen sharing
6161
enable_screen_sharing: false
6262

63-
# extra installs
64-
## cryptomator
65-
install_cryptomator: false
66-
cryptomator_version: 1.11.1
67-
68-
install_keypass_xc: false
69-
install_rclone: false
70-
71-
## openrgb
72-
install_openrgb: false
73-
# get from https://gitlab.com/CalcProgrammer1/OpenRGB/-/tags
74-
openrgb_git_release: release_0.9
75-
openrgb_deb_version: 0.9.0
76-
openrgb_deb_architecture: amd64
77-
7863
# glob pattern to ansible task files to run after all other tasks are finished.
7964
post_provision_tasks: []

eg/local.nix

+14
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,20 @@
55
git = {
66
userName = "Rick Sanchez";
77
email = "[email protected]";
8+
defaultBranch = "main";
9+
createWorkspaces = true;
10+
workspaces = [
11+
{
12+
folderName = "workspace_personal";
13+
email = "[email protected]";
14+
userName = "Rick Personal";
15+
}
16+
{
17+
folderName = "workspace_work";
18+
email = "[email protected]";
19+
userName = "Rick Professional";
20+
}
21+
];
822
};
923
mainUser = {
1024
name = "username";

main.yml

-34
Original file line numberDiff line numberDiff line change
@@ -19,27 +19,9 @@
1919
ansible.builtin.command: killall -SIGQUIT gnome-shell
2020
changed_when: true
2121

22-
- name: Delete openrgb repo
23-
ansible.builtin.file:
24-
path: "{{ ansible_env.HOME }}/OpenRGB"
25-
state: absent
26-
27-
- name: Delete openrgb generated files
28-
ansible.builtin.file:
29-
path: "{{ ansible_env.HOME }}/{{ item }}"
30-
state: absent
31-
with_items:
32-
- "openrgb_{{ openrgb_deb_version }}_{{ openrgb_deb_architecture }}.buildinfo"
33-
- "openrgb_{{ openrgb_deb_version }}_{{ openrgb_deb_architecture }}.changes"
34-
- "openrgb_{{ openrgb_deb_version }}_{{ openrgb_deb_architecture }}.deb"
35-
- "openrgb-dbgsym_{{ openrgb_deb_version }}_{{ openrgb_deb_architecture }}.deb"
36-
- "OpenRGB/debian/changelog"
37-
3822
roles:
3923
- role: geerlingguy.dotfiles
4024
when: configure_dotfiles
41-
- role: stefangweichinger.ansible_rclone
42-
when: install_rclone
4325

4426
tasks:
4527
- name: Create SSH key
@@ -50,22 +32,6 @@
5032
ansible.builtin.include_tasks: tasks/sudoers.yml
5133
when: configure_sudoers
5234

53-
- name: Setup Git
54-
ansible.builtin.include_tasks: tasks/git-setup.yml
55-
when: setup_git
56-
57-
- name: Cryptomator
58-
ansible.builtin.include_tasks: tasks/cryptomator.yml
59-
when: install_cryptomator
60-
61-
- name: Install Keypass XC
62-
ansible.builtin.import_tasks: tasks/keypass-xc.yml
63-
when: install_keypass_xc
64-
65-
- name: OpenRGB
66-
ansible.builtin.include_tasks: tasks/openrgb.yml
67-
when: install_openrgb
68-
6935
- name: Enable entire screen sharing
7036
ansible.builtin.lineinfile:
7137
dest: /etc/gdm3/daemon.conf

modules/sysconf.nix

+81-17
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,95 @@
11
{ lib, pkgs, ... }:
2-
{
2+
3+
let
4+
inherit (lib) mkOption types;
5+
in {
36
options.environment.sysConf = {
4-
git = lib.mkOption {
5-
type = with lib.types; attrsOf str;
6-
default = {
7+
git = mkOption {
8+
type = with types; submodule {
9+
options = {
10+
userName = mkOption {
11+
type = str;
12+
default = "Rick Sanchez";
13+
description = "Git global username.";
14+
};
15+
16+
email = mkOption {
17+
type = str;
18+
default = "[email protected]";
19+
description = "Git global email.";
20+
};
21+
22+
defaultBranch = mkOption {
23+
type = str;
24+
default = "main";
25+
description = "Default Git branch name (e.g. main or master).";
26+
};
27+
28+
createWorkspaces = mkOption {
29+
type = bool;
30+
default = false;
31+
description = "Whether to enable per-workspace Git configs.";
32+
};
33+
34+
workspaces = mkOption {
35+
type = listOf (submodule {
36+
options = {
37+
folderName = mkOption {
38+
type = str;
39+
description = "Relative folder path for the Git workspace.";
40+
};
41+
email = mkOption {
42+
type = str;
43+
description = "Git email to use in this workspace.";
44+
};
45+
userName = mkOption {
46+
type = str;
47+
description = "Git username to use in this workspace.";
48+
};
49+
};
50+
});
51+
default = [ ];
52+
description = "List of Git workspace configurations.";
53+
};
54+
};
55+
};
56+
default = {};
57+
example = {
758
userName = "Rick Sanchez";
859
email = "[email protected]";
960
defaultBranch = "main";
61+
createWorkspaces = true;
62+
workspaces = [
63+
{
64+
folderName = "workspace_personal";
65+
email = "[email protected]";
66+
userName = "Rick Personal";
67+
}
68+
{
69+
folderName = "workspace_work";
70+
email = "[email protected]";
71+
userName = "Rick Professional";
72+
}
73+
];
1074
};
11-
description = "The git configs for commits: userName, email and default branch";
75+
description = "Git configuration including user info and optional workspace-specific overrides.";
1276
};
1377

14-
keyboardCCedilla = lib.mkOption {
15-
type = lib.types.bool;
78+
keyboardCCedilla = mkOption {
79+
type = types.bool;
1680
default = false;
1781
description = "Whether to enable cedilla support via GTK/QT IM modules.";
1882
};
19-
keyboardLayout = lib.mkOption {
20-
type = with lib.types; listOf (submodule {
83+
keyboardLayout = mkOption {
84+
type = with types; listOf (submodule {
2185
options = {
22-
layout = lib.mkOption {
86+
layout = mkOption {
2387
type = str;
2488
description = "Keyboard layout, e.g. 'us'";
2589
example = "us";
2690
};
2791

28-
variant = lib.mkOption {
92+
variant = mkOption {
2993
type = nullOr str;
3094
default = null;
3195
description = "Optional keyboard variant, e.g. 'intl'";
@@ -41,8 +105,8 @@
41105
];
42106
};
43107

44-
mainUser = lib.mkOption {
45-
type = with lib.types; attrsOf (oneOf [str (listOf package)]);
108+
mainUser = mkOption {
109+
type = with types; attrsOf (oneOf [str (listOf package)]);
46110
default = {
47111
name = "rick";
48112
pkgs = with pkgs; [
@@ -54,16 +118,16 @@
54118
description = "The main user of the system: name and pkgs";
55119
};
56120

57-
systemWidePkgs = lib.mkOption {
58-
type = lib.types.listOf lib.types.package;
121+
systemWidePkgs = mkOption {
122+
type = types.listOf types.package;
59123
default = with pkgs; [
60124
openssl
61125
];
62126
description = "The system packages";
63127
};
64128

65-
timeZone = lib.mkOption {
66-
type = lib.types.str;
129+
timeZone = mkOption {
130+
type = types.str;
67131
default = "UTC";
68132
description = "The system time zone";
69133
};

requirements.yml

-2
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22
roles:
33
- name: geerlingguy.dotfiles
44
version: 1.2.1
5-
- name: stefangweichinger.ansible_rclone
6-
version: 0.1.3
75

86
collections:
97
- name: community.general

src/users.nix

+13-26
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,11 @@
11
{ config, lib, pkgs, ... }:
22

33
let
4-
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-
];
4+
sysConf = config.environment.sysConf;
185
in
196
{
207
# Define a user account. Don't forget to set a password with ‘passwd’.
21-
users.users."${mainUser.name}" = {
8+
users.users."${sysConf.mainUser.name}" = {
229
isNormalUser = true;
2310
shell = pkgs.zsh;
2411
extraGroups = [
@@ -29,11 +16,11 @@ in
2916
};
3017

3118
home-manager.users = {
32-
"${mainUser.name}" = { ... }:
19+
"${sysConf.mainUser.name}" = { ... }:
3320
{
3421
home = {
35-
username = mainUser.name;
36-
homeDirectory = "/home/${mainUser.name}";
22+
username = sysConf.mainUser.name;
23+
homeDirectory = "/home/${sysConf.mainUser.name}";
3724
};
3825

3926
programs.git = {
@@ -64,26 +51,26 @@ in
6451
pull.rebase = true;
6552

6653
};
67-
includes = lib.optionals git_create_workspaces (
54+
includes = lib.optionals sysConf.git.createWorkspaces (
6855
map (ws: {
69-
condition = "gitdir:~/${ws.folder_name}/";
70-
path = "~/${ws.folder_name}/.gitconfig";
71-
}) git_workspaces
56+
condition = "gitdir:~/${ws.folderName}/";
57+
path = "~/${ws.folderName}/.gitconfig";
58+
}) sysConf.git.workspaces
7259
);
7360
};
7461

75-
home.file = lib.mkIf git_create_workspaces (
62+
home.file = lib.mkIf sysConf.git.createWorkspaces (
7663
lib.listToAttrs (map (ws:
7764
{
78-
name = "${ws.folder_name}/.gitconfig";
65+
name = "${ws.folderName}/.gitconfig";
7966
value = {
8067
text = ''
8168
[user]
8269
email = ${ws.email}
83-
name = ${ws.username}
70+
name = ${ws.userName}
8471
'';
8572
};
86-
}) git_workspaces)
73+
}) sysConf.git.workspaces)
8774
);
8875
};
8976
};

tasks/cryptomator.yml

-11
This file was deleted.

tasks/git-setup.yml

-24
This file was deleted.

0 commit comments

Comments
 (0)