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

@ -9,6 +9,8 @@
//! Keyed by the agent alone, like [`crate::agent_limits`]: an agent can move
//! between hives, and its closure goes with it.
use hive_types::NixBuilds;
/// The KV bucket closures are recorded in, keyed by agent name.
pub const BUCKET: &str = "agent-closures";
@ -42,6 +44,11 @@ pub struct AgentClosure {
/// false, which keeps the agent out of one.
#[serde(default)]
pub private_users: bool,
/// The agent's `services.hyperhive.agent.nixBuilds`: where its nix builds
/// run. A record written before the field existed reads as
/// [`NixBuilds::Host`], which is what every agent did before it.
#[serde(default)]
pub nix_builds: NixBuilds,
}
#[cfg(test)]
@ -63,6 +70,7 @@ mod tests {
built_unix: 7,
cached: true,
private_users: true,
nix_builds: NixBuilds::Disabled,
};
let wire = serde_json::json!({
"meta_rev": "abc",
@ -71,6 +79,7 @@ mod tests {
"built_unix": 7,
"cached": true,
"private_users": true,
"nix_builds": "none",
});
assert_eq!(serde_json::to_value(&value).expect("encodes"), wire);
assert_eq!(
@ -80,7 +89,7 @@ mod tests {
}
#[test]
fn a_record_without_the_fields_reads_as_not_cached_and_not_namespaced() {
fn a_record_without_the_fields_reads_as_not_cached_not_namespaced_and_host_builds() {
let old = serde_json::json!({
"meta_rev": "abc",
"store_path": "/nix/store/x",
@ -90,5 +99,6 @@ mod tests {
let record = serde_json::from_value::<AgentClosure>(old).expect("decodes");
assert!(!record.cached);
assert!(!record.private_users);
assert_eq!(record.nix_builds, NixBuilds::Host);
}
}