Watch
0
0
Fork
You've already forked hyperhive
0
hyperhive/nix/script-tests/attic-init.nix
atlas 1e5070796d copy the cache's pull facts to each hive and create them in the in-swarm cache
the in-swarm cache stores its address, name and public key beside its tokens, create-only. swarm-controller copies the four cache facts to swarm/hives/<hive>/attic/* every five minutes, with read on the sources and write on the copies. part 1 of 3: nothing reads the copies until the hive reader and probe land.
2026-10-28 01:19:56 +01:00

45 lines
1.5 KiB
Nix

# `checks.script-test-attic-init` — runs ../host-modules/lib/attic-init.nix's two
# scripts, as the cache's host units run them, against stub `bao`, `openssl`,
# `atticadm`, `attic`, `curl` and `systemctl`. The cases are in ./attic-init.sh.
#
# What runs is the rendered script, behind the same helpers the units put in
# front of it.
{
pkgs,
...
}:
let
init = import ../host-modules/lib/attic-init.nix { inherit (pkgs) lib; } {
jwtPath = "secret/swarm/services/attic/jwt-secret";
pullPath = "secret/swarm/services/attic/pull-token";
pushPath = "secret/swarm/services/attic/push-token";
urlPath = "secret/swarm/services/attic/url";
cachePath = "secret/swarm/services/attic/cache";
publicKeyPath = "secret/swarm/services/attic/public-key";
url = "http://cache.example";
cache = "grid";
endpoint = "http://127.0.0.1:8910";
configFile = "@DIR@/server.toml";
envFile = "@DIR@/secrets/server.env";
machine = "swarm-attic";
unit = "swarm-attic";
};
render =
name: body:
pkgs.writeText name ''
set -euo pipefail
${import ../host-modules/lib/atomic-write-secret.nix { }}
${import ../host-modules/lib/refresh-consumer.nix { }}
${init.prelude}
${body}
'';
in
pkgs.runCommand "hyperhive-script-test-attic-init"
{
ENSURE_JWT = render "ensure-jwt.sh" init.ensureJwt;
PROVISION = render "provision.sh" init.provision;
}
''
${pkgs.bash}/bin/bash ${./attic-init.sh}
touch "$out"
''