Compare commits
7 changed files with 13 additions and 84 deletions
|
|
@ -26,10 +26,6 @@ Where it runs and how it's enabled: [`services.md`](services.md#builder).
|
||||||
- `hyperhive` and `nixpkgs`: the sources the builder's own host was
|
- `hyperhive` and `nixpkgs`: the sources the builder's own host was
|
||||||
deployed with, the same two a hive on that host renders into its meta
|
deployed with, the same two a hive on that host renders into its meta
|
||||||
flake (`c0re.hyperhiveFlake`, `c0re.nixpkgsFlake`).
|
flake (`c0re.hyperhiveFlake`, `c0re.nixpkgsFlake`).
|
||||||
- `hyperhive-docs`: the `docs/` source a hive on that host renders into its
|
|
||||||
meta flake (`c0re.hyperhiveDocs`). The check sets
|
|
||||||
`services.hyperhive.agent.docs.source` from it, as the meta flake does,
|
|
||||||
since the `hyperhive` source has no `docs/`.
|
|
||||||
- `agent`: `git+https://<forge>/agent-configs/<agent>?ref=refs/pull/<pr>/head&rev=<head>`.
|
- `agent`: `git+https://<forge>/agent-configs/<agent>?ref=refs/pull/<pr>/head&rev=<head>`.
|
||||||
A build has one hour.
|
A build has one hour.
|
||||||
4. The reply is the system closure's store path, or the last lines `nix`
|
4. The reply is the system closure's store path, or the last lines `nix`
|
||||||
|
|
@ -52,7 +48,7 @@ Where it runs and how it's enabled: [`services.md`](services.md#builder).
|
||||||
|
|
||||||
- It composes the config the way a hive's meta flake does
|
- It composes the config the way a hive's meta flake does
|
||||||
(`agent-base.extendModules` with the config's `nixosModules.default`), minus
|
(`agent-base.extendModules` with the config's `nixosModules.default`), minus
|
||||||
what a hive adds: its CA bundle, `claude-code` path, ports and
|
what a hive adds: its CA bundle, docs source, `claude-code` path, ports and
|
||||||
OTEL settings, and the `follows` that point the config's own inputs at the
|
OTEL settings, and the `follows` that point the config's own inputs at the
|
||||||
hive's. A green check can therefore still fail on a hive, and the reverse.
|
hive's. A green check can therefore still fail on a hive, and the reverse.
|
||||||
- The agent base is the builder's host's, not the hive's. Hives on another
|
- The agent base is the builder's host's, not the hive's. Hives on another
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,6 @@
|
||||||
# The swarm builder's build check: one agent config on hyperhive's agent base,
|
# The swarm builder's build check: one agent config on hyperhive's agent base,
|
||||||
# composed the way a hive's meta flake composes it, minus the values a hive
|
# composed the way a hive's meta flake composes it, minus the values a hive
|
||||||
# adds (its CA, claude-code path and ports). The docs source is set the way the
|
# adds (its CA, docs source, claude-code path and ports).
|
||||||
# meta flake sets it: `hyperhive`'s source has no `docs/`, so the default
|
|
||||||
# `docs.source` fails to evaluate.
|
|
||||||
#
|
#
|
||||||
# Every input is replaced at build time with `--override-input`
|
# Every input is replaced at build time with `--override-input`
|
||||||
# (swarm-builder/src/nix_build.rs), so the URLs below are never fetched and
|
# (swarm-builder/src/nix_build.rs), so the URLs below are never fetched and
|
||||||
|
|
@ -14,25 +12,15 @@
|
||||||
nixpkgs.url = "flake:nixpkgs";
|
nixpkgs.url = "flake:nixpkgs";
|
||||||
hyperhive.url = "flake:hyperhive";
|
hyperhive.url = "flake:hyperhive";
|
||||||
hyperhive.inputs.nixpkgs.follows = "nixpkgs";
|
hyperhive.inputs.nixpkgs.follows = "nixpkgs";
|
||||||
hyperhive-docs.url = "flake:hyperhive-docs";
|
|
||||||
hyperhive-docs.flake = false;
|
|
||||||
agent.url = "flake:agent";
|
agent.url = "flake:agent";
|
||||||
};
|
};
|
||||||
|
|
||||||
outputs =
|
outputs =
|
||||||
{
|
{ hyperhive, agent, ... }:
|
||||||
hyperhive,
|
|
||||||
hyperhive-docs,
|
|
||||||
agent,
|
|
||||||
...
|
|
||||||
}:
|
|
||||||
{
|
{
|
||||||
packages.x86_64-linux.check =
|
packages.x86_64-linux.check =
|
||||||
(hyperhive.nixosConfigurations.agent-base.extendModules {
|
(hyperhive.nixosConfigurations.agent-base.extendModules {
|
||||||
modules = [
|
modules = [ agent.nixosModules.default ];
|
||||||
agent.nixosModules.default
|
|
||||||
{ services.hyperhive.agent.docs.source = hyperhive-docs.outPath; }
|
|
||||||
];
|
|
||||||
}).config.system.build.toplevel;
|
}).config.system.build.toplevel;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -89,11 +89,10 @@ let
|
||||||
# The `nix` the host daemon runs, so client and daemon speak one protocol.
|
# The `nix` the host daemon runs, so client and daemon speak one protocol.
|
||||||
nix = config.nix.package;
|
nix = config.nix.package;
|
||||||
|
|
||||||
# Strings, not paths: all three are already store paths, and the flake
|
# Strings, not paths: both are already store paths, and the flake reference
|
||||||
# references the daemon passes must be the ones a hive's meta flake names.
|
# the daemon passes must be the same one a hive's meta flake names.
|
||||||
hyperhiveFlake = hyperhiveCfg.c0re.hyperhiveFlake;
|
hyperhiveFlake = hyperhiveCfg.c0re.hyperhiveFlake;
|
||||||
nixpkgsFlake = hyperhiveCfg.c0re.nixpkgsFlake;
|
nixpkgsFlake = hyperhiveCfg.c0re.nixpkgsFlake;
|
||||||
docsFlake = hyperhiveCfg.c0re.hyperhiveDocs;
|
|
||||||
|
|
||||||
privateNetwork = true;
|
privateNetwork = true;
|
||||||
in
|
in
|
||||||
|
|
@ -254,7 +253,6 @@ in
|
||||||
SWARM_BUILDER_CHECK_FLAKE = "${../builder/check-flake}";
|
SWARM_BUILDER_CHECK_FLAKE = "${../builder/check-flake}";
|
||||||
SWARM_BUILDER_HYPERHIVE_FLAKE = hyperhiveFlake;
|
SWARM_BUILDER_HYPERHIVE_FLAKE = hyperhiveFlake;
|
||||||
SWARM_BUILDER_NIXPKGS_FLAKE = nixpkgsFlake;
|
SWARM_BUILDER_NIXPKGS_FLAKE = nixpkgsFlake;
|
||||||
SWARM_BUILDER_HYPERHIVE_DOCS_FLAKE = docsFlake;
|
|
||||||
SWARM_BUILDER_FORGE_URL = "https://${forgeCfg.domain}";
|
SWARM_BUILDER_FORGE_URL = "https://${forgeCfg.domain}";
|
||||||
SWARM_BUILDER_CONFIG_ORG = "agent-configs";
|
SWARM_BUILDER_CONFIG_ORG = "agent-configs";
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -49,30 +49,6 @@ let
|
||||||
svc = inner.systemd.services.swarm-builder;
|
svc = inner.systemd.services.swarm-builder;
|
||||||
env = svc.environment;
|
env = svc.environment;
|
||||||
|
|
||||||
# The check flake on the inputs the builder's unit names, called as
|
|
||||||
# `nix build` calls it. `hyperhive` is entered through the filtered source's
|
|
||||||
# own `flake.nix`, so its agent base sees the tree without `docs/` that a
|
|
||||||
# real build gets; `self`'s own agent base would find `docs/` here.
|
|
||||||
builderCheck =
|
|
||||||
agentModule:
|
|
||||||
let
|
|
||||||
src = env.SWARM_BUILDER_HYPERHIVE_FLAKE;
|
|
||||||
hyperhive = (import "${src}/flake.nix").outputs (
|
|
||||||
self.inputs
|
|
||||||
// {
|
|
||||||
self = hyperhive // {
|
|
||||||
outPath = src;
|
|
||||||
inherit (self) inputs;
|
|
||||||
};
|
|
||||||
}
|
|
||||||
);
|
|
||||||
in
|
|
||||||
((import "${env.SWARM_BUILDER_CHECK_FLAKE}/flake.nix").outputs {
|
|
||||||
inherit hyperhive;
|
|
||||||
hyperhive-docs.outPath = env.SWARM_BUILDER_HYPERHIVE_DOCS_FLAKE;
|
|
||||||
agent.nixosModules.default = agentModule;
|
|
||||||
}).packages.x86_64-linux.check;
|
|
||||||
|
|
||||||
cases = [
|
cases = [
|
||||||
{
|
{
|
||||||
name = "the swarm builder's container exists only where its host enables it";
|
name = "the swarm builder's container exists only where its host enables it";
|
||||||
|
|
@ -137,10 +113,9 @@ let
|
||||||
{
|
{
|
||||||
# The check builds on the sources a hive on this host would render into
|
# The check builds on the sources a hive on this host would render into
|
||||||
# its meta flake, so a green check means the same base.
|
# its meta flake, so a green check means the same base.
|
||||||
name = "the builder builds on the hyperhive, docs and nixpkgs this host's hives use";
|
name = "the builder builds on the hyperhive and nixpkgs this host's hives use";
|
||||||
ok =
|
ok =
|
||||||
env.SWARM_BUILDER_HYPERHIVE_FLAKE == withBuilder.services.hyperhive.c0re.hyperhiveFlake
|
env.SWARM_BUILDER_HYPERHIVE_FLAKE == withBuilder.services.hyperhive.c0re.hyperhiveFlake
|
||||||
&& env.SWARM_BUILDER_HYPERHIVE_DOCS_FLAKE == withBuilder.services.hyperhive.c0re.hyperhiveDocs
|
|
||||||
&& env.SWARM_BUILDER_NIXPKGS_FLAKE == withBuilder.services.hyperhive.c0re.nixpkgsFlake
|
&& env.SWARM_BUILDER_NIXPKGS_FLAKE == withBuilder.services.hyperhive.c0re.nixpkgsFlake
|
||||||
&& lib.hasSuffix "-check-flake" env.SWARM_BUILDER_CHECK_FLAKE
|
&& lib.hasSuffix "-check-flake" env.SWARM_BUILDER_CHECK_FLAKE
|
||||||
&& env.SWARM_BUILDER_CONFIG_ORG == "agent-configs"
|
&& env.SWARM_BUILDER_CONFIG_ORG == "agent-configs"
|
||||||
|
|
@ -175,18 +150,6 @@ let
|
||||||
&& lib.elem "execution" reviewer
|
&& lib.elem "execution" reviewer
|
||||||
&& !(lib.elem "meta" reviewer);
|
&& !(lib.elem "meta" reviewer);
|
||||||
}
|
}
|
||||||
{
|
|
||||||
# `docs.enable` reads `docs.source`, whose default builds from the
|
|
||||||
# `docs/` the `hyperhive` source has none of; an eval error there fails
|
|
||||||
# this whole group.
|
|
||||||
name = "the builder's check evaluates a config with the reference docs on";
|
|
||||||
ok =
|
|
||||||
lib.hasSuffix ".drv"
|
|
||||||
(builderCheck {
|
|
||||||
services.hyperhive.agent.user.name = "a1";
|
|
||||||
services.hyperhive.agent.docs.enable = true;
|
|
||||||
}).drvPath;
|
|
||||||
}
|
|
||||||
{
|
{
|
||||||
# The responder denies a client id it does not know, and a NATS denial
|
# The responder denies a client id it does not know, and a NATS denial
|
||||||
# arrives as a timeout.
|
# arrives as a timeout.
|
||||||
|
|
|
||||||
|
|
@ -12,10 +12,9 @@ the answer into a `swarm-builder` commit status on the PR's head.
|
||||||
|
|
||||||
## What a build is
|
## What a build is
|
||||||
|
|
||||||
- `nix build` of `nix/builder/check-flake`'s `check` output, with its four
|
- `nix build` of `nix/builder/check-flake`'s `check` output, with its three
|
||||||
inputs overridden: `hyperhive` and `nixpkgs` to this host's own sources,
|
inputs overridden: `hyperhive` and `nixpkgs` to this host's own sources, and
|
||||||
`hyperhive-docs` to the `docs/` source its hives use (`c0re.hyperhiveDocs`),
|
`agent` to `git+https://<forge>/agent-configs/<agent>?ref=refs/pull/<pr>/head&rev=<rev>`.
|
||||||
and `agent` to `git+https://<forge>/agent-configs/<agent>?ref=refs/pull/<pr>/head&rev=<rev>`.
|
|
||||||
- The evaluation runs here, pure; the builds run in the host daemon's sandbox
|
- The evaluation runs here, pure; the builds run in the host daemon's sandbox
|
||||||
as an untrusted client, so a config can neither set daemon options nor read
|
as an untrusted client, so a config can neither set daemon options nor read
|
||||||
this service's environment.
|
this service's environment.
|
||||||
|
|
|
||||||
|
|
@ -49,7 +49,6 @@ async fn main() -> Result<()> {
|
||||||
check_flake: var("CHECK_FLAKE")?,
|
check_flake: var("CHECK_FLAKE")?,
|
||||||
hyperhive: var("HYPERHIVE_FLAKE")?,
|
hyperhive: var("HYPERHIVE_FLAKE")?,
|
||||||
nixpkgs: var("NIXPKGS_FLAKE")?,
|
nixpkgs: var("NIXPKGS_FLAKE")?,
|
||||||
hyperhive_docs: var("HYPERHIVE_DOCS_FLAKE")?,
|
|
||||||
forge_url: forge_url()?,
|
forge_url: forge_url()?,
|
||||||
config_org: var("CONFIG_ORG")?,
|
config_org: var("CONFIG_ORG")?,
|
||||||
deadline: BUILD_DEADLINE,
|
deadline: BUILD_DEADLINE,
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,5 @@
|
||||||
//! One build: `nix build` of the check flake with its four inputs pointed at
|
//! One build: `nix build` of the check flake with its three inputs pointed at
|
||||||
//! this host's hyperhive, hyperhive docs and nixpkgs and at the agent's config
|
//! this host's hyperhive and nixpkgs and at the agent's config commit.
|
||||||
//! commit.
|
|
||||||
//!
|
//!
|
||||||
//! The config repo is private, so `git` fetches it with the builder's forge
|
//! The config repo is private, so `git` fetches it with the builder's forge
|
||||||
//! token. The token reaches `git` through a credential helper that reads it
|
//! token. The token reaches `git` through a credential helper that reads it
|
||||||
|
|
@ -45,8 +44,6 @@ pub struct Builder {
|
||||||
pub hyperhive: String,
|
pub hyperhive: String,
|
||||||
/// The nixpkgs source this host was deployed from.
|
/// The nixpkgs source this host was deployed from.
|
||||||
pub nixpkgs: String,
|
pub nixpkgs: String,
|
||||||
/// The hyperhive `docs/` source this host was deployed from.
|
|
||||||
pub hyperhive_docs: String,
|
|
||||||
/// `https://<forge>`, with no trailing slash and no path.
|
/// `https://<forge>`, with no trailing slash and no path.
|
||||||
pub forge_url: String,
|
pub forge_url: String,
|
||||||
/// The org the config repos are in.
|
/// The org the config repos are in.
|
||||||
|
|
@ -102,9 +99,6 @@ impl Builder {
|
||||||
"nixpkgs".to_owned(),
|
"nixpkgs".to_owned(),
|
||||||
self.nixpkgs.clone(),
|
self.nixpkgs.clone(),
|
||||||
"--override-input".to_owned(),
|
"--override-input".to_owned(),
|
||||||
"hyperhive-docs".to_owned(),
|
|
||||||
self.hyperhive_docs.clone(),
|
|
||||||
"--override-input".to_owned(),
|
|
||||||
"agent".to_owned(),
|
"agent".to_owned(),
|
||||||
self.agent_url(job),
|
self.agent_url(job),
|
||||||
])
|
])
|
||||||
|
|
@ -308,7 +302,6 @@ mod tests {
|
||||||
check_flake: "/nix/store/c-check".to_owned(),
|
check_flake: "/nix/store/c-check".to_owned(),
|
||||||
hyperhive: "/nix/store/h-source".to_owned(),
|
hyperhive: "/nix/store/h-source".to_owned(),
|
||||||
nixpkgs: "/nix/store/n-source".to_owned(),
|
nixpkgs: "/nix/store/n-source".to_owned(),
|
||||||
hyperhive_docs: "/nix/store/d-docs-source".to_owned(),
|
|
||||||
forge_url: "https://forge.example".to_owned(),
|
forge_url: "https://forge.example".to_owned(),
|
||||||
config_org: "agent-configs".to_owned(),
|
config_org: "agent-configs".to_owned(),
|
||||||
nix: PathBuf::from("nix"),
|
nix: PathBuf::from("nix"),
|
||||||
|
|
@ -333,14 +326,7 @@ mod tests {
|
||||||
.filter(|w| w[0] == "--override-input")
|
.filter(|w| w[0] == "--override-input")
|
||||||
.map(|w| w[1].as_str())
|
.map(|w| w[1].as_str())
|
||||||
.collect();
|
.collect();
|
||||||
assert_eq!(
|
assert_eq!(overridden, ["hyperhive", "nixpkgs", "agent"]);
|
||||||
overridden,
|
|
||||||
["hyperhive", "nixpkgs", "hyperhive-docs", "agent"]
|
|
||||||
);
|
|
||||||
assert!(
|
|
||||||
args.windows(2)
|
|
||||||
.any(|w| w[0] == "hyperhive-docs" && w[1] == "/nix/store/d-docs-source")
|
|
||||||
);
|
|
||||||
assert!(args.iter().any(|a| a == "/nix/store/c-check#check"));
|
assert!(args.iter().any(|a| a == "/nix/store/c-check#check"));
|
||||||
assert!(args.iter().any(|a| a == "--no-write-lock-file"));
|
assert!(args.iter().any(|a| a == "--no-write-lock-file"));
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue