From 70538fb2097e1fb85a6412c76e9aba16904d56e8 Mon Sep 17 00:00:00 2001 From: atlas Date: Thu, 29 Oct 2026 14:31:20 +0100 Subject: [PATCH] move c0re.hyperhiveFlake to deploy.hyperhiveFlake --- docs/swarm/builder.md | 2 +- flake.nix | 2 +- nix/host-modules/deploy.nix | 5 +++++ nix/host-modules/hive-c0re/default.nix | 4 ++-- nix/host-modules/hive-c0re/options.nix | 30 +++++++++++++------------- nix/host-modules/swarm-builder.nix | 2 +- nix/module-eval/builder.nix | 2 +- nix/module-eval/core-toggle.nix | 16 +++++++++++--- 8 files changed, 39 insertions(+), 24 deletions(-) diff --git a/docs/swarm/builder.md b/docs/swarm/builder.md index 827c21bf..d49864f7 100644 --- a/docs/swarm/builder.md +++ b/docs/swarm/builder.md @@ -32,7 +32,7 @@ Where it runs and how it's enabled: [`services.md`](services.md#builder). 3. The builder runs `nix build` of `nix/builder/check-flake`'s `check` output with every input overridden: - `hyperhive` and `nixpkgs`: the sources the builder's own host was - deployed with (`c0re.hyperhiveFlake`, `deploy.builder.nixpkgsFlake`). A hive's meta + deployed with (`deploy.hyperhiveFlake`, `deploy.builder.nixpkgsFlake`). A hive's meta flake pins `hyperhive` by forge URL and rev instead. - `agent`: `git+https:///agent-configs/?ref=refs/pull//head&rev=`. A build has one hour. diff --git a/flake.nix b/flake.nix index b99438ec..b163d8cf 100644 --- a/flake.nix +++ b/flake.nix @@ -126,7 +126,7 @@ { lib, pkgs, ... }: { imports = [ ./nix/host-modules ]; - services.hyperhive.c0re.hyperhiveFlake = lib.mkDefault "${sources.hyperhiveFlakeSource}"; + services.hyperhive.deploy.hyperhiveFlake = lib.mkDefault "${sources.hyperhiveFlakeSource}"; services.hyperhive.deploy.hive-controller = { package = lib.mkDefault self.packages.${pkgs.stdenv.hostPlatform.system}.default; frontend = lib.mkDefault self.packages.${pkgs.stdenv.hostPlatform.system}.frontend; diff --git a/nix/host-modules/deploy.nix b/nix/host-modules/deploy.nix index fac8a867..b6041746 100644 --- a/nix/host-modules/deploy.nix +++ b/nix/host-modules/deploy.nix @@ -198,6 +198,11 @@ in # The c0re daemon is the hive-controller service, so its knobs and package # options sit under it. Same types, same meanings. + # One host-level value, read by hive-c0re and the swarm builder alike. + (lib.mkRenamedOptionModule + [ "services" "hyperhive" "c0re" "hyperhiveFlake" ] + [ "services" "hyperhive" "deploy" "hyperhiveFlake" ] + ) (lib.mkRenamedOptionModule [ "services" "hyperhive" "c0re" "package" ] [ "services" "hyperhive" "deploy" "hive-controller" "package" ] diff --git a/nix/host-modules/hive-c0re/default.nix b/nix/host-modules/hive-c0re/default.nix index 522e286d..4de6106e 100644 --- a/nix/host-modules/hive-c0re/default.nix +++ b/nix/host-modules/hive-c0re/default.nix @@ -11,8 +11,8 @@ ... }: let - cfg = config.services.hyperhive.c0re; controllerCfg = config.services.hyperhive.deploy.hive-controller; + hyperhiveFlake = config.services.hyperhive.deploy.hyperhiveFlake; # `/run/hyperhive`'s mode. Held in one place because whichever of the two # units below activates first creates the directory, so they cannot be @@ -81,7 +81,7 @@ let # NOT trigger a startup sweep that rebuilds every agent — unless the # c0re binary itself changes. serveConfigJson = builtins.toJSON { - hyperhive_flake = cfg.hyperhiveFlake; + hyperhive_flake = hyperhiveFlake; # The `claude-code` every agent runs, or null for "each agent keeps # the one out of its own nixpkgs". `builtins.toJSON` serialises a diff --git a/nix/host-modules/hive-c0re/options.nix b/nix/host-modules/hive-c0re/options.nix index a104035d..5d2eefc0 100644 --- a/nix/host-modules/hive-c0re/options.nix +++ b/nix/host-modules/hive-c0re/options.nix @@ -1,10 +1,9 @@ -# Option declarations for the c0re daemon. `services.hyperhive.c0re.*` -# keeps the flake-source option the swarm builder also reads -# (`hyperhiveFlake`); every other knob and the +# Option declarations for the c0re daemon. The knobs and the # package/asset options the flake's `nixosModules.default` wires to its # own outputs (they carry no in-module defaults; see ../../../flake.nix) # live under `services.hyperhive.deploy.hive-controller`, alongside the -# values the meta-flake render hands the hive's agents. The read-only +# values the meta-flake render hands the hive's agents. The flake-source +# option the swarm builder also reads is `services.hyperhive.deploy.hyperhiveFlake`. The read-only # `servedFrontend` option lives in ./theme.nix with the stylix wiring # that computes it. { @@ -22,17 +21,18 @@ '') ]; - options.services.hyperhive.c0re = { - hyperhiveFlake = lib.mkOption { - type = lib.types.str; - defaultText = lib.literalMD "the hyperhive flake's own filtered source store path"; - description = '' - Store path of the hyperhive flake source (no fragment). hive-c0re - reads it to tell which revision is running, and the swarm builder - builds on it. Wired by `nixosModules.default` to this flake's own - filtered source. - ''; - }; + # One host-level value that both hive-c0re and the swarm builder read, so it + # sits under neither service. + options.services.hyperhive.deploy.hyperhiveFlake = lib.mkOption { + type = lib.types.str; + internal = true; + defaultText = lib.literalMD "the hyperhive flake's own filtered source store path"; + description = '' + Store path of the hyperhive flake source (no fragment). hive-c0re + reads it to tell which revision is running, and the swarm builder + builds on it. Wired by `nixosModules.default` to this flake's own + filtered source. + ''; }; # The hive-controller's deployment options. diff --git a/nix/host-modules/swarm-builder.nix b/nix/host-modules/swarm-builder.nix index efa2ea62..d98b87e5 100644 --- a/nix/host-modules/swarm-builder.nix +++ b/nix/host-modules/swarm-builder.nix @@ -89,7 +89,7 @@ let nix = config.nix.package; # Strings, not paths: both are already store paths. - hyperhiveFlake = hyperhiveCfg.c0re.hyperhiveFlake; + hyperhiveFlake = hyperhiveCfg.deploy.hyperhiveFlake; nixpkgsFlake = hyperhiveCfg.deploy.builder.nixpkgsFlake; # The assertion below keeps the two options together. diff --git a/nix/module-eval/builder.nix b/nix/module-eval/builder.nix index 6237fcaa..e7e40244 100644 --- a/nix/module-eval/builder.nix +++ b/nix/module-eval/builder.nix @@ -252,7 +252,7 @@ let # the same hyperhive and nixpkgs base. name = "the builder builds on the hyperhive and nixpkgs this host was deployed with"; ok = - env.SWARM_BUILDER_HYPERHIVE_FLAKE == withBuilder.services.hyperhive.c0re.hyperhiveFlake + env.SWARM_BUILDER_HYPERHIVE_FLAKE == withBuilder.services.hyperhive.deploy.hyperhiveFlake && env.SWARM_BUILDER_NIXPKGS_FLAKE == withBuilder.services.hyperhive.deploy.builder.nixpkgsFlake && lib.hasSuffix "-check-flake" env.SWARM_BUILDER_CHECK_FLAKE && env.SWARM_BUILDER_SYSTEM == pkgs.stdenv.hostPlatform.system diff --git a/nix/module-eval/core-toggle.nix b/nix/module-eval/core-toggle.nix index 54d5b367..bcdb300f 100644 --- a/nix/module-eval/core-toggle.nix +++ b/nix/module-eval/core-toggle.nix @@ -1441,6 +1441,7 @@ let c0re.agentIoWeight = null; c0re.buildSlots = 3; c0re.adminUsers = [ "alice" ]; + c0re.hyperhiveFlake = "/nix/store/legacy-flake"; }; c = old.services.hyperhive.deploy.hive-controller; warned = @@ -1468,6 +1469,8 @@ let && c.agentIoWeight == null && c.buildSlots == 3 && c.adminUsers == [ "alice" ] + && old.services.hyperhive.deploy.hyperhiveFlake == "/nix/store/legacy-flake" + && serve.hyperhive_flake == "/nix/store/legacy-flake" && lib.all (warned old) [ "package" "frontend" @@ -1483,27 +1486,34 @@ let "agentIoWeight" "buildSlots" "adminUsers" + "hyperhiveFlake" ] && !(warned bare "package") && !(warned bare "adminUsers") + && !(warned bare "hyperhiveFlake") && serve.agent_memory_max == "8G" && serve.agent_cpu_quota == "300%" && serve.build_slots == 3 && old.users.groups.hive-admin.members == [ "alice" ]; } { - # What the moved options render with their defaults: the agent limits + # What the moved options render with their defaults: the flake source, the agent limits # and build slots in serve.json, the sudoless-hivectl group's members, # and the model price table. The same values the options held at their # old paths. - name = "the agent limits, build slots, admin group and price table render their defaults unchanged"; + name = "the flake source, agent limits, build slots, admin group and price table render their defaults unchanged"; ok = let serve = builtins.fromJSON ( builtins.unsafeDiscardStringContext allLocal.environment.etc."hyperhive/serve.json".text ); in - serve.agent_memory_max == "4G" + serve.hyperhive_flake + == builtins.unsafeDiscardStringContext "${(import ../sources.nix { inherit lib; }) + .hyperhiveFlakeSource + }" + && allLocal.services.hyperhive.deploy.hyperhiveFlake == serve.hyperhive_flake + && serve.agent_memory_max == "4G" && serve.agent_cpu_quota == "200%" && serve.agent_cpu_weight == 80 && serve.agent_io_weight == 80