Skip to content

Commit d5a9066

Browse files
authored
Merge pull request #4 from jeremystucki/copilot/fix-576129a5-fd6d-4df1-b445-440e27e841b5
Simplify and modularize dotfiles configuration structure
2 parents ac0852e + 88c4cf6 commit d5a9066

6 files changed

Lines changed: 133 additions & 149 deletions

File tree

common/1password.nix

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
{
2+
config,
3+
pkgs,
4+
pkgs-unstable,
5+
hostConfiguration,
6+
...
7+
}: {
8+
programs._1password = {
9+
enable = true;
10+
package = pkgs-unstable._1password-cli;
11+
};
12+
13+
programs._1password-gui = {
14+
enable = true;
15+
package = pkgs-unstable._1password-gui;
16+
polkitPolicyOwners = [hostConfiguration.username];
17+
};
18+
19+
programs.ssh.extraConfig = ''
20+
Host *
21+
IdentityAgent ${config.users.users.${hostConfiguration.username}.home}/.1password/agent.sock
22+
'';
23+
24+
systemd.user.services._1password = {
25+
script = "${pkgs-unstable._1password-gui}/bin/1password --silent";
26+
after = ["graphical-session.target"];
27+
partOf = ["graphical-session.target"];
28+
wantedBy = ["graphical-session.target"];
29+
};
30+
}

common/desktop-gnome.nix

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
{...}: {
2+
services.xserver = {
3+
enable = true;
4+
5+
xkb = {
6+
layout = "us";
7+
variant = "";
8+
};
9+
10+
displayManager.gdm.enable = true;
11+
desktopManager.gnome.enable = true;
12+
};
13+
14+
services.pulseaudio.enable = false;
15+
security.rtkit.enable = true;
16+
services.pipewire = {
17+
enable = true;
18+
alsa.enable = true;
19+
alsa.support32Bit = true;
20+
pulse.enable = true;
21+
};
22+
23+
# Enable OpenGL
24+
hardware.graphics = {
25+
enable = true;
26+
enable32Bit = true;
27+
};
28+
29+
environment.sessionVariables.NIXOS_OZONE_WL = "1";
30+
}

common/nix-settings.nix

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{...}: {
2+
nix.settings.experimental-features = [
3+
"nix-command"
4+
"flakes"
5+
];
6+
}

common/nixos.nix

Lines changed: 2 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -44,22 +44,6 @@
4444
};
4545
};
4646

47-
services.xserver = {
48-
enable = true;
49-
50-
xkb = {
51-
layout = "us";
52-
variant = "";
53-
};
54-
55-
displayManager = {
56-
gdm.enable = true;
57-
};
58-
desktopManager = {
59-
gnome.enable = true;
60-
};
61-
};
62-
6347
services.openssh.enable = true;
6448
services.printing.enable = true;
6549
services.tailscale.enable = true;
@@ -71,21 +55,6 @@
7155
"hmac-sha2-512"
7256
];
7357

74-
services.pulseaudio.enable = false;
75-
security.rtkit.enable = true;
76-
services.pipewire = {
77-
enable = true;
78-
alsa.enable = true;
79-
alsa.support32Bit = true;
80-
pulse.enable = true;
81-
# If you want to use JACK applications, uncomment this
82-
#jack.enable = true;
83-
84-
# use the example session manager (no others are packaged yet so this is enabled by default,
85-
# no need to redefine it in your config for now)
86-
#media-session.enable = true;
87-
};
88-
8958
services.ratbagd.enable = true;
9059

9160
virtualisation.docker.enable = true;
@@ -95,69 +64,25 @@
9564
defaultNetwork.settings.dns_enabled = true;
9665
};
9766

98-
# Some programs need SUID wrappers, can be configured further or are
99-
# started in user sessions.
100-
# programs.mtr.enable = true;
101-
# programs.gnupg.agent = {
102-
# enable = true;
103-
# enableSSHSupport = true;
104-
# };
105-
10667
hardware.i2c.enable = true;
10768

108-
# Enable OpenGL
109-
hardware.graphics = {
110-
enable = true;
111-
enable32Bit = true;
112-
};
113-
11469
fonts.packages = with pkgs; [
11570
pkgs.nerd-fonts.jetbrains-mono
11671
input-fonts
11772
];
11873

