Watch
0
0
Fork
You've already forked hyperhive
0
hyperhive/nix/script-tests/attic-root-facts.nix

45 lines
1.3 KiB
Nix

# `checks.script-test-attic-root-facts` — runs
# ../host-modules/lib/attic-root-facts.nix's script, as `hive-priv-cache-facts`
# runs it, against a stub `bao` that keeps its leaves in files. The cases are in
# ./attic-root-facts.sh.
#
# What runs is the rendered script, with the directory it writes moved into the
# test's scratch space. `SCRIPT_HOSTCA` is the same script for a host whose nix
# sets its own `ssl-cert-file`, which becomes the base of the CA bundle.
{
pkgs,
...
}:
let
render =
baseBundle:
pkgs.writeText "attic-root-facts.sh" (
import ../host-modules/lib/attic-root-facts.nix { inherit (pkgs) lib; } {
hive = "alpha";
host = "cache.example";
dir = "@DIR@/attic";
url = "https://cache.example/swarm";
confFile = "@DIR@/nix/cache.conf";
netrcFile = "@DIR@/nix/netrc";
hostNetrc = "@DIR@/host-netrc";
caBundleFile = "@DIR@/nix/ca-bundle.crt";
inherit baseBundle;
swarmCa = "@DIR@/swarm-root.pem";
}
);
in
pkgs.runCommand "hyperhive-script-test-attic-root-facts"
{
SCRIPT = render "@DIR@/system-bundle.crt";
SCRIPT_HOSTCA = render "@DIR@/host-ca.pem";
nativeBuildInputs = [
pkgs.coreutils
pkgs.curl
pkgs.gnugrep
pkgs.openssl
];
}
''
${pkgs.bash}/bin/bash ${./attic-root-facts.sh}
touch "$out"
''