aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorRobert Hensing <robert@roberthensing.nl>2020-11-13 17:49:27 +0100
committerRobert Hensing <robert@roberthensing.nl>2020-11-13 17:49:27 +0100
commitac5081d28035ef8d6a907fc3bff812d534719f74 (patch)
tree09eaabd7097a4aa345c9ecd3dd4e6ee7e7aa2e6e /src
parent258e5338d68c5d98090748bbbd49bd33a37c7954 (diff)
nix-build: Fix #4197 output order regression
Diffstat (limited to 'src')
-rwxr-xr-xsrc/nix-build/nix-build.cc22
1 files changed, 11 insertions, 11 deletions
diff --git a/src/nix-build/nix-build.cc b/src/nix-build/nix-build.cc
index f60e0706c..74fafd426 100755
--- a/src/nix-build/nix-build.cc
+++ b/src/nix-build/nix-build.cc
@@ -487,6 +487,7 @@ static void main_nix_build(int argc, char * * argv)
else {
std::vector<StorePathWithOutputs> pathsToBuild;
+ std::vector<std::pair<StorePath, std::string>> pathsToBuildOrdered;
std::map<StorePath, std::pair<size_t, StringSet>> drvMap;
@@ -498,6 +499,7 @@ static void main_nix_build(int argc, char * * argv)
throw Error("derivation '%s' lacks an 'outputName' attribute", store->printStorePath(drvPath));
pathsToBuild.push_back({drvPath, {outputName}});
+ pathsToBuildOrdered.push_back({drvPath, {outputName}});
auto i = drvMap.find(drvPath);
if (i != drvMap.end())
@@ -513,25 +515,23 @@ static void main_nix_build(int argc, char * * argv)
std::vector<StorePath> outPaths;
- for (auto & [drvPath, info] : drvMap) {
- auto & [counter, wantedOutputs] = info;
+ for (auto & [drvPath, outputName] : pathsToBuildOrdered) {
+ auto & [counter, _wantedOutputs] = drvMap.at({drvPath});
std::string drvPrefix = outLink;
if (counter)
drvPrefix += fmt("-%d", counter + 1);
auto builtOutputs = store->queryDerivationOutputMap(drvPath);
- for (auto & outputName : wantedOutputs) {
- auto outputPath = builtOutputs.at(outputName);
+ auto outputPath = builtOutputs.at(outputName);
- if (auto store2 = store.dynamic_pointer_cast<LocalFSStore>()) {
- std::string symlink = drvPrefix;
- if (outputName != "out") symlink += "-" + outputName;
- store2->addPermRoot(outputPath, absPath(symlink));
- }
-
- outPaths.push_back(outputPath);
+ if (auto store2 = store.dynamic_pointer_cast<LocalFSStore>()) {
+ std::string symlink = drvPrefix;
+ if (outputName != "out") symlink += "-" + outputName;
+ store2->addPermRoot(outputPath, absPath(symlink));
}
+
+ outPaths.push_back(outputPath);
}
logger->stop();