aboutsummaryrefslogtreecommitdiff
path: root/src/nix-build/nix-build.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/nix-build/nix-build.cc')
-rwxr-xr-xsrc/nix-build/nix-build.cc41
1 files changed, 19 insertions, 22 deletions
diff --git a/src/nix-build/nix-build.cc b/src/nix-build/nix-build.cc
index f60e0706c..7b4a53919 100755
--- a/src/nix-build/nix-build.cc
+++ b/src/nix-build/nix-build.cc
@@ -17,7 +17,7 @@
#include "get-drvs.hh"
#include "common-eval-args.hh"
#include "attr-path.hh"
-#include "../nix/legacy.hh"
+#include "legacy.hh"
using namespace nix;
using namespace std::string_literals;
@@ -217,9 +217,9 @@ static void main_nix_build(int argc, char * * argv)
// read the shebang to understand which packages to read from. Since
// this is handled via nix-shell -p, we wrap our ruby script execution
// in ruby -e 'load' which ignores the shebangs.
- envCommand = (format("exec %1% %2% -e 'load(\"%3%\")' -- %4%") % execArgs % interpreter % script % joined.str()).str();
+ envCommand = (format("exec %1% %2% -e 'load(ARGV.shift)' -- %3% %4%") % execArgs % interpreter % shellEscape(script) % joined.str()).str();
} else {
- envCommand = (format("exec %1% %2% %3% %4%") % execArgs % interpreter % script % joined.str()).str();
+ envCommand = (format("exec %1% %2% %3% %4%") % execArgs % interpreter % shellEscape(script) % joined.str()).str();
}
}
@@ -240,8 +240,6 @@ static void main_nix_build(int argc, char * * argv)
myArgs.parseCmdline(args);
- initPlugins();
-
if (packages && fromArgs)
throw UsageError("'-p' and '-E' are mutually exclusive");
@@ -369,11 +367,8 @@ static void main_nix_build(int argc, char * * argv)
shell = drv->queryOutPath() + "/bin/bash";
} catch (Error & e) {
- logWarning({
- .name = "bashInteractive",
- .hint = hintfmt("%s; will use bash from your environment",
- (e.info().hint ? e.info().hint->str() : ""))
- });
+ logError(e.info());
+ notice("will use bash from your environment");
shell = "bash";
}
}
@@ -487,6 +482,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 +494,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 +510,25 @@ 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 builtOutputs = store->queryPartialDerivationOutputMap(drvPath);
- if (auto store2 = store.dynamic_pointer_cast<LocalFSStore>()) {
- std::string symlink = drvPrefix;
- if (outputName != "out") symlink += "-" + outputName;
- store2->addPermRoot(outputPath, absPath(symlink));
- }
+ auto maybeOutputPath = builtOutputs.at(outputName);
+ assert(maybeOutputPath);
+ auto outputPath = *maybeOutputPath;
- 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();