Watch
0
0
Fork
You've already forked hyperhive
0

add a per-agent nix builds mode, host or none, carried like privateUsers

This commit is contained in:
atlas 2026-11-03 00:30:55 +01:00 • committed by mara
commit 5485151ba6

View file

@ -371,6 +371,7 @@ pub(crate) async fn run(
system,
cached,
private_users,
nix_builds,
}) => {
let built_rev = meta_rev.clone();
let closure = AgentClosure {
@ -380,6 +381,7 @@ pub(crate) async fn run(
built_unix: unix_now(),
cached,
private_users,
nix_builds,
};
match queue.record(&agent, &closure).await {
Ok(()) => {
@ -398,6 +400,8 @@ pub(crate) async fn run(
mod tests {
use std::sync::{Arc, Mutex};
use hive_types::NixBuilds;
use crate::builder::runs::tests::FakeDoc;
use super::*;
@ -488,15 +492,16 @@ mod tests {
}
fn built_cached(cached: bool) -> Self {
Self::built_with(cached, false)
Self::built_with(cached, false, NixBuilds::Host)
}
fn built_with(cached: bool, private_users: bool) -> Self {
fn built_with(cached: bool, private_users: bool, nix_builds: NixBuilds) -> Self {
Self::answering(Ok(FromMetaReply::Built {
out_path: "/nix/store/x-toplevel".to_owned(),
system: "x86_64-linux".to_owned(),
cached,
private_users,
nix_builds,
}))
}
}
@ -627,9 +632,9 @@ mod tests {
/// The record says what the builder said about the agent's user namespace,
/// both ways; a builder that said nothing leaves it off.
#[tokio::test]
async fn the_record_carries_the_builders_private_users_answer() {
for private_users in [true, false] {
let queue = FakeQueue::built_with(true, private_users);
async fn the_record_carries_the_builders_user_namespace_and_nix_builds_answers() {
for (private_users, nix_builds) in [(true, NixBuilds::Disabled), (false, NixBuilds::Host)] {
let queue = FakeQueue::built_with(true, private_users, nix_builds);
let outcome = run_with(&FakeHead::reading(Ok(Some(REV))), &queue).await;
assert_eq!(outcome, Outcome::Done);
let recorded = queue.recorded.lock().unwrap();
@ -637,6 +642,7 @@ mod tests {
panic!("one record: {recorded:?}")
};
assert_eq!(closure.private_users, private_users);
assert_eq!(closure.nix_builds, nix_builds);
}
}
@ -922,6 +928,7 @@ mod tests {
built_unix: 1,
cached: false,
private_users: true,
nix_builds: NixBuilds::Disabled,
};
client.record("atlas", &closure).await.expect("written");
closure.store_path = "/nix/store/b".to_owned();