From ec1c0fba56978b6bf1df3dda336db6bd8ae7c10d Mon Sep 17 00:00:00 2001 From: alexion Date: Wed, 7 Oct 2026 16:59:03 -0400 Subject: [PATCH] refactor(nixos): organize host modules --- configs/nixos/AGENTS.md | 1 + configs/nixos/hosts/neogaia/default.nix | 2 +- configs/nixos/hosts/pikachu/default.nix | 2 +- configs/nixos/hosts/zeus/default.nix | 2 +- configs/nixos/modules/{kernel => host}/cachyos.nix | 4 ++-- configs/nixos/modules/{host.nix => host/default.nix} | 4 ++-- configs/nixos/modules/{ => host}/zfs.nix | 4 ++-- 7 files changed, 10 insertions(+), 9 deletions(-) rename configs/nixos/modules/{kernel => host}/cachyos.nix (68%) rename configs/nixos/modules/{host.nix => host/default.nix} (96%) rename configs/nixos/modules/{ => host}/zfs.nix (95%) diff --git a/configs/nixos/AGENTS.md b/configs/nixos/AGENTS.md index 15d032d..cd8c10f 100644 --- a/configs/nixos/AGENTS.md +++ b/configs/nixos/AGENTS.md @@ -63,3 +63,4 @@ Generate it on the target system or live ISO, then stage it before evaluating the flake. - Configure the Chaotic Nyx cache only on hosts that select `linuxPackages_cachyos` (currently Neogaia and Zeus), not in the generic host module. +- Module-relative paths resolve from the module file. Update them when moving a module into a subdirectory. diff --git a/configs/nixos/hosts/neogaia/default.nix b/configs/nixos/hosts/neogaia/default.nix index a069dcd..1cfe0ae 100644 --- a/configs/nixos/hosts/neogaia/default.nix +++ b/configs/nixos/hosts/neogaia/default.nix @@ -12,7 +12,7 @@ ./disk.nix ]; - modules.kernel.cachyos.enable = true; + modules.host.cachyos.enable = true; # So wifi can be joined from the console. networking.networkmanager.enable = true; diff --git a/configs/nixos/hosts/pikachu/default.nix b/configs/nixos/hosts/pikachu/default.nix index a36bb26..bff75e9 100644 --- a/configs/nixos/hosts/pikachu/default.nix +++ b/configs/nixos/hosts/pikachu/default.nix @@ -58,7 +58,7 @@ boot.zfs.forceImportRoot = false; - modules.zfs = { + modules.host.zfs = { enable = true; pools.pikachu = { }; }; diff --git a/configs/nixos/hosts/zeus/default.nix b/configs/nixos/hosts/zeus/default.nix index f1ee3f6..9e49cd8 100644 --- a/configs/nixos/hosts/zeus/default.nix +++ b/configs/nixos/hosts/zeus/default.nix @@ -14,7 +14,7 @@ nixpkgs.hostPlatform = "x86_64-linux"; - modules.kernel.cachyos.enable = true; + modules.host.cachyos.enable = true; hardware.graphics = { enable = true; diff --git a/configs/nixos/modules/kernel/cachyos.nix b/configs/nixos/modules/host/cachyos.nix similarity index 68% rename from configs/nixos/modules/kernel/cachyos.nix rename to configs/nixos/modules/host/cachyos.nix index b590507..705b186 100644 --- a/configs/nixos/modules/kernel/cachyos.nix +++ b/configs/nixos/modules/host/cachyos.nix @@ -5,9 +5,9 @@ ... }: { - options.modules.kernel.cachyos.enable = lib.mkEnableOption "CachyOS kernel"; + options.modules.host.cachyos.enable = lib.mkEnableOption "CachyOS kernel"; - config = lib.mkIf config.modules.kernel.cachyos.enable { + config = lib.mkIf config.modules.host.cachyos.enable { boot.kernelPackages = pkgs.linuxPackages_cachyos; nix.settings.extra-substituters = [ "https://nyx-cache.chaotic.cx/" ]; diff --git a/configs/nixos/modules/host.nix b/configs/nixos/modules/host/default.nix similarity index 96% rename from configs/nixos/modules/host.nix rename to configs/nixos/modules/host/default.nix index 6c5ccee..8961f0d 100644 --- a/configs/nixos/modules/host.nix +++ b/configs/nixos/modules/host/default.nix @@ -5,7 +5,7 @@ ... }: let - hostSecrets = ../secrets + "/${config.networking.hostName}.yaml"; + hostSecrets = ../../secrets + "/${config.networking.hostName}.yaml"; in { options.modules.host.enable = lib.mkEnableOption "physical host configuration"; @@ -33,7 +33,7 @@ in services.xserver.xkb.options = "caps:escape_shifted_capslock"; console.useXkbConfig = true; - sops.defaultSopsFile = ../secrets/shared.yaml; + sops.defaultSopsFile = ../../secrets/shared.yaml; sops.age.keyFile = "/var/lib/sops-nix/key.txt"; sops.age.sshKeyPaths = [ ]; sops.gnupg.sshKeyPaths = [ ]; diff --git a/configs/nixos/modules/zfs.nix b/configs/nixos/modules/host/zfs.nix similarity index 95% rename from configs/nixos/modules/zfs.nix rename to configs/nixos/modules/host/zfs.nix index 0c8eb5f..794e616 100644 --- a/configs/nixos/modules/zfs.nix +++ b/configs/nixos/modules/host/zfs.nix @@ -5,10 +5,10 @@ }: # The host-level ZFS pool import: durable service state a host mounts, never rebuilds. let - cfg = config.modules.zfs; # NOLINT(let_order) + cfg = config.modules.host.zfs; # NOLINT(let_order) in { - options.modules.zfs = { + options.modules.host.zfs = { enable = lib.mkEnableOption "importing durable ZFS pools that hold service state"; pools = lib.mkOption {