[Nix-dev] RE: [Nix-commits] SVN commit: nix - r25586 - nixos/trunk/lib

Sander van der Burg - EWI S.vanderBurg at tudelft.nl
Sun Jan 16 17:46:20 CET 2011


Hmmm, this breaks the nixos-build-vms command, because it no longer produces a derivation. Any idea how to fix it?


-----Original Message-----
From: nix-commits-bounces at cs.uu.nl on behalf of Eelco Dolstra
Sent: Sun 1/16/2011 3:21 PM
To: nix-commits at cs.uu.nl
Subject: [Nix-commits] SVN commit: nix - r25586 - nixos/trunk/lib
 
Author: eelco
Date: Sun Jan 16 14:21:47 2011
New Revision: 25586
URL: https://svn.nixos.org/websvn/nix/?rev=25586&sc=1

Log:
* Remove "nix-build tests -A foo.vms; ./result/bin/run-vms" as a way
  to run the VMs of a test.  Instead, you can do

    $ nix-build tests -A foo.driver
    $ ./result/bin/nixos-run-vms

  This uses the test driver infrastructure, which is necessary in
  order to set up the VDE switches.

Modified:
   nixos/trunk/lib/build-vms.nix
   nixos/trunk/lib/testing.nix

Modified: nixos/trunk/lib/build-vms.nix
==============================================================================
--- nixos/trunk/lib/build-vms.nix	Sun Jan 16 13:04:40 2011	(r25585)
+++ nixos/trunk/lib/build-vms.nix	Sun Jan 16 14:21:47 2011	(r25586)
@@ -12,42 +12,10 @@
   
   # 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 <<EOF
-          #! ${stdenv.shell}
-          port=8080
-          for i in $out/vms/*; do
-            port2=\$((port++))
-            echo "forwarding localhost:\$port2 to \$(basename \$i):80"
-            QEMU_OPTS="-redir tcp:\$port2::80" \$i/bin/run-*-vm &
-          done
-          EOF
-          chmod +x $out/bin/run-vms
-        ''; # */
-      passthru = { nodes = nodes_; };
-    };
+    nodes: let nodesOut = lib.mapAttrs (n: buildVM nodesOut) (assignIPAddresses nodes); in nodesOut;
 
 
   buildVM =

Modified: nixos/trunk/lib/testing.nix
==============================================================================
--- nixos/trunk/lib/testing.nix	Sun Jan 16 13:04:40 2011	(r25585)
+++ nixos/trunk/lib/testing.nix	Sun Jan 16 14:21:47 2011	(r25586)
@@ -121,21 +121,24 @@
   call = f: f { inherit pkgs nixpkgs system; };
 
   complete = t: t // rec {
-    nodes =
+    nodes = buildVirtualNetwork (
       if t ? nodes then t.nodes else
       if t ? machine then { machine = t.machine; }
-      else { };
-      
-    vms = buildVirtualNetwork { inherit nodes; };
-    
+      else { } );
+
     testScript =
       # Call the test script with the computed nodes.
       if builtins.isFunction t.testScript
-      then t.testScript { inherit (vms) nodes; }
+      then t.testScript { inherit nodes; }
       else t.testScript;
       
-    # Generate a convenience wrapper for running the test driver
-    # interactively with the specified network.
+    vlans = map (m: m.config.virtualisation.vlans) (lib.attrValues nodes);
+
+    vms = map (m: m.config.system.build.vm) (lib.attrValues nodes);
+    
+    # Generate onvenience wrappers for running the test driver
+    # interactively with the specified network, and for starting the
+    # VMs from the command line.
     driver = runCommand "nixos-test-driver"
       { buildInputs = [ makeWrapper];
         inherit testScript;
@@ -143,13 +146,18 @@
       ''
         mkdir -p $out/bin
         echo "$testScript" > $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;
_______________________________________________
nix-commits mailing list
nix-commits at cs.uu.nl
http://mail.cs.uu.nl/mailman/listinfo/nix-commits

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.science.uu.nl/pipermail/nix-dev/attachments/20110116/b2a78fd8/attachment.html 


More information about the nix-dev mailing list