[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
01/08: Allow substitutes for builds that have preferLocalBuild set
From: |
Ludovic Courtès |
Subject: |
01/08: Allow substitutes for builds that have preferLocalBuild set |
Date: |
Thu, 02 Jul 2015 22:34:04 +0000 |
civodul pushed a commit to branch nix
in repository guix.
commit 2459458bc8257734ca78cb7a2db3df20bd730ec0
Author: Eelco Dolstra <address@hidden>
Date: Thu Jun 4 16:04:41 2015 +0200
Allow substitutes for builds that have preferLocalBuild set
Not substituting builds with "preferLocalBuild = true" was a bad idea,
because it didn't take the cost of dependencies into account. For
instance, if we can't substitute a fetchgit call, then we have to
download/build git and all its dependencies.
Partially reverts 5558652709f27e8a887580b77b93c705659d7a4b and adds a
new derivation attribute "allowSubstitutes" to specify whether a
derivation may be substituted.
---
nix/libstore/build.cc | 22 ++++++++++++++--------
nix/libstore/misc.cc | 4 ++--
nix/libstore/misc.hh | 2 ++
3 files changed, 18 insertions(+), 10 deletions(-)
diff --git a/nix/libstore/build.cc b/nix/libstore/build.cc
index 85a818b..11ca6cf 100644
--- a/nix/libstore/build.cc
+++ b/nix/libstore/build.cc
@@ -1000,7 +1000,7 @@ void DerivationGoal::haveDerivation()
/* We are first going to try to create the invalid output paths
through substitutes. If that doesn't work, we'll build
them. */
- if (settings.useSubstitutes && !willBuildLocally(drv))
+ if (settings.useSubstitutes && substitutesAllowed(drv))
foreach (PathSet::iterator, i, invalidOutputs)
addWaitee(worker.makeSubstitutionGoal(*i, buildMode == bmRepair));
@@ -1197,13 +1197,6 @@ PathSet outputPaths(const DerivationOutputs & outputs)
}
-static string get(const StringPairs & map, const string & key)
-{
- StringPairs::const_iterator i = map.find(key);
- return i == map.end() ? (string) "" : i->second;
-}
-
-
static bool canBuildLocally(const string & platform)
{
return platform == settings.thisSystem
@@ -1214,12 +1207,25 @@ static bool canBuildLocally(const string & platform)
}
+static string get(const StringPairs & map, const string & key, const string &
def = "")
+{
+ StringPairs::const_iterator i = map.find(key);
+ return i == map.end() ? def : i->second;
+}
+
+
bool willBuildLocally(const Derivation & drv)
{
return get(drv.env, "preferLocalBuild") == "1" &&
canBuildLocally(drv.platform);
}
+bool substitutesAllowed(const Derivation & drv)
+{
+ return get(drv.env, "allowSubstitutes", "1") == "1";
+}
+
+
void DerivationGoal::tryToBuild()
{
trace("trying to build");
diff --git a/nix/libstore/misc.cc b/nix/libstore/misc.cc
index 6ecf878..22363af 100644
--- a/nix/libstore/misc.cc
+++ b/nix/libstore/misc.cc
@@ -120,7 +120,7 @@ void queryMissing(StoreAPI & store, const PathSet & targets,
if (invalid.empty()) continue;
todoDrv.insert(*i);
- if (settings.useSubstitutes && !willBuildLocally(drv))
+ if (settings.useSubstitutes && substitutesAllowed(drv))
query.insert(invalid.begin(), invalid.end());
}
@@ -144,7 +144,7 @@ void queryMissing(StoreAPI & store, const PathSet & targets,
PathSet outputs;
bool mustBuild = false;
- if (settings.useSubstitutes && !willBuildLocally(drv)) {
+ if (settings.useSubstitutes && substitutesAllowed(drv)) {
foreach (DerivationOutputs::iterator, j, drv.outputs) {
if (!wantOutput(j->first, i2.second)) continue;
if (!store.isValidPath(j->second.path)) {
diff --git a/nix/libstore/misc.hh b/nix/libstore/misc.hh
index 144cb7f..d3e31d5 100644
--- a/nix/libstore/misc.hh
+++ b/nix/libstore/misc.hh
@@ -34,5 +34,7 @@ void queryMissing(StoreAPI & store, const PathSet & targets,
bool willBuildLocally(const Derivation & drv);
+bool substitutesAllowed(const Derivation & drv);
+
}
- branch nix updated (e531520 -> 0dccab9), Ludovic Courtès, 2015/07/02
- 01/08: Allow substitutes for builds that have preferLocalBuild set,
Ludovic Courtès <=
- 03/08: Export outputPaths function, Ludovic Courtès, 2015/07/02
- 04/08: Make /nix/var/nix/db/reserved bigger, Ludovic Courtès, 2015/07/02
- 05/08: Use posix_fallocate to create /nix/var/nix/db/reserved, Ludovic Courtès, 2015/07/02
- 06/08: GC: Handle ENOSPC creating/moving to the trash directory, Ludovic Courtès, 2015/07/02
- 02/08: Use std::vector::data(), Ludovic Courtès, 2015/07/02
- 08/08: Typo, Ludovic Courtès, 2015/07/02
- 07/08: Preserve supplementary groups of build users, Ludovic Courtès, 2015/07/02