11974
programs.steam.enable = true;
120-
121-
programs._1password = {
122-
enable = true;
123-
package = pkgs-unstable._1password-cli;
124-
};
125-
126-
programs._1password-gui = {
127-
enable = true;
128-
package = pkgs-unstable._1password-gui;
129-
130-
# Certain features, including CLI integration and system authentication support,
131-
# require enabling PolKit integration on some desktop environments (e.g. Plasma).
132-
polkitPolicyOwners = [hostConfiguration.username];
133-
};
134-
13575
programs.adb.enable = true;
13676

137-
programs.ssh.extraConfig = ''
138-
Host *
139-
IdentityAgent ${config.users.users.${hostConfiguration.username}.home}/.1password/agent.sock
140-
'';
141-
142-
systemd.user.services._1password = {
143-
script = "${pkgs._1password-gui}/bin/1password --silent";
144-
after = ["graphical-session.target"];
145-
partOf = ["graphical-session.target"];
146-
wantedBy = ["graphical-session.target"];
147-
};
148-
14977
systemd.user.services.tmux = {
15078
script = "${pkgs.tmux}/bin/tmux new-session -d";
15179
wantedBy = ["default.target"];
15280
serviceConfig.Type = "forking";
15381
};
15482

155-
environment.sessionVariables = {
156-
NIXOS_OZONE_WL = "1";
157-
TZDIR = "/etc/zoneinfo";
158-
};
159-
16083
virtualisation.virtualbox.host.enable = true;
16184
users.extraGroups.vboxusers.members = [hostConfiguration.username];
16285
boot.kernelModules = ["vboxnetflt" "vboxnetadp"];
86+
87+
environment.sessionVariables.TZDIR = "/etc/zoneinfo";
16388
}

darwin-configuration.nix

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
{
2+
pkgs,
3+
pkgs-unstable,
4+
inputs,
5+
hostConfiguration,
6+
...
7+
}: {
8+
nix.settings.trusted-users = [hostConfiguration.username];
9+
10+
nix.gc = {
11+
automatic = true;
12+
options = "--delete-older-than 14d";
13+
};
14+
15+
system.stateVersion = 4;
16+
system.primaryUser = hostConfiguration.username;
17+
ids.gids.nixbld = 350;
18+
19+
environment.shells = [pkgs.zsh];
20+
programs.zsh.enable = true;
21+
22+
services.tailscale.enable = true;
23+
24+
users.users.${hostConfiguration.username}.home = "/Users/${hostConfiguration.username}";
25+
26+
fonts.packages = [pkgs.nerd-fonts.jetbrains-mono];
27+
28+
homebrew = {
29+
enable = true;
30+
casks = ["ghostty"];
31+
};
32+
33+
home-manager = {
34+
useGlobalPkgs = true;
35+
useUserPackages = true;
36+
users.${hostConfiguration.username}.imports = [
37+
./common/home-manager.nix
38+
./components/dotnet.nix
39+
];
40+
extraSpecialArgs = {inherit pkgs-unstable hostConfiguration;};
41+
sharedModules = [inputs.mac-app-util.homeManagerModules.default];
42+
};
43+
44+
security.pam.services.sudo_local = {
45+
enable = true;
46+
reattach = true;
47+
touchIdAuth = true;
48+
watchIdAuth = true;
49+
};
50+
}

flake.nix

