diff --git a/lib/build-vms.nix b/lib/build-vms.nix index 2c867a0985b..618194fd1db 100644 --- a/lib/build-vms.nix +++ b/lib/build-vms.nix @@ -12,42 +12,10 @@ rec { # Build a virtual network from an attribute set `{ machine1 = # config1; ... machineN = configN; }', where `machineX' is the - # hostname and `configX' is a NixOS system configuration. The - # result is a script that starts a QEMU instance for each virtual - # machine. Each machine is given an arbitrary IP address in the - # virtual network. + # hostname and `configX' is a NixOS system configuration. Each + # machine is given an arbitrary IP address in the virtual network. buildVirtualNetwork = - { nodes }: - - let nodes_ = lib.mapAttrs (n: buildVM nodes_) (assignIPAddresses nodes); in - - stdenv.mkDerivation { - name = "vms"; - buildCommand = - '' - ensureDir $out/vms - ${ - lib.concatMapStrings (vm: - '' - ln -sn ${vm.config.system.build.vm} $out/vms/${vm.config.networking.hostName} - '' - ) (lib.attrValues nodes_) - } - - ensureDir $out/bin - cat > $out/bin/run-vms < $out/test-script - ln -s ${vms}/bin/* $out/bin/ - ln -s ${testDriver}/bin/* $out/bin/ + ln -s ${testDriver}/bin/nixos-test-driver $out/bin/ + vms="$(for i in ${toString vms}; do echo $i/bin/run-*-vm; done)" wrapProgram $out/bin/nixos-test-driver \ - --add-flags "${vms}/vms/*/bin/run-*-vm" \ + --add-flags "$vms" \ --run "testScript=\"\$(cat $out/test-script)\"" \ --set testScript '"$testScript"' \ - --set VLANS '"${toString (map (m: m.config.virtualisation.vlans) (lib.attrValues vms.nodes))}"' \ + --set VLANS '"${toString vlans}"' + ln -s ${testDriver}/bin/nixos-test-driver $out/bin/nixos-run-vms + wrapProgram $out/bin/nixos-run-vms \ + --add-flags "$vms" \ + --set tests '"startAll; sleep 1e9;"' \ + --set VLANS '"${toString vlans}"' ''; # " test = runTests driver;