nixos configs

big module refactor

+185 -199
+21 -20
CLAUDE.md
··· 34 34 35 35 ### Hosts (`/hosts/`) 36 36 37 - | Host | Platform | Notes | 38 - |------|----------|-------| 39 - | merlon | NixOS x86_64 | Desktop with Nvidia GPU, Wayland (Niri), FIDO2 disk encryption | 40 - | merlow | NixOS x86_64 | Hetzner VPS, headless server | 41 - | watt | NixOS x86_64 | Homelab MacBook Pro, headless, Home Assistant | 42 - | nolrem | nix-darwin aarch64 | MacBook Air | 43 - | FH91CFY4QP-2 | nix-darwin aarch64 | Work MacBook, uses `alebat01` user | 37 + Each host's `configuration.nix` is self-contained: it imports the modules it needs from `/modules/` and configures home-manager inline. The `flake.nix` is kept slim, only wiring host entry points to `nixosSystem`/`darwinSystem` with `home-manager.*Modules.*`. 38 + 39 + | Host | Platform | Profile | Notes | 40 + |------|----------|---------|-------| 41 + | merlon | NixOS x86_64 | desktop | Desktop with Nvidia GPU, Wayland (Niri), FIDO2 disk encryption | 42 + | merlow | NixOS x86_64 | headless | Hetzner VPS, headless server | 43 + | watt | NixOS x86_64 | headless | Homelab MacBook Pro, headless | 44 + | nolrem | nix-darwin aarch64 | laptop | MacBook Air | 45 + | FH91CFY4QP-2 | nix-darwin aarch64 | laptop | Work MacBook, uses `alebat01` user | 46 + 47 + Shared darwin config lives in `hosts/darwin.nix`. 44 48 45 - ### Home Manager (`/home/`) 49 + ### Modules (`/modules/`) 46 50 47 - Two user profiles with layered configuration: 51 + Reusable modules organised by module system: 48 52 49 - - **bates64/cli/** - Base configuration for all machines (shell, git, rust, cpp) 50 - - **bates64/gui/** - Extends cli with desktop apps (browser, terminal, window manager) 51 - - **alebat01/** - Work user, imports shared cli/gui modules 53 + - **`modules/system/`** - NixOS and nix-darwin system modules (auto-upgrade, gc, nixvim, tailscale, factorio, matchbox, minecraft, focus-follows-mouse). Darwin-only modules use `lib.mkIf pkgs.stdenv.isDarwin`. 54 + - **`modules/home/`** - Home-manager modules (shell, git, rust, cpp, ghostty, niri, hammerspoon, zed, browser, etc.) 55 + - **`modules/home/profiles/`** - Chained profiles that compose home modules: 56 + - `headless.nix` - CLI tools (shell, git, rust, cpp, caches). Defines the `isMacOS` option. 57 + - `desktop.nix` - Imports headless + GUI apps (niri, ghostty, zed, browser, vscode) 58 + - `laptop.nix` - Imports desktop + hammerspoon (macOS window management) 52 59 53 - **Key pattern:** The `isMacOS` option (defined in `home/bates64/cli/default.nix`) allows conditional logic for cross-platform configs: 60 + Hosts import modules à la carte. The `isMacOS` option allows conditional logic for cross-platform configs: 54 61 ```nix 55 62 if config.isMacOS then [ ] else [ pkgs.mold ] 56 63 ``` 57 64 58 - ### System Modules 59 - 60 - - `/tasks/` - Shared NixOS modules 61 - - `/programs/` - System-wide programs 62 - - `/services/` - Server services 63 - 64 65 ### Flake Structure 65 66 66 67 The `flake.nix` defines: ··· 68 69 - `darwinConfigurations` for macOS hosts 69 70 - `homeConfigurations` for standalone home-manager 70 71 71 - Inputs are passed to modules via `extraSpecialArgs = { inherit inputs; }`. 72 + Inputs are passed to modules via `specialArgs = { inherit inputs; }`.
+8 -128
flake.nix
··· 60 60 outputs = 61 61 { 62 62 nixpkgs, 63 - minegrub-world-sel-theme, 64 - minecraft-plymouth-theme, 65 63 home-manager, 66 64 nix-darwin, 67 - nixvim, 68 - vscode-server, 69 65 nixgl, 70 - disko, 71 - nix-minecraft, 72 66 ... 73 67 }@inputs: 74 68 let ··· 84 78 }; 85 79 in 86 80 { 87 - # 88 81 nixosConfigurations = { 89 - # PC 82 + # Desktop PC 90 83 merlon = nixpkgs.lib.nixosSystem { 91 84 system = "x86_64-linux"; 92 85 pkgs = pkgs-x86_64; 86 + specialArgs = { inherit inputs; }; 93 87 modules = [ 94 88 ./hosts/merlon/configuration.nix 95 - ./tasks/auto-upgrade.nix 96 - ./tasks/gc.nix 97 - minegrub-world-sel-theme.nixosModules.default 98 - minecraft-plymouth-theme.nixosModules.default 99 - disko.nixosModules.disko 100 - 101 - { 102 - programs.nix-ld.enable = true; 103 - } 104 - 105 - # Splash 106 - { 107 - boot = { 108 - plymouth = { 109 - enable = true; 110 - plymouth-minecraft-theme.enable = true; 111 - }; 112 - 113 - # Enable "Silent boot" 114 - consoleLogLevel = 3; 115 - initrd.verbose = false; 116 - kernelParams = [ 117 - "quiet" 118 - "splash" 119 - "boot.shell_on_fail" 120 - "udev.log_priority=3" 121 - "rd.systemd.show_status=auto" 122 - ]; 123 - }; 124 - } 125 - 126 89 home-manager.nixosModules.home-manager 127 - { 128 - home-manager.useGlobalPkgs = true; 129 - home-manager.useUserPackages = true; 130 - home-manager.users.bates64 = ./home/bates64/gui; 131 - home-manager.backupCommand = "rm"; 132 - home-manager.extraSpecialArgs = { inherit inputs; }; 133 - } 134 - 135 - nixvim.nixosModules.nixvim 136 - ./programs/nixvim.nix 137 - 138 - vscode-server.nixosModules.default 139 - { 140 - services.vscode-server.enable = true; 141 - } 142 - 143 - ./services/tailscale.nix 144 90 ]; 145 91 }; 146 92 # Hetzner VPS 147 93 merlow = nixpkgs.lib.nixosSystem { 148 94 system = "x86_64-linux"; 149 95 pkgs = pkgs-x86_64; 96 + specialArgs = { inherit inputs; }; 150 97 modules = [ 151 98 ./hosts/merlow/configuration.nix 152 - ./tasks/auto-upgrade.nix 153 - ./tasks/gc.nix 154 - 155 99 home-manager.nixosModules.home-manager 156 - { 157 - home-manager.useGlobalPkgs = true; 158 - home-manager.useUserPackages = true; 159 - home-manager.users.bates64 = ./home/bates64/cli; 160 - } 161 - 162 - nixvim.nixosModules.nixvim 163 - ./programs/nixvim.nix 164 - 165 - vscode-server.nixosModules.default 166 - { 167 - services.vscode-server.enable = true; 168 - } 169 - 170 - nix-minecraft.nixosModules.minecraft-servers 171 - { 172 - nixpkgs.overlays = [ nix-minecraft.overlay ]; 173 - } 174 - 175 - ./services/factorio.nix 176 - #./services/wua-mediawiki.nix # FIXME extensions should use git 177 - ./services/matchbox.nix 178 - ./services/minecraft/vanilla.nix 179 - ./services/minecraft/gtnh 180 - 181 - ./services/tailscale.nix 182 100 ]; 183 101 }; 184 102 # Homelab 185 103 watt = nixpkgs.lib.nixosSystem { 186 104 system = "x86_64-linux"; 187 105 pkgs = pkgs-x86_64; 106 + specialArgs = { inherit inputs; }; 188 107 modules = [ 189 - disko.nixosModules.disko 190 108 ./hosts/watt/configuration.nix 191 - ./tasks/auto-upgrade.nix 192 - ./tasks/gc.nix 193 - 194 109 home-manager.nixosModules.home-manager 195 - { 196 - home-manager.useGlobalPkgs = true; 197 - home-manager.useUserPackages = true; 198 - home-manager.users.bates64 = ./home/bates64/cli; 199 - } 200 - 201 - nixvim.nixosModules.nixvim 202 - ./programs/nixvim.nix 203 - 204 - ./services/tailscale.nix 205 110 ]; 206 111 }; 207 112 }; 208 113 209 - # Laptops 210 114 darwinConfigurations = { 211 - # Macbook Air 15 115 + # MacBook Air 15 212 116 nolrem = nix-darwin.lib.darwinSystem { 213 117 pkgs = pkgs-aarch64-darwin; 118 + specialArgs = { inherit inputs; }; 214 119 modules = [ 215 120 ./hosts/nolrem/configuration.nix 216 - ./hosts/darwin.nix 217 - 218 121 home-manager.darwinModules.home-manager 219 - { 220 - home-manager.useGlobalPkgs = true; 221 - home-manager.useUserPackages = true; 222 - home-manager.users.bates64 = 223 - { ... }: 224 - { 225 - imports = [ ./home/bates64/gui ]; 226 - isMacOS = true; 227 - }; 228 - home-manager.extraSpecialArgs = { inherit inputs; }; 229 - } 230 122 ]; 231 123 }; 232 - # (Work) Macbook Pro 124 + # (Work) MacBook Pro 233 125 "FH91CFY4QP-2" = nix-darwin.lib.darwinSystem { 234 126 pkgs = pkgs-aarch64-darwin; 127 + specialArgs = { inherit inputs; }; 235 128 modules = [ 236 129 ./hosts/work-mbp/configuration.nix 237 - ./hosts/darwin.nix 238 - 239 130 home-manager.darwinModules.home-manager 240 - { 241 - home-manager.useGlobalPkgs = true; 242 - home-manager.useUserPackages = true; 243 - home-manager.users.alebat01 = 244 - { ... }: 245 - { 246 - imports = [ ./home/alebat01/home.nix ]; 247 - isMacOS = true; 248 - }; 249 - home-manager.extraSpecialArgs = { inherit inputs; }; 250 - } 251 131 ]; 252 132 }; 253 133 };
+1 -2
home/alebat01/home.nix
··· 2 2 { 3 3 imports = [ 4 4 ./ssh.nix 5 - ../bates64/cli 6 - ../bates64/gui 5 + ../../modules/home/profiles/desktop.nix 7 6 ]; 8 7 config = { 9 8 home.username = "alebat01";
home/bates64/cli/caches.nix modules/home/caches.nix
home/bates64/cli/cpp/default.nix modules/home/cpp/default.nix
+6 -6
home/bates64/cli/default.nix modules/home/profiles/headless.nix
··· 1 1 { lib, config, ... }: 2 2 { 3 3 imports = [ 4 - ./shell 5 - ./git.nix 6 - ./caches.nix 7 - #./tmux.nix 8 - ./rust 9 - ./cpp 4 + ../shell 5 + ../git.nix 6 + ../caches.nix 7 + #../tmux.nix 8 + ../rust 9 + ../cpp 10 10 ]; 11 11 options = { 12 12 isMacOS = lib.mkOption {
home/bates64/cli/git.nix modules/home/git.nix
home/bates64/cli/gitignore modules/home/gitignore
home/bates64/cli/rust/config.toml modules/home/rust/config.toml
home/bates64/cli/rust/default.nix modules/home/rust/default.nix
home/bates64/cli/shell/default.nix modules/home/shell/default.nix
home/bates64/cli/shell/p10k.zsh modules/home/shell/p10k.zsh
home/bates64/cli/tmux.nix modules/home/tmux.nix
home/bates64/gui/browser.nix modules/home/browser.nix
+6 -9
home/bates64/gui/default.nix modules/home/profiles/desktop.nix
··· 5 5 ... 6 6 }: 7 7 let 8 - # on macOS, override ares so that `ares` works in the shell 9 8 ares-wrapped = 10 9 if config.isMacOS then 11 10 pkgs.ares.overrideAttrs (oldAttrs: { ··· 19 18 in 20 19 { 21 20 imports = [ 22 - ../cli 23 - ./gl.nix 24 - ./niri 25 - ./hammerspoon 26 - ./ghostty 27 - ./zed.nix 28 - ./browser.nix 21 + ./headless.nix 22 + ../gl.nix 23 + ../niri 24 + ../ghostty 25 + ../zed.nix 26 + ../browser.nix 29 27 ]; 30 28 31 29 programs.vscode = { ··· 64 62 aseprite # TODO: maintain darwin package 65 63 ] 66 64 ); 67 - 68 65 }
home/bates64/gui/discord/README.md modules/home/discord/README.md
home/bates64/gui/discord/default.nix modules/home/discord/default.nix
home/bates64/gui/discord/krisp-patcher.py modules/home/discord/krisp-patcher.py
home/bates64/gui/ghostty/bettercrt.glsl modules/home/ghostty/bettercrt.glsl
home/bates64/gui/ghostty/bloom.glsl modules/home/ghostty/bloom.glsl
home/bates64/gui/ghostty/cursor_warp.glsl modules/home/ghostty/cursor_warp.glsl
home/bates64/gui/ghostty/default.nix modules/home/ghostty/default.nix
home/bates64/gui/ghostty/glitchy.glsl modules/home/ghostty/glitchy.glsl
home/bates64/gui/gl.nix modules/home/gl.nix
home/bates64/gui/hammerspoon/default.nix modules/home/hammerspoon/default.nix
home/bates64/gui/hammerspoon/init.lua modules/home/hammerspoon/init.lua
home/bates64/gui/niri/config.kdl modules/home/niri/config.kdl
home/bates64/gui/niri/default.nix modules/home/niri/default.nix
home/bates64/gui/zed.nix modules/home/zed.nix
+1 -1
hosts/darwin.nix
··· 1 1 { 2 2 imports = [ 3 - ../services/darwin/focus-follows-mouse.nix 3 + ../modules/system/focus-follows-mouse.nix 4 4 ]; 5 5 6 6 system.defaults.NSGlobalDomain.AppleFontSmoothing = 0; # https://tonsky.me/blog/monitors/
+36 -2
hosts/merlon/configuration.nix
··· 8 8 config, 9 9 pkgs, 10 10 lib, 11 + inputs, 11 12 ... 12 13 }: 13 14 ··· 18 19 imports = [ 19 20 ./disko.nix 20 21 #./8bitdo.nix 22 + ../../modules/system/auto-upgrade.nix 23 + ../../modules/system/gc.nix 24 + ../../modules/system/nixvim.nix 25 + ../../modules/system/tailscale.nix 26 + inputs.minegrub-world-sel-theme.nixosModules.default 27 + inputs.minecraft-plymouth-theme.nixosModules.default 28 + inputs.disko.nixosModules.disko 29 + inputs.nixvim.nixosModules.nixvim 30 + inputs.vscode-server.nixosModules.default 21 31 ]; 32 + 33 + programs.nix-ld.enable = true; 34 + services.vscode-server.enable = true; 35 + 36 + boot.plymouth = { 37 + enable = true; 38 + plymouth-minecraft-theme.enable = true; 39 + }; 40 + boot.consoleLogLevel = 3; 41 + boot.initrd.verbose = false; 42 + boot.kernelParams = [ 43 + "quiet" 44 + "splash" 45 + "boot.shell_on_fail" 46 + "udev.log_priority=3" 47 + "rd.systemd.show_status=auto" 48 + "nvidia.NVreg_PreserveVideoMemoryAllocations=1" 49 + ]; 50 + 51 + home-manager = { 52 + useGlobalPkgs = true; 53 + useUserPackages = true; 54 + users.bates64 = ../../modules/home/profiles/desktop.nix; 55 + backupCommand = "rm"; 56 + extraSpecialArgs = { inherit inputs; }; 57 + }; 22 58 23 59 boot.loader.grub = { 24 60 enable = true; ··· 210 246 forceFullCompositionPipeline = true; # Fixes tearing 211 247 package = config.boot.kernelPackages.nvidiaPackages.stable; 212 248 }; 213 - 214 - boot.kernelParams = [ "nvidia.NVreg_PreserveVideoMemoryAllocations=1" ]; 215 249 216 250 boot.extraModulePackages = 217 251 with config.boot.kernelPackages;
+22
hosts/merlow/configuration.nix
··· 2 2 config, 3 3 lib, 4 4 pkgs, 5 + inputs, 5 6 ... 6 7 }: 7 8 8 9 { 9 10 imports = [ 10 11 ./hardware-configuration.nix 12 + ../../modules/system/auto-upgrade.nix 13 + ../../modules/system/gc.nix 14 + ../../modules/system/nixvim.nix 15 + ../../modules/system/tailscale.nix 16 + ../../modules/system/factorio.nix 17 + #../../modules/system/wua-mediawiki.nix # FIXME extensions should use git 18 + ../../modules/system/matchbox.nix 19 + ../../modules/system/minecraft/vanilla.nix 20 + ../../modules/system/minecraft/gtnh 21 + inputs.nixvim.nixosModules.nixvim 22 + inputs.vscode-server.nixosModules.default 23 + inputs.nix-minecraft.nixosModules.minecraft-servers 11 24 ]; 25 + 26 + services.vscode-server.enable = true; 27 + nixpkgs.overlays = [ inputs.nix-minecraft.overlay ]; 28 + 29 + home-manager = { 30 + useGlobalPkgs = true; 31 + useUserPackages = true; 32 + users.bates64 = ../../modules/home/profiles/headless.nix; 33 + }; 12 34 13 35 # Use the GRUB 2 boot loader. 14 36 boot.loader.grub.enable = true;
+17 -1
hosts/nolrem/configuration.nix
··· 1 - { pkgs, ... }: 1 + { pkgs, inputs, ... }: 2 2 { 3 + imports = [ 4 + ../darwin.nix 5 + ]; 6 + 7 + home-manager = { 8 + useGlobalPkgs = true; 9 + useUserPackages = true; 10 + users.bates64 = 11 + { ... }: 12 + { 13 + imports = [ ../../modules/home/profiles/laptop.nix ]; 14 + isMacOS = true; 15 + }; 16 + extraSpecialArgs = { inherit inputs; }; 17 + }; 18 + 3 19 # List packages installed in system profile. To search by name, run: 4 20 # $ nix-env -qaP | grep wget 5 21 environment.systemPackages = [
+13
hosts/watt/configuration.nix
··· 2 2 config, 3 3 lib, 4 4 pkgs, 5 + inputs, 5 6 modulesPath, 6 7 ... 7 8 }: ··· 10 11 imports = [ 11 12 ./disko.nix 12 13 (modulesPath + "/hardware/network/broadcom-43xx.nix") 14 + ../../modules/system/auto-upgrade.nix 15 + ../../modules/system/gc.nix 16 + ../../modules/system/nixvim.nix 17 + ../../modules/system/tailscale.nix 18 + inputs.disko.nixosModules.disko 19 + inputs.nixvim.nixosModules.nixvim 13 20 ]; 21 + 22 + home-manager = { 23 + useGlobalPkgs = true; 24 + useUserPackages = true; 25 + users.bates64 = ../../modules/home/profiles/headless.nix; 26 + }; 14 27 15 28 # Hardware 16 29 boot.initrd.availableKernelModules = [
+17 -1
hosts/work-mbp/configuration.nix
··· 1 - { pkgs, ... }: 1 + { pkgs, inputs, ... }: 2 2 { 3 + imports = [ 4 + ../darwin.nix 5 + ]; 6 + 7 + home-manager = { 8 + useGlobalPkgs = true; 9 + useUserPackages = true; 10 + users.alebat01 = 11 + { ... }: 12 + { 13 + imports = [ ../../home/alebat01/home.nix ]; 14 + isMacOS = true; 15 + }; 16 + extraSpecialArgs = { inherit inputs; }; 17 + }; 18 + 3 19 # List packages installed in system profile. To search by name, run: 4 20 # $ nix-env -qaP | grep wget 5 21 environment.systemPackages = [
+6
modules/home/profiles/laptop.nix
··· 1 + { 2 + imports = [ 3 + ./desktop.nix 4 + ../hammerspoon 5 + ]; 6 + }
+31
modules/system/focus-follows-mouse.nix
··· 1 + { 2 + config, 3 + lib, 4 + pkgs, 5 + ... 6 + }: 7 + let 8 + autoraise = pkgs.autoraise.overrideAttrs (old: { 9 + buildPhase = '' 10 + runHook preBuild 11 + $CXX -std=c++03 -fobjc-arc -D"NS_FORMAT_ARGUMENT(A)=" -D"SKYLIGHT_AVAILABLE=1" -DEXPERIMENTAL_FOCUS_FIRST -o AutoRaise AutoRaise.mm -framework AppKit -framework SkyLight 12 + bash create-app-bundle.sh 13 + runHook postBuild 14 + ''; 15 + }); 16 + in 17 + { 18 + config = lib.mkIf pkgs.stdenv.isDarwin { 19 + environment.systemPackages = [ autoraise ]; 20 + 21 + launchd.user.agents.autoraise = { 22 + command = "${autoraise}/bin/autoraise -delay 0 -focusDelay 1"; 23 + serviceConfig = { 24 + KeepAlive = true; 25 + RunAtLoad = true; 26 + StandardOutPath = "/tmp/autoraise.log"; 27 + StandardErrorPath = "/tmp/autoraise.err.log"; 28 + }; 29 + }; 30 + }; 31 + }
programs/nixvim.nix modules/system/nixvim.nix
-29
services/darwin/focus-follows-mouse.nix
··· 1 - { 2 - config, 3 - lib, 4 - pkgs, 5 - ... 6 - }: 7 - let 8 - autoraise = pkgs.autoraise.overrideAttrs (old: { 9 - buildPhase = '' 10 - runHook preBuild 11 - $CXX -std=c++03 -fobjc-arc -D"NS_FORMAT_ARGUMENT(A)=" -D"SKYLIGHT_AVAILABLE=1" -DEXPERIMENTAL_FOCUS_FIRST -o AutoRaise AutoRaise.mm -framework AppKit -framework SkyLight 12 - bash create-app-bundle.sh 13 - runHook postBuild 14 - ''; 15 - }); 16 - in 17 - { 18 - environment.systemPackages = [ autoraise ]; 19 - 20 - launchd.user.agents.autoraise = { 21 - command = "${autoraise}/bin/autoraise -delay 0 -focusDelay 1"; 22 - serviceConfig = { 23 - KeepAlive = true; 24 - RunAtLoad = true; 25 - StandardOutPath = "/tmp/autoraise.log"; 26 - StandardErrorPath = "/tmp/autoraise.err.log"; 27 - }; 28 - }; 29 - }
services/factorio.nix modules/system/factorio.nix
services/matchbox.nix modules/system/matchbox.nix
services/minecraft/gtnh/default.nix modules/system/minecraft/gtnh/default.nix
services/minecraft/gtnh/gtnh.nix modules/system/minecraft/gtnh/gtnh.nix
services/minecraft/vanilla.nix modules/system/minecraft/vanilla.nix
services/minecraft/whitelist.nix modules/system/minecraft/whitelist.nix
services/tailscale.nix modules/system/tailscale.nix
services/wua-mediawiki.nix modules/system/wua-mediawiki.nix
tasks/auto-upgrade.nix modules/system/auto-upgrade.nix
tasks/gc.nix modules/system/gc.nix