From 8d19be95277434a90234d25315620c1b2b6f8d30 Mon Sep 17 00:00:00 2001 From: aaron Date: Fri, 2 Oct 2026 09:25:40 +0200 Subject: [PATCH] refactor: fold host-only modules into the hosts - argon owns its gpu settings, calibre and the luks drives, now generated from one table - claudecode.nix is gone, claude-code lives in packages.nix - home-manager options live next to the home-manager wiring in flake.nix - settings.nix: one nix block, extra-substituters instead of repeating the cache.nixos.org defaults - README: current layout Co-Authored-By: Claude Opus 5.5 --- README.md | 20 +++++++------- flake.nix | 3 +++ hosts/argon/configuration.nix | 50 +++++++++++++++++++++++++++++------ hosts/neon/configuration.nix | 6 +---- modules/nixos/calibre.nix | 8 ------ modules/nixos/claudecode.nix | 7 ----- modules/nixos/drives.nix | 45 ------------------------------- modules/nixos/graphics.nix | 17 ------------ modules/nixos/settings.nix | 35 +++++++----------------- 9 files changed, 65 insertions(+), 126 deletions(-) delete mode 100644 modules/nixos/calibre.nix delete mode 100644 modules/nixos/claudecode.nix delete mode 100644 modules/nixos/drives.nix delete mode 100644 modules/nixos/graphics.nix diff --git a/README.md b/README.md index 02e8484..cb1307c 100644 --- a/README.md +++ b/README.md @@ -6,20 +6,20 @@ My personal NixOS configurations. ```bash . -├── flake.lock -├── flake.nix # flake definition +├── flake.nix # hosts and home-manager wiring ├── hosts -│   └── neon -│   ├── configuration.nix # import nix-modules for specific host -│   └── hardware-configuration.nix # hardware configs for specific host +│ ├── argon # desktop +│ ├── neon # laptop +│ └── default # test vm +│ ├── configuration.nix # host-specific settings and module imports +│ ├── hardware-configuration.nix # generated by nixos-generate-config +│ └── niri.nix # host-specific niri settings (outputs, input) ├── modules -│   ├── home-manager -│   │   ├── xyz_module.nix -│   └── nixos -│   └── xyz_module.nix +│ ├── home-manager # user modules, imported by users/aaron/home.nix +│ └── nixos # system modules, imported by the hosts └── users └── aaron - └── home.nix # import home-manager modules for specific user + └── home.nix # imports home-manager modules ``` ## installation diff --git a/flake.nix b/flake.nix index 37cba33..cf7edb1 100644 --- a/flake.nix +++ b/flake.nix @@ -35,6 +35,9 @@ ./hosts/${hostName}/configuration.nix home-manager.nixosModules.home-manager { + home-manager.useGlobalPkgs = true; + home-manager.useUserPackages = true; + home-manager.backupCommand = "mv -f {file} {file}.hm-bak-$(date +%Y%m%d%H%M%S)"; home-manager.extraSpecialArgs = { inherit inputs; }; home-manager.users.aaron.imports = [ nixvim.homeModules.nixvim diff --git a/hosts/argon/configuration.nix b/hosts/argon/configuration.nix index 5a44438..f12c342 100644 --- a/hosts/argon/configuration.nix +++ b/hosts/argon/configuration.nix @@ -1,15 +1,25 @@ +# argon: desktop with an amd gpu and three luks-encrypted data drives. +# The drives are unlocked in the initrd with keyfiles from /etc/nixos/keys. + +{ lib, pkgs, ... }: + +let + # luks name -> partition uuid, mounted at /mnt/ + drives = { + data1 = "dfae62cc-bad1-4879-bf9a-461bde833625"; + data2 = "8312edae-9247-481b-a313-52a7f848f027"; + nvmecache = "2352250e-4ebe-4f9a-bf66-0d4aaa961bd8"; + }; + key = name: "/etc/nixos/keys/${name}.key"; +in { imports = [ ../../modules/nixos/appimage.nix ../../modules/nixos/astro.nix ../../modules/nixos/audio.nix ../../modules/nixos/bootloader.nix - ../../modules/nixos/calibre.nix ../../modules/nixos/certificates.nix - ../../modules/nixos/claudecode.nix - ../../modules/nixos/drives.nix ../../modules/nixos/gnupg.nix - ../../modules/nixos/graphics.nix ../../modules/nixos/greetd.nix ../../modules/nixos/locales.nix ../../modules/nixos/networking.nix @@ -29,9 +39,33 @@ # host-specific niri config (outputs, input devices) home-manager.users.aaron.imports = [ ./niri.nix ]; - # set hostname - networking.hostName = "argon"; + # amd gpu: mesa/vulkan, and amdgpu in the initrd for plymouth + hardware.graphics = { + enable = true; + enable32Bit = true; + }; + hardware.amdgpu.initrd.enable = true; - # install state version - system.stateVersion = "25.11"; # Don't change + # encrypted data drives + boot.initrd.secrets = lib.mapAttrs' (name: _: lib.nameValuePair (key name) (key name)) drives; + boot.initrd.luks.devices = lib.mapAttrs (name: uuid: { + device = "/dev/disk/by-uuid/${uuid}"; + keyFile = key name; + }) drives; + fileSystems = lib.mapAttrs' ( + name: _: + lib.nameValuePair "/mnt/${name}" { + device = "/dev/mapper/${name}"; + fsType = "ext4"; + options = [ "nofail" ]; + } + ) drives; + + environment.systemPackages = with pkgs; [ + amdgpu_top + calibre # ebook management and kobo syncing + ]; + + networking.hostName = "argon"; + system.stateVersion = "25.11"; # don't change } diff --git a/hosts/neon/configuration.nix b/hosts/neon/configuration.nix index 2b9a93a..8febcdb 100644 --- a/hosts/neon/configuration.nix +++ b/hosts/neon/configuration.nix @@ -5,7 +5,6 @@ ../../modules/nixos/audio.nix ../../modules/nixos/bootloader.nix ../../modules/nixos/certificates.nix - ../../modules/nixos/claudecode.nix ../../modules/nixos/docker.nix ../../modules/nixos/gnupg.nix ../../modules/nixos/locales.nix @@ -26,9 +25,6 @@ # host-specific niri config (input devices, laptop binds) home-manager.users.aaron.imports = [ ./niri.nix ]; - # set hostname networking.hostName = "neon"; - - # install state version - system.stateVersion = "25.11"; # Don't change + system.stateVersion = "25.11"; # don't change } diff --git a/modules/nixos/calibre.nix b/modules/nixos/calibre.nix deleted file mode 100644 index 5e42588..0000000 --- a/modules/nixos/calibre.nix +++ /dev/null @@ -1,8 +0,0 @@ -{ pkgs, ... }: - -{ - # install calibre for ebook management and kobo syncing - environment.systemPackages = with pkgs; [ - calibre - ]; -} diff --git a/modules/nixos/claudecode.nix b/modules/nixos/claudecode.nix deleted file mode 100644 index c1b1097..0000000 --- a/modules/nixos/claudecode.nix +++ /dev/null @@ -1,7 +0,0 @@ -{ pkgs, ... }: - -{ - environment.systemPackages = with pkgs; [ - claude-code - ]; -} diff --git a/modules/nixos/drives.nix b/modules/nixos/drives.nix deleted file mode 100644 index d7a3dce..0000000 --- a/modules/nixos/drives.nix +++ /dev/null @@ -1,45 +0,0 @@ -# Add encrypted drives to argon - -{ - # copy keyfiles into initrd to make them available during early boot - boot.initrd.secrets = { - "/etc/nixos/keys/data1.key" = "/etc/nixos/keys/data1.key"; - "/etc/nixos/keys/data2.key" = "/etc/nixos/keys/data2.key"; - "/etc/nixos/keys/nvmecache.key" = "/etc/nixos/keys/nvmecache.key"; - }; - - # decrypt data drives with keyfiles for argon - boot.initrd.luks.devices = { - "data1" = { - device = "/dev/disk/by-uuid/dfae62cc-bad1-4879-bf9a-461bde833625"; - keyFile = "/etc/nixos/keys/data1.key"; - }; - "data2" = { - device = "/dev/disk/by-uuid/8312edae-9247-481b-a313-52a7f848f027"; - keyFile = "/etc/nixos/keys/data2.key"; - }; - "nvmecache" = { - device = "/dev/disk/by-uuid/2352250e-4ebe-4f9a-bf66-0d4aaa961bd8"; - keyFile = "/etc/nixos/keys/nvmecache.key"; - }; - }; - - # mount decrypted filesystems - fileSystems."/mnt/data1" = { - device = "/dev/mapper/data1"; - fsType = "ext4"; - options = [ "nofail" ]; - }; - - fileSystems."/mnt/data2" = { - device = "/dev/mapper/data2"; - fsType = "ext4"; - options = [ "nofail" ]; - }; - - fileSystems."/mnt/nvmecache" = { - device = "/dev/mapper/nvmecache"; - fsType = "ext4"; - options = [ "nofail" ]; - }; -} diff --git a/modules/nixos/graphics.nix b/modules/nixos/graphics.nix deleted file mode 100644 index ade9567..0000000 --- a/modules/nixos/graphics.nix +++ /dev/null @@ -1,17 +0,0 @@ -{ pkgs, ... }: - -{ - # enable amd GPU acceleration (mesa, vulkan, egl) - hardware.graphics = { - enable = true; - enable32Bit = true; - }; - - # install amdgpu_top - environment.systemPackages = with pkgs; [ - amdgpu_top - ]; - - # add amdgpu to the initrd for plymouth - hardware.amdgpu.initrd.enable = true; -} diff --git a/modules/nixos/settings.nix b/modules/nixos/settings.nix index b09a9a3..2f46fe7 100644 --- a/modules/nixos/settings.nix +++ b/modules/nixos/settings.nix @@ -1,31 +1,25 @@ { nix = { - # nix settings settings = { - # enable flakes and nix-command experimental-features = [ "nix-command" "flakes" ]; - # auto-optimize my nix-store auto-optimise-store = true; - # use all cores + # parallel builds, each using all cores max-jobs = "auto"; - # use all available cores per job cores = 0; - # add trusted substituters (binary caches) - substituters = [ - "https://cache.nixos.org" - "https://nix-community.cachix.org" - ]; - # add keys - trusted-public-keys = [ - "cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY=" + # cache.nixos.org is the default, these come on top + extra-substituters = [ "https://nix-community.cachix.org" ]; + extra-trusted-public-keys = [ "nix-community.cachix.org-1:mB9FSh9qf2dCimDSUo8Zy7bkq5CX+/rkCWyvRCYg3Fs=" ]; + trusted-users = [ + "root" + "@wheel" + ]; }; - # enable automatic garbage collection gc = { automatic = true; dates = "weekly"; @@ -33,20 +27,9 @@ }; }; - # add trusted users (able to modify the nix store) - nix.settings.trusted-users = [ - "root" - "@wheel" - ]; - - # allow unfree packages (steam, protonvpn, discord, etc.) + # steam, protonvpn, discord, etc. nixpkgs.config.allowUnfree = true; # links /libexec from derivations to /run/current-system/sw environment.pathsToLink = [ "/libexec" ]; - - # enable home-manager globally - home-manager.useGlobalPkgs = true; - home-manager.useUserPackages = true; - home-manager.backupCommand = "mv -f {file} {file}.hm-bak-$(date +%Y%m%d%H%M%S)"; }