Skip to content

Commit 64a84ea

Browse files
committed
Remove work laptop from config
1 parent 8d5f51e commit 64a84ea

File tree

4 files changed

+29
-61
lines changed

4 files changed

+29
-61
lines changed

README.md

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,15 @@
66
## Overview
77
This repo is managed at the top level via `flake.nix`, which defines configuration for:
88
- My personal MacBook Pro
9-
- My work MacBook Pro (requires a special `work-extras.nix`)
109
- `optimus`, an old Optiplex 9020 that I picked up some years ago
1110
- `rpi4`, a Raspberry Pi 4 Model B
1211
- `rpi5`, a Raspberry Pi 5
1312

14-
The two MBPs are configured via [nix-darwin].
15-
1613
### Building and Deploying
1714
```bash
1815
# Rebuild local system
1916
sudo nixos-rebuild switch --flake .#HOSTNAME
20-
sudo darwin-rebuild switch --flake .#HOSTNAME # --impure if needed
17+
sudo darwin-rebuild switch --flake .#HOSTNAME
2118

2219
# Deploy to hosts (via ./deploy/default.nix)
2320
nix run .#deploy-rs -- .#HOSTNAME

flake.nix

Lines changed: 19 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -28,37 +28,32 @@
2828
nixos-raspberrypi,
2929
}:
3030
let
31-
systems = [
32-
"aarch64-darwin"
33-
"aarch64-linux"
34-
"x86_64-linux"
35-
];
36-
mkFlakeOutput = f: nixpkgs.lib.genAttrs systems f;
37-
38-
# NOTE: used by ./home/git.nix
31+
# NOTE: a special arg used by ./home/git.nix
3932
git = {
4033
settings = {
4134
user.name = "Gregory Conrad";
4235
user.email = "[email protected]";
4336
};
4437
};
38+
in
39+
{
40+
lib = {
41+
mkFlakeOutput = f: nixpkgs.lib.genAttrs nixpkgs.lib.systems.flakeExposed f;
4542

46-
mkHomeManagerModule = specialArgs: homeManagerModules: {
47-
home-manager.useGlobalPkgs = true;
48-
home-manager.useUserPackages = true;
49-
home-manager.extraSpecialArgs = specialArgs // {
50-
inherit git;
43+
mkHomeManagerModule = specialArgs: homeManagerModules: {
44+
home-manager.useGlobalPkgs = true;
45+
home-manager.useUserPackages = true;
46+
home-manager.extraSpecialArgs = specialArgs;
47+
home-manager.users.${specialArgs.username} = nixpkgs.lib.mkMerge homeManagerModules;
5148
};
52-
home-manager.users.${specialArgs.username} = nixpkgs.lib.mkMerge homeManagerModules;
5349
};
54-
in
55-
{
56-
formatter = mkFlakeOutput (system: nixpkgs.legacyPackages.${system}.nixfmt-tree);
57-
apps = mkFlakeOutput (system: {
50+
51+
formatter = self.lib.mkFlakeOutput (system: nixpkgs.legacyPackages.${system}.nixfmt-tree);
52+
apps = self.lib.mkFlakeOutput (system: {
5853
deploy-rs = deploy-rs.apps.${system}.deploy-rs;
5954
});
6055
deploy = import ./deploy inputs;
61-
devShells = mkFlakeOutput (
56+
devShells = self.lib.mkFlakeOutput (
6257
system:
6358
let
6459
pkgs = nixpkgs.legacyPackages.${system};
@@ -83,47 +78,23 @@
8378
username = "gconrad";
8479
hostname = "Groog-MBP";
8580
specialArgs = inputs // {
86-
inherit username hostname;
81+
inherit username hostname git;
8782
};
8883
in
8984
nix-darwin.lib.darwinSystem {
9085
inherit specialArgs;
9186
modules = [
9287
./modules/darwin-common.nix
88+
./modules/darwin-nix.nix
9389
./hosts/Groog-MBP.nix
9490
home-manager.darwinModules.home-manager
95-
(mkHomeManagerModule specialArgs [
91+
(self.lib.mkHomeManagerModule specialArgs [
9692
(import ./home)
9793
(import ./home/personal.nix)
9894
])
9995
];
10096
};
10197

102-
darwinConfigurations.Greg-Work-MBP =
103-
let
104-
username = "greg";
105-
hostname = "Greg-Work-MBP";
106-
specialArgs = inputs // {
107-
inherit username hostname;
108-
};
109-
workExtrasPath = "/Users/greg/Documents/work-darwin-config.nix";
110-
in
111-
nix-darwin.lib.darwinSystem {
112-
inherit specialArgs;
113-
modules = [
114-
./modules/darwin-common.nix
115-
./hosts/Greg-Work-MBP.nix
116-
home-manager.darwinModules.home-manager
117-
(mkHomeManagerModule specialArgs [ (import ./home) ])
118-
119-
# NOTE: this out-of-repo import is what requires impure.
120-
# Frankly too much effort to do this a "proper" way, like:
121-
# - A private git repo, that is added as a git submodule
122-
# - Via secret management (never looked into this enough)
123-
(if builtins.pathExists workExtrasPath then import workExtrasPath else { })
124-
];
125-
};
126-
12798
nixosConfigurations.optimus =
12899
let
129100
username = "gconrad";
@@ -132,7 +103,7 @@
132103
nodeIP = "100.64.0.1";
133104
};
134105
specialArgs = inputs // {
135-
inherit username hostname k3sConfig;
106+
inherit username hostname git k3sConfig;
136107
};
137108
in
138109
nixpkgs.lib.nixosSystem {
@@ -145,7 +116,7 @@
145116
./modules/k8s/leader.nix
146117
./hosts/optimus
147118
home-manager.nixosModules.home-manager
148-
(mkHomeManagerModule specialArgs [ (import ./home) ])
119+
(self.lib.mkHomeManagerModule specialArgs [ (import ./home) ])
149120
];
150121
};
151122

modules/darwin-common.nix

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,8 @@
55
...
66
}:
77
{
8-
nix.settings.experimental-features = [
9-
"nix-command"
10-
"flakes"
11-
];
12-
138
nixpkgs.hostPlatform = "aarch64-darwin";
149

15-
nix.gc.automatic = true;
16-
nix.linux-builder.enable = true;
17-
nix.linux-builder.config.virtualisation.cores = 8;
18-
1910
environment.shells = [ pkgs.fish ];
2011
programs.fish.enable = true;
2112

modules/darwin-nix.nix

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
nix.gc.automatic = true;
3+
nix.linux-builder.enable = true;
4+
nix.linux-builder.config.virtualisation.cores = 8;
5+
nix.settings.experimental-features = [
6+
"nix-command"
7+
"flakes"
8+
];
9+
}

0 commit comments

Comments
 (0)