1 import ./make-test-python.nix ({pkgs, lib, ...}:
3 gpgKeyring = (pkgs.runCommand "gpg-keyring" { buildInputs = [ pkgs.gnupg ]; } ''
7 %echo Generating a basic OpenPGP key
14 Name-Email: bob@foo.bar
16 # Do a commit here, so that we can later print "done"
20 gpg --batch --generate-key foo
21 rm $out/S.gpg-agent $out/S.gpg-agent.*
22 gpg --export bob@foo.bar -a > $out/pubkey.gpg
25 nspawnImages = (pkgs.runCommand "localhost" { buildInputs = [ pkgs.coreutils pkgs.gnupg ]; } ''
29 # produce a testimage.raw
30 dd if=/dev/urandom of=$out/testimage.raw bs=$((1024*1024+7)) count=5
32 # produce a testimage2.tar.xz, containing the hello store path
33 tar cvJpf testimage2.tar.xz ${pkgs.hello}
35 # produce signature(s)
36 sha256sum testimage* > SHA256SUMS
37 export GNUPGHOME="$(mktemp -d)"
38 cp -R ${gpgKeyring}/* $GNUPGHOME
39 gpg --batch --sign --detach-sign --output SHA256SUMS.gpg SHA256SUMS
42 name = "systemd-nspawn";
45 server = { pkgs, ... }: {
46 networking.firewall.allowedTCPPorts = [ 80 ];
49 virtualHosts."server".root = nspawnImages;
52 client = { pkgs, ... }: {
53 environment.etc."systemd/import-pubring.gpg".source = "${gpgKeyring}/pubkey.gpg";
60 server.wait_for_unit("nginx.service")
61 client.wait_for_unit("network-online.target")
62 client.succeed("machinectl pull-raw --verify=signature http://server/testimage.raw")
64 "cmp /var/lib/machines/testimage.raw ${nspawnImages}/testimage.raw"
66 client.succeed("machinectl pull-tar --verify=signature http://server/testimage2.tar.xz")
68 "cmp /var/lib/machines/testimage2/${pkgs.hello}/bin/hello ${pkgs.hello}/bin/hello"