Lines changed: 15 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -45,25 +45,7 @@
4545
allowUnfree = true;
4646
input-fonts.acceptLicense = true;
4747
};
48-
nixSettings = {
49-
nix.settings.experimental-features = [
50-
"nix-command"
51-
"flakes"
52-
];
53-
};
54-
hostConfigurations = {
55-
"volt-nixos" = {
56-
hostname = "volt-nixos";
57-
username = "jeremy";
58-
};
59-
"zephyr" = {
60-
hostname = "zephyr";
61-
username = "jeremy";
62-
};
63-
"work-macbook" = {
64-
username = "jeremy";
65-
};
66-
};
48+
username = "jeremy";
6749
in
6850
{
6951
nixosConfigurations = let
@@ -73,19 +55,23 @@
7355
nixosConfig = {
7456
nixosModule,
7557
hostSpecificHomeManagerModule ? {},
76-
hostConfiguration,
77-
}:
58+
hostname,
59+
}: let
60+
hostConfiguration = {inherit username hostname;};
61+
in
7862
inputs.nixpkgs.lib.nixosSystem {
7963
specialArgs = {inherit pkgs-unstable hostConfiguration;};
8064
modules = [
8165
{nixpkgs.pkgs = pkgs;}
8266
./common/nixos.nix
83-
nixSettings
67+
./common/desktop-gnome.nix
68+
./common/1password.nix
69+
./common/nix-settings.nix
8470
nixosModule
8571
inputs.color-scheme-sync.nixosModules.default
8672
inputs.home-manager.nixosModules.home-manager
8773
{
88-
home-manager.users.${hostConfiguration.username}.imports = [
74+
home-manager.users.${username}.imports = [
8975
./common/home-manager.nix
9076
./components/alacritty.nix
9177
./components/haskell.nix
@@ -100,20 +86,20 @@
10086
in {
10187
"volt-nixos" = nixosConfig {
10288
nixosModule = ./volt/nixos-configuration.nix;
103-
hostConfiguration = hostConfigurations.volt-nixos;
89+
hostname = "volt-nixos";
10490
hostSpecificHomeManagerModule = ./volt/home-manager.nix;
10591
};
10692
"zephyr" = nixosConfig {
10793
nixosModule = ./zephyr/nixos-configuration.nix;
108-
hostConfiguration = hostConfigurations.zephyr;
94+
hostname = "zephyr";
10995
};
11096
};
11197

11298
darwinConfigurations = let
11399
system = "aarch64-darwin";
114100
pkgs = import inputs.nixpkgs {inherit system config;};
115101
pkgs-unstable = import inputs.nixpkgs-unstable {inherit system config;};
116-
hostConfiguration = hostConfigurations.work-macbook;
102+
hostConfiguration = {inherit username;};
117103
in {
118104
"work-macbook" = inputs.darwin.lib.darwinSystem {
119105
inherit system;
@@ -125,56 +111,13 @@
125111
nodejs = prev.nodejs_22;
126112
})
127113
];
128-
}
129-
nixSettings
130-
{
131-
nix.settings.trusted-users = [hostConfiguration.username];
132-
133-
nix.gc = {
134-
automatic = true;
135-
options = "--delete-older-than 14d";
136-
};
137-
138-
system.stateVersion = 4;
139-
system.primaryUser = hostConfiguration.username;
140-
ids.gids.nixbld = 350;
141-
142114
nixpkgs.config = config;
143-
environment.shells = [pkgs.zsh];
144-
programs.zsh.enable = true;
145-
146-
services.tailscale.enable = true;
147-
148-
users.users.${hostConfiguration.username}.home = "/Users/${hostConfiguration.username}";
149-
150-
fonts.packages = [pkgs.nerd-fonts.jetbrains-mono];
151-
152-
homebrew = {
153-
enable = true;
154-
casks = ["ghostty"];
155-
};
156115
}
116+
./common/nix-settings.nix
117+
./darwin-configuration.nix
157118
inputs.home-manager.darwinModules.home-manager
158-
{
159-
home-manager = {
160-
useGlobalPkgs = true;
161-
useUserPackages = true;
162-
users.${hostConfiguration.username}.imports = [
163-
./common/home-manager.nix
164-
./components/dotnet.nix
165-
];
166-
extraSpecialArgs = {inherit pkgs-unstable hostConfiguration;};
167-
sharedModules = [inputs.mac-app-util.homeManagerModules.default];
168-
};
169-
170-
security.pam.services.sudo_local = {
171-
enable = true;
172-
reattach = true;
173-
touchIdAuth = true;
174-
watchIdAuth = true;
175-
};
176-
}
177119
];
120+
specialArgs = {inherit inputs hostConfiguration pkgs-unstable;};
178121
};
179122
};
180123
}

0 commit comments

Comments
 (0)