diff --git a/nixbld-etc-nixos/nix-3-networked-derivations.patch b/nixbld-etc-nixos/nix-3-networked-derivations.patch index 64766271..ffa2e755 100644 --- a/nixbld-etc-nixos/nix-3-networked-derivations.patch +++ b/nixbld-etc-nixos/nix-3-networked-derivations.patch @@ -1,18 +1,7 @@ -From e9d0448929a46df1b5923d69989fa3ca4c9e47ba Mon Sep 17 00:00:00 2001 -From: Astro -Date: Thu, 5 Nov 2020 17:21:09 +0100 -Subject: [PATCH] networked derivations - ---- - 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() +diff -Naur /nix/store/32wd1lrf55ymaz1aysrqffpxfgkwl6m4-source/src/libstore/build/local-derivation-goal.cc nix3/src/libstore/build/local-derivation-goal.cc +--- /nix/store/32wd1lrf55ymaz1aysrqffpxfgkwl6m4-source/src/libstore/build/local-derivation-goal.cc 1970-01-01 08:00:01.000000000 +0800 ++++ nix3/src/libstore/build/local-derivation-goal.cc 2021-04-24 16:29:52.493166702 +0800 +@@ -395,6 +395,8 @@ additionalSandboxProfile = parsedDrv->getStringAttr("__sandboxProfile").value_or(""); #endif @@ -21,7 +10,7 @@ index bf2bad62c..ef4ce8a0b 100644 /* Are we doing a chroot build? */ { auto noChroot = parsedDrv->getBoolAttr("__noChroot"); -@@ -1216,7 +1218,7 @@ void DerivationGoal::startBuilder() +@@ -412,7 +414,7 @@ else if (settings.sandboxMode == smDisabled) useChroot = false; else if (settings.sandboxMode == smRelaxed) @@ -29,8 +18,8 @@ index bf2bad62c..ef4ce8a0b 100644 + useChroot = !allowNetwork() && !(derivationIsImpure(derivationType)) && !noChroot; } - if (worker.store.storeDir != worker.store.realStoreDir) { -@@ -1430,7 +1432,7 @@ void DerivationGoal::startBuilder() + auto & localStore = getLocalStore(); +@@ -623,7 +625,7 @@ "nogroup:x:65534:\n", sandboxGid())); /* 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"); /* Make the closure of the inputs available in the chroot, -@@ -1617,7 +1619,7 @@ void DerivationGoal::startBuilder() +@@ -810,7 +812,7 @@ us. */ @@ -48,7 +37,7 @@ index bf2bad62c..ef4ce8a0b 100644 privateNetwork = true; userNamespaceSync.create(); -@@ -1865,7 +1867,7 @@ void DerivationGoal::initEnv() +@@ -1066,7 +1068,7 @@ to the builder is generally impure, but the output of fixed-output derivations is by definition pure (since we 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())) 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 network, so give them access to /etc/resolv.conf and so on. */ - if (derivationIsImpure(derivationType)) { + if (allowNetwork() || derivationIsImpure(derivationType)) { - ss.push_back("/etc/resolv.conf"); - // Only use nss functions to resolve hosts and -@@ -2728,7 +2730,7 @@ void DerivationGoal::runChild() + // services. Don’t 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"; @@ -75,13 +64,12 @@ index bf2bad62c..ef4ce8a0b 100644 sandboxProfile += "(import \"sandbox-network.sb\")\n"; /* 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 -index 4976207e0..c57238403 100644 ---- a/src/libstore/build/derivation-goal.hh -+++ b/src/libstore/build/derivation-goal.hh -@@ -134,6 +134,12 @@ private: - /* Whether to run the build in a private network namespace. */ - bool privateNetwork = false; +diff -Naur /nix/store/32wd1lrf55ymaz1aysrqffpxfgkwl6m4-source/src/libstore/build/local-derivation-goal.hh nix3/src/libstore/build/local-derivation-goal.hh +--- /nix/store/32wd1lrf55ymaz1aysrqffpxfgkwl6m4-source/src/libstore/build/local-derivation-goal.hh 1970-01-01 08:00:01.000000000 +0800 ++++ nix3/src/libstore/build/local-derivation-goal.hh 2021-04-24 16:35:23.060968488 +0800 +@@ -40,6 +40,12 @@ + + Path chrootRootDir; + bool networked; + bool allowNetwork() @@ -89,9 +77,6 @@ index 4976207e0..c57238403 100644 + return derivationIsFixed(drv->type()) || networked; + } + - typedef void (DerivationGoal::*GoalState)(); - GoalState state; + /* RAII object to delete the chroot directory. */ + std::shared_ptr autoDelChroot; --- -2.29.0 - diff --git a/nixbld-etc-nixos/nix-networked-derivations.diff b/nixbld-etc-nixos/nix-networked-derivations.diff index 496b04ab..10d9c49b 100644 --- a/nixbld-etc-nixos/nix-networked-derivations.diff +++ b/nixbld-etc-nixos/nix-networked-derivations.diff @@ -1,8 +1,7 @@ -diff --git a/src/libstore/build.cc b/src/libstore/build.cc -index 53a0958a..16a98aec 100644 ---- a/src/libstore/build.cc -+++ b/src/libstore/build.cc -@@ -809,9 +809,16 @@ private: +diff -Naur nix-2.3.10.orig/src/libstore/build.cc nix-2.3.10/src/libstore/build.cc +--- nix-2.3.10.orig/src/libstore/build.cc 1970-01-01 08:00:01.000000000 +0800 ++++ nix-2.3.10/src/libstore/build.cc 2021-04-24 16:17:08.778875340 +0800 +@@ -840,9 +840,16 @@ /* Whether this is a fixed-output derivation. */ bool fixedOutput; @@ -19,7 +18,7 @@ index 53a0958a..16a98aec 100644 typedef void (DerivationGoal::*GoalState)(); GoalState state; -@@ -1179,6 +1186,8 @@ void DerivationGoal::haveDerivation() +@@ -1181,6 +1188,8 @@ { trace("have derivation"); @@ -28,7 +27,7 @@ index 53a0958a..16a98aec 100644 retrySubstitution = false; for (auto & i : drv->outputs) -@@ -1195,6 +1204,8 @@ void DerivationGoal::haveDerivation() +@@ -1197,6 +1206,8 @@ parsedDrv = std::make_unique(drvPath, *drv); @@ -37,7 +36,7 @@ index 53a0958a..16a98aec 100644 /* We are first going to try to create the invalid output paths through substitutes. If that doesn't work, we'll build them. */ -@@ -1987,7 +1998,7 @@ void DerivationGoal::startBuilder() +@@ -1932,7 +1943,7 @@ else if (settings.sandboxMode == smDisabled) useChroot = false; else if (settings.sandboxMode == smRelaxed) @@ -46,7 +45,7 @@ index 53a0958a..16a98aec 100644 } if (worker.store.storeDir != worker.store.realStoreDir) { -@@ -2153,7 +2164,7 @@ void DerivationGoal::startBuilder() +@@ -2109,7 +2120,7 @@ "nogroup:x:65534:\n") % sandboxGid).str()); /* 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"); /* Make the closure of the inputs available in the chroot, -@@ -2361,7 +2372,7 @@ void DerivationGoal::startBuilder() +@@ -2323,7 +2334,7 @@ us. */ @@ -64,16 +63,16 @@ index 53a0958a..16a98aec 100644 privateNetwork = true; userNamespaceSync.create(); -@@ -2573,7 +2584,7 @@ void DerivationGoal::initEnv() +@@ -2534,7 +2545,7 @@ to the builder is generally impure, but the output of fixed-output derivations is by definition pure (since we already know the cryptographic hash of the output). */ - if (fixedOutput) { + if (allowNetwork()) { 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 network, so give them access to /etc/resolv.conf and so on. */