2019-11-23 23:05:12 +01:00
|
|
|
import ./make-test-python.nix ({pkgs, lib, ...}:
|
2019-11-02 19:55:41 +01:00
|
|
|
let
|
2023-07-17 17:19:44 +02:00
|
|
|
gpgKeyring = import ./common/gpg-keyring.nix { inherit pkgs; };
|
2019-11-02 19:55:41 +01:00
|
|
|
|
|
|
|
nspawnImages = (pkgs.runCommand "localhost" { buildInputs = [ pkgs.coreutils pkgs.gnupg ]; } ''
|
|
|
|
mkdir -p $out
|
|
|
|
cd $out
|
2022-05-06 15:38:43 +02:00
|
|
|
|
|
|
|
# produce a testimage.raw
|
2019-11-02 19:55:41 +01:00
|
|
|
dd if=/dev/urandom of=$out/testimage.raw bs=$((1024*1024+7)) count=5
|
2022-05-06 15:38:43 +02:00
|
|
|
|
|
|
|
# produce a testimage2.tar.xz, containing the hello store path
|
|
|
|
tar cvJpf testimage2.tar.xz ${pkgs.hello}
|
|
|
|
|
|
|
|
# produce signature(s)
|
|
|
|
sha256sum testimage* > SHA256SUMS
|
2019-11-02 19:55:41 +01:00
|
|
|
export GNUPGHOME="$(mktemp -d)"
|
|
|
|
cp -R ${gpgKeyring}/* $GNUPGHOME
|
|
|
|
gpg --batch --sign --detach-sign --output SHA256SUMS.gpg SHA256SUMS
|
|
|
|
'');
|
|
|
|
in {
|
2019-11-23 23:05:12 +01:00
|
|
|
name = "systemd-nspawn";
|
2019-11-02 19:55:41 +01:00
|
|
|
|
|
|
|
nodes = {
|
|
|
|
server = { pkgs, ... }: {
|
|
|
|
networking.firewall.allowedTCPPorts = [ 80 ];
|
|
|
|
services.nginx = {
|
|
|
|
enable = true;
|
|
|
|
virtualHosts."server".root = nspawnImages;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
client = { pkgs, ... }: {
|
|
|
|
environment.etc."systemd/import-pubring.gpg".source = "${gpgKeyring}/pubkey.gpg";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
testScript = ''
|
2019-11-23 23:05:12 +01:00
|
|
|
start_all()
|
2019-11-02 19:55:41 +01:00
|
|
|
|
2019-11-23 23:05:12 +01:00
|
|
|
server.wait_for_unit("nginx.service")
|
2023-10-03 10:02:18 +02:00
|
|
|
client.systemctl("start network-online.target")
|
2019-11-23 23:05:12 +01:00
|
|
|
client.wait_for_unit("network-online.target")
|
|
|
|
client.succeed("machinectl pull-raw --verify=signature http://server/testimage.raw")
|
|
|
|
client.succeed(
|
|
|
|
"cmp /var/lib/machines/testimage.raw ${nspawnImages}/testimage.raw"
|
|
|
|
)
|
2022-05-06 15:38:43 +02:00
|
|
|
client.succeed("machinectl pull-tar --verify=signature http://server/testimage2.tar.xz")
|
|
|
|
client.succeed(
|
|
|
|
"cmp /var/lib/machines/testimage2/${pkgs.hello}/bin/hello ${pkgs.hello}/bin/hello"
|
|
|
|
)
|
2019-11-02 19:55:41 +01:00
|
|
|
'';
|
|
|
|
})
|