Watch
0
0
Fork
You've already forked hyperhive
0

read the running rev and the hyperhive flake from /etc files, not the unit

This commit is contained in:
atlas 2026-11-06 04:44:27 +01:00 • committed by mara
commit aed7c8451a

View file

@ -10,6 +10,7 @@ use std::process::Stdio;
use std::sync::{Arc, Mutex};
use std::time::{Duration, Instant};
use crate::hyperhive_flake::HyperhiveFlake;
use swarm_wire::builder::ArchetypesReply;
use tokio::io::AsyncReadExt as _;
@ -17,8 +18,9 @@ use tokio::io::AsyncReadExt as _;
pub struct Evaluator {
/// The `nix` binary.
pub nix: PathBuf,
/// The hyperhive source this host was deployed from.
pub hyperhive: String,
/// The hyperhive source this host was deployed from, read for each
/// evaluation.
pub hyperhive: HyperhiveFlake,
/// The nixpkgs source this host was deployed from, which the hyperhive
/// source's own `nixpkgs` input is pointed at, as a hive's meta flake does.
pub nixpkgs: String,
@ -30,16 +32,17 @@ impl Evaluator {
/// Evaluate the archetypes' `meta`.
pub async fn eval(&self) -> ArchetypesReply {
let mut cmd = tokio::process::Command::new(&self.nix);
cmd.args(self.args())
let hyperhive = self.hyperhive.current();
cmd.args(self.args(&hyperhive))
.stdin(Stdio::null())
.stdout(Stdio::piped())
.stderr(Stdio::piped())
.kill_on_drop(true);
run(cmd, &self.hyperhive, self.deadline).await
run(cmd, &hyperhive, self.deadline).await
}
/// The `nix eval` arguments.
fn args(&self) -> Vec<String> {
/// The `nix eval` arguments, on the hyperhive source at `hyperhive`.
fn args(&self, hyperhive: &str) -> Vec<String> {
[
"eval",
"--json",
@ -51,7 +54,7 @@ impl Evaluator {
.into_iter()
.map(str::to_owned)
.chain([
format!("{}#hyperhiveArchetypes", self.hyperhive),
format!("{hyperhive}#hyperhiveArchetypes"),
"--override-input".to_owned(),
"nixpkgs".to_owned(),
self.nixpkgs.clone(),
@ -165,7 +168,7 @@ mod tests {
fn evaluator() -> Evaluator {
Evaluator {
nix: PathBuf::from("nix"),
hyperhive: "/nix/store/h-source".to_owned(),
hyperhive: HyperhiveFlake::fixed("/nix/store/h-source"),
nixpkgs: "/nix/store/n-source".to_owned(),
deadline: swarm_wire::builder::ARCHETYPES_DEADLINE,
}
@ -173,7 +176,7 @@ mod tests {
#[test]
fn only_meta_is_evaluated_on_this_hosts_sources() {
let args = evaluator().args();
let args = evaluator().args("/nix/store/h-source");
assert!(
args.iter()
.any(|a| a == "/nix/store/h-source#hyperhiveArchetypes")