From fa13d3f4f3d8fb6dc3e3fc87ac5a2e26d8b32d84 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Mon, 14 Jul 2014 12:19:27 +0200 Subject: [PATCH] build-remote.pl: Fix building multiple output derivations We were importing paths without sorting them topologically, leading to "path is not valid" errors. See e.g. http://hydra.nixos.org/build/12451761 --- src/libstore/remote-store.cc | 1 - src/nix-store/nix-store.cc | 4 +++- tests/remote-builds.nix | 5 +++-- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/libstore/remote-store.cc b/src/libstore/remote-store.cc index f566ccf53..3b021bb2a 100644 --- a/src/libstore/remote-store.cc +++ b/src/libstore/remote-store.cc @@ -35,7 +35,6 @@ template T readStorePaths(Source & from) } template PathSet readStorePaths(Source & from); -template Paths readStorePaths(Source & from); RemoteStore::RemoteStore() diff --git a/src/nix-store/nix-store.cc b/src/nix-store/nix-store.cc index 0196c2fc1..048f5c603 100644 --- a/src/nix-store/nix-store.cc +++ b/src/nix-store/nix-store.cc @@ -992,7 +992,9 @@ static void opServe(Strings opFlags, Strings opArgs) } case cmdExportPaths: { - exportPaths(*store, readStorePaths(in), false, out); + Paths sorted = topoSortPaths(*store, readStorePaths(in)); + reverse(sorted.begin(), sorted.end()); + exportPaths(*store, sorted, false, out); break; } diff --git a/tests/remote-builds.nix b/tests/remote-builds.nix index 571cdfbdd..eb80a7d7e 100644 --- a/tests/remote-builds.nix +++ b/tests/remote-builds.nix @@ -25,7 +25,8 @@ let system = "i686-linux"; PATH = "''${utils}/bin"; builder = "''${utils}/bin/sh"; - args = [ "-c" "echo Hello; mkdir $out; cat /proc/sys/kernel/hostname > $out/host; sleep 3" ]; + args = [ "-c" "echo Hello; mkdir $out $foo; cat /proc/sys/kernel/hostname > $out/host; ln -s $out $foo/bar; sleep 5" ]; + outputs = [ "out" "foo" ]; } ''; @@ -86,7 +87,7 @@ in # And a parallel build. my ($out1, $out2) = split /\s/, - $client->succeed("nix-store -r \$(nix-instantiate ${expr nodes.client.config 2} ${expr nodes.client.config 3})"); + $client->succeed('nix-store -r $(nix-instantiate ${expr nodes.client.config 2})\!out $(nix-instantiate ${expr nodes.client.config 3})\!out'); $slave1->succeed("test -e $out1 -o -e $out2"); $slave2->succeed("test -e $out1 -o -e $out2");