feat(#1003): inject pkgs.path into meta flake as explicit nixpkgs.url

meta flake was using `nixpkgs.follows = "hyperhive/nixpkgs"` but
`hyperhive` is a store-path input, so nix resolves hyperhive's own
pinned lock rather than the host's follows-substituted version.
When an operator sets `inputs.hyperhive.inputs.nixpkgs.follows =
"nixpkgs"` in their host flake, the meta flake was silently ignoring
it and using hyperhive's pinned nixpkgs instead.

Fix: hive-c0re.nix injects `--nixpkgs-flake path:${pkgs.path}` into
the daemon's ExecStart. `pkgs` IS the host's nixpkgs when follows is
set; otherwise it's hyperhive's own pin — so the meta flake gets the
right nixpkgs in both cases. render_flake emits `nixpkgs.url = "..."`
(explicit) when nixpkgs_flake is non-empty, falling back to the old
`follows` form when empty for backward compat.
This commit is contained in:
atlas 2026-06-01 22:23:33 +02:00
commit fe5a41288d
9 changed files with 97 additions and 37 deletions

View file

@ -36,6 +36,15 @@ enum Cmd {
/// `flake.nix` as the `hyperhive` input.
#[arg(long, default_value = "/etc/hyperhive")]
hyperhive_flake: String,
/// Store-path URL of the nixpkgs to wire into the meta flake as
/// `inputs.nixpkgs.url`. Set by the NixOS module to
/// `"path:${pkgs.path}"` so the meta flake tracks exactly the
/// nixpkgs the host was evaluated with (the host's own nixpkgs
/// when `inputs.hyperhive.inputs.nixpkgs.follows = "nixpkgs"` is
/// set, otherwise hyperhive's pin). Empty = legacy
/// `follows = "hyperhive/nixpkgs"` fallback.
#[arg(long, default_value = "")]
nixpkgs_flake: String,
/// Path to the sqlite message store.
#[arg(long, default_value = "/var/lib/hyperhive/broker.sqlite")]
db: PathBuf,
@ -118,6 +127,7 @@ async fn main() -> Result<()> {
match cli.cmd {
Cmd::Serve {
hyperhive_flake,
nixpkgs_flake,
db,
dashboard_port,
operator_pronouns,
@ -125,6 +135,7 @@ async fn main() -> Result<()> {
} => {
cmd_serve(
hyperhive_flake,
nixpkgs_flake,
db,
dashboard_port,
operator_pronouns,
@ -172,6 +183,7 @@ async fn main() -> Result<()> {
/// dashboard), then serve the admin socket until a signal arrives.
async fn cmd_serve(
hyperhive_flake: String,
nixpkgs_flake: String,
db: std::path::PathBuf,
dashboard_port: u16,
operator_pronouns: String,
@ -183,6 +195,7 @@ async fn cmd_serve(
let coord = Arc::new(Coordinator::open(
&db,
hyperhive_flake,
nixpkgs_flake,
dashboard_port,
operator_pronouns,
cwt,