refactor(#2111): remove nixpkgs-unstable, source claude-code from main nixpkgs

This commit is contained in:
atlas 2026-07-01 19:11:22 +02:00 committed by mara
commit ae41e39dfb
8 changed files with 26 additions and 147 deletions

View file

@ -57,7 +57,6 @@ pub async fn sync_agents(hive: &HiveEnv, agents: &[AgentSpec]) -> Result<()> {
let new_flake = render_flake(
&hive.hyperhive_flake,
&hive.nixpkgs_flake,
&hive.nixpkgs_unstable_flake,
hive.dashboard_port,
&hive.operator_pronouns,
&hive.context_window_tokens,
@ -563,7 +562,6 @@ pub async fn bulk_commit_topology(
fn render_flake(
hyperhive_flake: &str,
nixpkgs_flake: &str,
nixpkgs_unstable_flake: &str,
dashboard_port: u16,
operator_pronouns: &str,
context_window_tokens: &std::collections::HashMap<String, u64>,
@ -572,7 +570,6 @@ fn render_flake(
render_flake_with_lookup(
hyperhive_flake,
nixpkgs_flake,
nixpkgs_unstable_flake,
dashboard_port,
operator_pronouns,
context_window_tokens,
@ -586,7 +583,7 @@ fn render_flake(
/// `follows = "<name>"` line emitted in meta — collapsing the
/// otherwise-separate-but-identical `nixpkgs_N` nodes into a single
/// meta-level reference.
const CANONICAL_INPUTS: &[&str] = &["nixpkgs", "nixpkgs-unstable"];
const CANONICAL_INPUTS: &[&str] = &["nixpkgs"];
/// Env vars hive-c0re forwards from its own systemd unit env into every
/// sub-agent's harness service env. Each entry is `(env_var_name,
@ -841,7 +838,6 @@ fn agent_canonical_inputs(name: &str) -> Vec<&'static str> {
fn render_flake_with_lookup<F>(
hyperhive_flake: &str,
nixpkgs_flake: &str,
nixpkgs_unstable_flake: &str,
dashboard_port: u16,
operator_pronouns: &str,
context_window_tokens: &std::collections::HashMap<String, u64>,
@ -854,37 +850,30 @@ where
use std::fmt::Write as _;
let mut out = String::new();
out.push_str("{\n description = \"hyperhive deployed agents\";\n inputs = {\n");
// `nixpkgs` + `nixpkgs-unstable` are top-level meta inputs with explicit
// store-path URLs. `hyperhive` then follows them via
// `hyperhive.inputs.*.follows`. This cascades through to every agent
// because `agent-<n>.inputs.nixpkgs.follows = "nixpkgs"` resolves to
// the same top-level node.
// `nixpkgs` is a top-level meta input with an explicit store-path URL.
// `hyperhive` then follows it via `hyperhive.inputs.nixpkgs.follows`.
// This cascades through to every agent because
// `agent-<n>.inputs.nixpkgs.follows = "nixpkgs"` resolves to the same
// top-level node.
//
// Why explicit `path:` URLs instead of
// Why an explicit `path:` URL instead of
// `nixpkgs.follows = "hyperhive/nixpkgs"`:
// meta points to hyperhive's *store path* as its flake input, so nix
// reads hyperhive's own pinned lock when evaluating that input — the
// host-level `follows` the operator set never propagates. Injecting the
// evaluated `pkgs.path` / nixpkgs-unstable path directly at nix-module
// evaluation time is the only reliable way to honour the host's channel
// choice.
// evaluated `pkgs.path` directly at nix-module evaluation time is the
// only reliable way to honour the host's channel choice.
//
// Fallback (both flake args empty): legacy `follows` wiring — used when
// Fallback (flake arg empty): legacy `follows` wiring — used when
// hive-c0re is not built with this option wired up.
if nixpkgs_flake.is_empty() {
// Legacy path: meta defers to hyperhive's own lock.
let _ = writeln!(out, " hyperhive.url = \"{hyperhive_flake}\";");
out.push_str(" nixpkgs.follows = \"hyperhive/nixpkgs\";\n");
out.push_str(" nixpkgs-unstable.follows = \"hyperhive/nixpkgs-unstable\";\n");
} else {
let _ = writeln!(out, " nixpkgs.url = \"{nixpkgs_flake}\";");
let _ = writeln!(
out,
" nixpkgs-unstable.url = \"{nixpkgs_unstable_flake}\";"
);
let _ = writeln!(out, " hyperhive.url = \"{hyperhive_flake}\";");
out.push_str(" hyperhive.inputs.nixpkgs.follows = \"nixpkgs\";\n");
out.push_str(" hyperhive.inputs.nixpkgs-unstable.follows = \"nixpkgs-unstable\";\n");
}
for spec in agents {
let _ = writeln!(
@ -1276,30 +1265,21 @@ mod tests {
let out = render_flake(
"github:example/hyperhive",
"path:/nix/store/aaaa-nixpkgs-source",
"path:/nix/store/bbbb-nixpkgs-unstable-source",
8000,
"she/her",
&std::collections::HashMap::new(),
&[sample_spec("alice", false, 9001)],
);
// Both nixpkgs + nixpkgs-unstable are top-level inputs with
// explicit URLs; hyperhive follows them.
// nixpkgs is a top-level input with an explicit URL; hyperhive
// follows it.
assert!(
out.contains("nixpkgs.url = \"path:/nix/store/aaaa-nixpkgs-source\""),
"expected explicit nixpkgs.url:\n{out}"
);
assert!(
out.contains("nixpkgs-unstable.url = \"path:/nix/store/bbbb-nixpkgs-unstable-source\""),
"expected explicit nixpkgs-unstable.url:\n{out}"
);
assert!(
out.contains("hyperhive.inputs.nixpkgs.follows = \"nixpkgs\""),
"expected hyperhive.inputs.nixpkgs.follows:\n{out}"
);
assert!(
out.contains("hyperhive.inputs.nixpkgs-unstable.follows = \"nixpkgs-unstable\""),
"expected hyperhive.inputs.nixpkgs-unstable.follows:\n{out}"
);
assert!(
!out.contains("nixpkgs.follows = \"hyperhive"),
"old-style follows must not appear when flake args are set:\n{out}"
@ -1313,7 +1293,6 @@ mod tests {
let out = render_flake(
"github:example/hyperhive",
"",
"",
8000,
"she/her",
&std::collections::HashMap::new(),
@ -1323,10 +1302,6 @@ mod tests {
out.contains("nixpkgs.follows = \"hyperhive/nixpkgs\""),
"expected fallback follows:\n{out}"
);
assert!(
out.contains("nixpkgs-unstable.follows = \"hyperhive/nixpkgs-unstable\""),
"expected fallback unstable follows:\n{out}"
);
assert!(
!out.contains("nixpkgs.url ="),
"no explicit url should be emitted in fallback mode:\n{out}"
@ -1335,19 +1310,17 @@ mod tests {
#[test]
fn render_flake_emits_follows_for_agents_declaring_nixpkgs() {
// Stub lookup: pretend `bitburner` declares `nixpkgs` at its
// root, while `argus` has no canonical inputs at all.
// Stub lookup: pretend `bitburner` + `dmatrix` declare `nixpkgs`
// at their root, while `argus` has no canonical inputs at all.
let lookup = |name: &str| -> Vec<&'static str> {
match name {
"bitburner" => vec!["nixpkgs"],
"dmatrix" => vec!["nixpkgs", "nixpkgs-unstable"],
"bitburner" | "dmatrix" => vec!["nixpkgs"],
_ => vec![],
}
};
let out = render_flake_with_lookup(
"github:example/hyperhive",
"path:/nix/store/aaaa-nixpkgs-source",
"path:/nix/store/bbbb-nixpkgs-unstable-source",
8000,
"she/her",
&std::collections::HashMap::new(),
@ -1363,11 +1336,8 @@ mod tests {
out.contains("agent-bitburner.inputs.nixpkgs.follows = \"nixpkgs\""),
"missing bitburner nixpkgs follows:\n{out}"
);
// dmatrix declares both → both follows emitted.
// dmatrix declares nixpkgs → follows emitted.
assert!(out.contains("agent-dmatrix.inputs.nixpkgs.follows = \"nixpkgs\""));
assert!(
out.contains("agent-dmatrix.inputs.nixpkgs-unstable.follows = \"nixpkgs-unstable\"")
);
// argus declares neither → no follows emitted for it. Asserting
// ABSENCE is the important bit: emitting a follows on a
// non-existent input errors at `nix flake lock` time.
@ -1382,7 +1352,6 @@ mod tests {
let out = render_flake_with_lookup(
"github:example/hyperhive",
"path:/nix/store/aaaa-nixpkgs-source",
"path:/nix/store/bbbb-nixpkgs-unstable-source",
8000,
"she/her",
&std::collections::HashMap::new(),
@ -1416,7 +1385,6 @@ mod tests {
let out = render_flake(
"github:example/hyperhive",
"path:/nix/store/aaaa-nixpkgs-source",
"path:/nix/store/bbbb-nixpkgs-unstable-source",
8000,
"she/her",
&std::collections::HashMap::new(),
@ -1464,7 +1432,6 @@ mod tests {
render_flake(
"github:example/hyperhive",
"path:/nix/store/aaaa-nixpkgs-source",
"path:/nix/store/bbbb-nixpkgs-unstable-source",
8000,
"she/her",
&std::collections::HashMap::new(),
@ -1546,7 +1513,6 @@ mod tests {
render_flake(
"github:example/hyperhive",
"path:/nix/store/aaaa-nixpkgs-source",
"path:/nix/store/bbbb-nixpkgs-unstable-source",
8000,
"she/her",
&std::collections::HashMap::new(),