nixbld: update Nix patches

pull/20/head
Sebastien Bourdeauducq 2021-04-24 17:07:14 +08:00
parent 5e455cf60d
commit 43005f0f65
2 changed files with 33 additions and 49 deletions

View File

@ -1,18 +1,7 @@
From e9d0448929a46df1b5923d69989fa3ca4c9e47ba Mon Sep 17 00:00:00 2001 diff -Naur /nix/store/32wd1lrf55ymaz1aysrqffpxfgkwl6m4-source/src/libstore/build/local-derivation-goal.cc nix3/src/libstore/build/local-derivation-goal.cc
From: Astro <astro@spaceboyz.net> --- /nix/store/32wd1lrf55ymaz1aysrqffpxfgkwl6m4-source/src/libstore/build/local-derivation-goal.cc 1970-01-01 08:00:01.000000000 +0800
Date: Thu, 5 Nov 2020 17:21:09 +0100 +++ nix3/src/libstore/build/local-derivation-goal.cc 2021-04-24 16:29:52.493166702 +0800
Subject: [PATCH] networked derivations @@ -395,6 +395,8 @@
---
src/libstore/build/derivation-goal.cc | 14 ++++++++------
src/libstore/build/derivation-goal.hh | 6 ++++++
2 files changed, 14 insertions(+), 6 deletions(-)
diff --git a/src/libstore/build/derivation-goal.cc b/src/libstore/build/derivation-goal.cc
index bf2bad62c..ef4ce8a0b 100644
--- a/src/libstore/build/derivation-goal.cc
+++ b/src/libstore/build/derivation-goal.cc
@@ -1199,6 +1199,8 @@ void DerivationGoal::startBuilder()
additionalSandboxProfile = parsedDrv->getStringAttr("__sandboxProfile").value_or(""); additionalSandboxProfile = parsedDrv->getStringAttr("__sandboxProfile").value_or("");
#endif #endif
@ -21,7 +10,7 @@ index bf2bad62c..ef4ce8a0b 100644
/* Are we doing a chroot build? */ /* Are we doing a chroot build? */
{ {
auto noChroot = parsedDrv->getBoolAttr("__noChroot"); auto noChroot = parsedDrv->getBoolAttr("__noChroot");
@@ -1216,7 +1218,7 @@ void DerivationGoal::startBuilder() @@ -412,7 +414,7 @@
else if (settings.sandboxMode == smDisabled) else if (settings.sandboxMode == smDisabled)
useChroot = false; useChroot = false;
else if (settings.sandboxMode == smRelaxed) else if (settings.sandboxMode == smRelaxed)
@ -29,8 +18,8 @@ index bf2bad62c..ef4ce8a0b 100644
+ useChroot = !allowNetwork() && !(derivationIsImpure(derivationType)) && !noChroot; + useChroot = !allowNetwork() && !(derivationIsImpure(derivationType)) && !noChroot;
} }
if (worker.store.storeDir != worker.store.realStoreDir) { auto & localStore = getLocalStore();
@@ -1430,7 +1432,7 @@ void DerivationGoal::startBuilder() @@ -623,7 +625,7 @@
"nogroup:x:65534:\n", sandboxGid())); "nogroup:x:65534:\n", sandboxGid()));
/* Create /etc/hosts with localhost entry. */ /* Create /etc/hosts with localhost entry. */
@ -39,7 +28,7 @@ index bf2bad62c..ef4ce8a0b 100644
writeFile(chrootRootDir + "/etc/hosts", "127.0.0.1 localhost\n::1 localhost\n"); writeFile(chrootRootDir + "/etc/hosts", "127.0.0.1 localhost\n::1 localhost\n");
/* Make the closure of the inputs available in the chroot, /* Make the closure of the inputs available in the chroot,
@@ -1617,7 +1619,7 @@ void DerivationGoal::startBuilder() @@ -810,7 +812,7 @@
us. us.
*/ */
@ -48,7 +37,7 @@ index bf2bad62c..ef4ce8a0b 100644
privateNetwork = true; privateNetwork = true;
userNamespaceSync.create(); userNamespaceSync.create();
@@ -1865,7 +1867,7 @@ void DerivationGoal::initEnv() @@ -1066,7 +1068,7 @@
to the builder is generally impure, but the output of to the builder is generally impure, but the output of
fixed-output derivations is by definition pure (since we fixed-output derivations is by definition pure (since we
already know the cryptographic hash of the output). */ already know the cryptographic hash of the output). */
@ -57,16 +46,16 @@ index bf2bad62c..ef4ce8a0b 100644
for (auto & i : parsedDrv->getStringsAttr("impureEnvVars").value_or(Strings())) for (auto & i : parsedDrv->getStringsAttr("impureEnvVars").value_or(Strings()))
env[i] = getEnv(i).value_or(""); env[i] = getEnv(i).value_or("");
} }
@@ -2487,7 +2489,7 @@ void DerivationGoal::runChild() @@ -1702,7 +1704,7 @@
/* Fixed-output derivations typically need to access the /* Fixed-output derivations typically need to access the
network, so give them access to /etc/resolv.conf and so network, so give them access to /etc/resolv.conf and so
on. */ on. */
- if (derivationIsImpure(derivationType)) { - if (derivationIsImpure(derivationType)) {
+ if (allowNetwork() || derivationIsImpure(derivationType)) { + if (allowNetwork() || derivationIsImpure(derivationType)) {
ss.push_back("/etc/resolv.conf");
// Only use nss functions to resolve hosts and // Only use nss functions to resolve hosts and
@@ -2728,7 +2730,7 @@ void DerivationGoal::runChild() // services. Dont use it for anything else that may
// be configured for this system. This limits the
@@ -1943,7 +1945,7 @@
sandboxProfile += "(import \"sandbox-defaults.sb\")\n"; sandboxProfile += "(import \"sandbox-defaults.sb\")\n";
@ -75,13 +64,12 @@ index bf2bad62c..ef4ce8a0b 100644
sandboxProfile += "(import \"sandbox-network.sb\")\n"; sandboxProfile += "(import \"sandbox-network.sb\")\n";
/* Add the output paths we'll use at build-time to the chroot */ /* Add the output paths we'll use at build-time to the chroot */
diff --git a/src/libstore/build/derivation-goal.hh b/src/libstore/build/derivation-goal.hh diff -Naur /nix/store/32wd1lrf55ymaz1aysrqffpxfgkwl6m4-source/src/libstore/build/local-derivation-goal.hh nix3/src/libstore/build/local-derivation-goal.hh
index 4976207e0..c57238403 100644 --- /nix/store/32wd1lrf55ymaz1aysrqffpxfgkwl6m4-source/src/libstore/build/local-derivation-goal.hh 1970-01-01 08:00:01.000000000 +0800
--- a/src/libstore/build/derivation-goal.hh +++ nix3/src/libstore/build/local-derivation-goal.hh 2021-04-24 16:35:23.060968488 +0800
+++ b/src/libstore/build/derivation-goal.hh @@ -40,6 +40,12 @@
@@ -134,6 +134,12 @@ private:
/* Whether to run the build in a private network namespace. */ Path chrootRootDir;
bool privateNetwork = false;
+ bool networked; + bool networked;
+ bool allowNetwork() + bool allowNetwork()
@ -89,9 +77,6 @@ index 4976207e0..c57238403 100644
+ return derivationIsFixed(drv->type()) || networked; + return derivationIsFixed(drv->type()) || networked;
+ } + }
+ +
typedef void (DerivationGoal::*GoalState)(); /* RAII object to delete the chroot directory. */
GoalState state; std::shared_ptr<AutoDelete> autoDelChroot;
--
2.29.0

View File

@ -1,8 +1,7 @@
diff --git a/src/libstore/build.cc b/src/libstore/build.cc diff -Naur nix-2.3.10.orig/src/libstore/build.cc nix-2.3.10/src/libstore/build.cc
index 53a0958a..16a98aec 100644 --- nix-2.3.10.orig/src/libstore/build.cc 1970-01-01 08:00:01.000000000 +0800
--- a/src/libstore/build.cc +++ nix-2.3.10/src/libstore/build.cc 2021-04-24 16:17:08.778875340 +0800
+++ b/src/libstore/build.cc @@ -840,9 +840,16 @@
@@ -809,9 +809,16 @@ private:
/* Whether this is a fixed-output derivation. */ /* Whether this is a fixed-output derivation. */
bool fixedOutput; bool fixedOutput;
@ -19,7 +18,7 @@ index 53a0958a..16a98aec 100644
typedef void (DerivationGoal::*GoalState)(); typedef void (DerivationGoal::*GoalState)();
GoalState state; GoalState state;
@@ -1179,6 +1186,8 @@ void DerivationGoal::haveDerivation() @@ -1181,6 +1188,8 @@
{ {
trace("have derivation"); trace("have derivation");
@ -28,7 +27,7 @@ index 53a0958a..16a98aec 100644
retrySubstitution = false; retrySubstitution = false;
for (auto & i : drv->outputs) for (auto & i : drv->outputs)
@@ -1195,6 +1204,8 @@ void DerivationGoal::haveDerivation() @@ -1197,6 +1206,8 @@
parsedDrv = std::make_unique<ParsedDerivation>(drvPath, *drv); parsedDrv = std::make_unique<ParsedDerivation>(drvPath, *drv);
@ -37,7 +36,7 @@ index 53a0958a..16a98aec 100644
/* We are first going to try to create the invalid output paths /* We are first going to try to create the invalid output paths
through substitutes. If that doesn't work, we'll build through substitutes. If that doesn't work, we'll build
them. */ them. */
@@ -1987,7 +1998,7 @@ void DerivationGoal::startBuilder() @@ -1932,7 +1943,7 @@
else if (settings.sandboxMode == smDisabled) else if (settings.sandboxMode == smDisabled)
useChroot = false; useChroot = false;
else if (settings.sandboxMode == smRelaxed) else if (settings.sandboxMode == smRelaxed)
@ -46,7 +45,7 @@ index 53a0958a..16a98aec 100644
} }
if (worker.store.storeDir != worker.store.realStoreDir) { if (worker.store.storeDir != worker.store.realStoreDir) {
@@ -2153,7 +2164,7 @@ void DerivationGoal::startBuilder() @@ -2109,7 +2120,7 @@
"nogroup:x:65534:\n") % sandboxGid).str()); "nogroup:x:65534:\n") % sandboxGid).str());
/* Create /etc/hosts with localhost entry. */ /* Create /etc/hosts with localhost entry. */
@ -55,7 +54,7 @@ index 53a0958a..16a98aec 100644
writeFile(chrootRootDir + "/etc/hosts", "127.0.0.1 localhost\n::1 localhost\n"); writeFile(chrootRootDir + "/etc/hosts", "127.0.0.1 localhost\n::1 localhost\n");
/* Make the closure of the inputs available in the chroot, /* Make the closure of the inputs available in the chroot,
@@ -2361,7 +2372,7 @@ void DerivationGoal::startBuilder() @@ -2323,7 +2334,7 @@
us. us.
*/ */
@ -64,16 +63,16 @@ index 53a0958a..16a98aec 100644
privateNetwork = true; privateNetwork = true;
userNamespaceSync.create(); userNamespaceSync.create();
@@ -2573,7 +2584,7 @@ void DerivationGoal::initEnv() @@ -2534,7 +2545,7 @@
to the builder is generally impure, but the output of to the builder is generally impure, but the output of
fixed-output derivations is by definition pure (since we fixed-output derivations is by definition pure (since we
already know the cryptographic hash of the output). */ already know the cryptographic hash of the output). */
- if (fixedOutput) { - if (fixedOutput) {
+ if (allowNetwork()) { + if (allowNetwork()) {
for (auto & i : parsedDrv->getStringsAttr("impureEnvVars").value_or(Strings())) for (auto & i : parsedDrv->getStringsAttr("impureEnvVars").value_or(Strings()))
env[i] = getEnv(i).value_or(""); env[i] = getEnv(i);
} }
@@ -3184,7 +3195,7 @@ void DerivationGoal::runChild() @@ -2823,7 +2834,7 @@
/* Fixed-output derivations typically need to access the /* Fixed-output derivations typically need to access the
network, so give them access to /etc/resolv.conf and so network, so give them access to /etc/resolv.conf and so
on. */ on. */