1 import ./make-test-python.nix ({pkgs, lib, ...}:
3 gpgKeyring = import ./common/gpg-keyring.nix { inherit pkgs; };
5 nspawnImages = (pkgs.runCommand "localhost" { buildInputs = [ pkgs.coreutils pkgs.gnupg ]; } ''
9 # produce a testimage.raw
10 dd if=/dev/urandom of=$out/testimage.raw bs=$((1024*1024+7)) count=5
12 # produce a testimage2.tar.xz, containing the hello store path
13 tar cvJpf testimage2.tar.xz ${pkgs.hello}
15 # produce signature(s)
16 sha256sum testimage* > SHA256SUMS
17 export GNUPGHOME="$(mktemp -d)"
18 cp -R ${gpgKeyring}/* $GNUPGHOME
19 gpg --batch --sign --detach-sign --output SHA256SUMS.gpg SHA256SUMS
22 name = "systemd-nspawn";
25 server = { pkgs, ... }: {
26 networking.firewall.allowedTCPPorts = [ 80 ];
29 virtualHosts."server".root = nspawnImages;
32 client = { pkgs, ... }: {
33 environment.etc."systemd/import-pubring.gpg".source = "${gpgKeyring}/pubkey.gpg";
40 server.wait_for_unit("nginx.service")
41 client.systemctl("start network-online.target")
42 client.wait_for_unit("network-online.target")
43 client.succeed("machinectl pull-raw --verify=signature http://server/testimage.raw")
45 "cmp /var/lib/machines/testimage.raw ${nspawnImages}/testimage.raw"
47 client.succeed("machinectl pull-tar --verify=signature http://server/testimage2.tar.xz")
49 "cmp /var/lib/machines/testimage2/${pkgs.hello}/bin/hello ${pkgs.hello}/bin/hello"