1 import ./make-test-python.nix ({ pkgs, lib, ... } :
4 lxd-image = import ../release.nix {
6 # Building documentation makes the test unnecessarily take a longer time:
7 documentation.enable = lib.mkForce false;
11 lxd-image-metadata = lxd-image.lxdMeta.${pkgs.stdenv.hostPlatform.system};
12 lxd-image-rootfs = lxd-image.lxdImage.${pkgs.stdenv.hostPlatform.system};
15 name = "lxd-image-server";
17 meta = with pkgs.lib.maintainers; {
18 maintainers = [ mkg20001 patryk27 ];
21 nodes.machine = { lib, ... }: {
28 lxc.lxcfs.enable = true;
32 security.pki.certificates = [
33 (builtins.readFile ./common/acme/server/ca.cert.pem)
40 services.lxd-image-server = {
48 services.nginx.virtualHosts."acme.test" = {
50 sslCertificate = ./common/acme/server/acme.test.cert.pem;
51 sslCertificateKey = ./common/acme/server/acme.test.key.pem;
55 "::1" = [ "acme.test" ];
60 machine.wait_for_unit("sockets.target")
61 machine.wait_for_unit("lxd.service")
62 machine.wait_for_file("/var/lib/lxd/unix.socket")
64 # It takes additional second for lxd to settle
67 # lxd expects the pool's directory to already exist
68 machine.succeed("mkdir /var/lxd-pool")
71 "cat ${./common/lxd/config.yaml} | lxd init --preseed"
75 "lxc image import ${lxd-image-metadata}/*/*.tar.xz ${lxd-image-rootfs}/*/*.tar.xz --alias nixos"
78 loc = "/var/www/simplestreams/images/iats/nixos/amd64/default/v1"
80 with subtest("push image to server"):
81 machine.succeed("lxc launch nixos test")
83 machine.succeed("lxc stop -f test")
84 machine.succeed("lxc publish --public test --alias=testimg")
85 machine.succeed("lxc image export testimg")
86 machine.succeed("ls >&2")
87 machine.succeed("mkdir -p " + loc)
88 machine.succeed("mv *.tar.gz " + loc)
90 with subtest("pull image from server"):
91 machine.succeed("lxc remote add img https://acme.test --protocol=simplestreams")
92 machine.succeed("lxc image list img: >&2")