From 1f2f1a79adbe40c4b4916a10ff1717bea5834c58 Mon Sep 17 00:00:00 2001 From: alexion Date: Wed, 7 Oct 2026 16:51:56 -0400 Subject: [PATCH 1/2] refactor(nixos): derive ZFS host IDs --- configs/nixos/hosts/pikachu/default.nix | 1 - configs/nixos/modules/zfs.nix | 18 ++++-------------- 2 files changed, 4 insertions(+), 15 deletions(-) diff --git a/configs/nixos/hosts/pikachu/default.nix b/configs/nixos/hosts/pikachu/default.nix index 06845e7..a36bb26 100644 --- a/configs/nixos/hosts/pikachu/default.nix +++ b/configs/nixos/hosts/pikachu/default.nix @@ -60,7 +60,6 @@ modules.zfs = { enable = true; - hostId = "2346edbd"; pools.pikachu = { }; }; diff --git a/configs/nixos/modules/zfs.nix b/configs/nixos/modules/zfs.nix index 8c340d8..0c8eb5f 100644 --- a/configs/nixos/modules/zfs.nix +++ b/configs/nixos/modules/zfs.nix @@ -11,18 +11,6 @@ in options.modules.zfs = { enable = lib.mkEnableOption "importing durable ZFS pools that hold service state"; - hostId = lib.mkOption { - type = lib.types.strMatching "[0-9a-f]{8}"; - example = "deadbeef"; - description = '' - This host's 8-hex-digit ZFS host id, written to `networking.hostId`. ZFS - stamps an imported pool with the importing host's id, so a pool still - held by another machine is refused rather than silently dual-mounted. It - must be fixed for the machine and distinct across machines that can reach - the same pool. - ''; - }; - pools = lib.mkOption { type = lib.types.attrsOf (lib.types.attrsOf lib.types.path); default = { }; @@ -49,8 +37,10 @@ in # The ZFS stack in the kernel and boot, needed even where the root filesystem is another kind. boot.supportedFilesystems = [ "zfs" ]; - # ZFS refuses to import a pool without a host id to stamp its ownership onto. - networking.hostId = cfg.hostId; + # Derive a stable 32-bit host ID from the configured hostname. + networking.hostId = builtins.substring 0 8 ( + builtins.hashString "sha256" config.networking.hostName + ); # The declared pools are imported at boot, distinct from any pool backing the root filesystem. boot.zfs.extraPools = lib.attrNames cfg.pools; -- 2.47.3 From ec1c0fba56978b6bf1df3dda336db6bd8ae7c10d Mon Sep 17 00:00:00 2001 From: alexion Date: Wed, 7 Oct 2026 16:59:03 -0400 Subject: [PATCH 2/2] 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 { -- 2.47.3