From aeb803de9ad3cd449f7dc85588430ed5b21503eb Mon Sep 17 00:00:00 2001 From: eldritch horrors Date: Mon, 4 Mar 2024 04:30:34 +0100 Subject: Merge pull request #8047 from lovesegfault/always-allow-substitutes feat: add always-allow-substitutes (cherry picked from commit da2b59a08878b3c6c7074595e3b6d26b6928b4c1) Change-Id: I50481cd8fe643c673c610fec28bad84519a4d650 --- doc/manual/src/language/advanced-attributes.md | 3 +++ src/libstore/globals.hh | 8 ++++++++ src/libstore/parsed-derivations.cc | 2 +- 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/doc/manual/src/language/advanced-attributes.md b/doc/manual/src/language/advanced-attributes.md index 5e8aaeba0..4907f7457 100644 --- a/doc/manual/src/language/advanced-attributes.md +++ b/doc/manual/src/language/advanced-attributes.md @@ -261,6 +261,9 @@ Derivations can declare some infrequently used optional attributes. useful for very trivial derivations (such as `writeText` in Nixpkgs) that are cheaper to build than to substitute from a binary cache. + You may disable the effects of this attibute by enabling the + `always-allow-substitutes` configuration option in Nix. + > **Note** > > You need to have a builder configured which satisfies the diff --git a/src/libstore/globals.hh b/src/libstore/globals.hh index dba7d78ef..229f1a96a 100644 --- a/src/libstore/globals.hh +++ b/src/libstore/globals.hh @@ -261,6 +261,14 @@ public: For the exact format and examples, see [the manual chapter on remote builds](../advanced-topics/distributed-builds.md) )"}; + Setting alwaysAllowSubstitutes{ + this, false, "always-allow-substitutes", + R"( + If set to `true`, Nix will ignore the `allowSubstitutes` attribute in + derivations and always attempt to use available substituters. + For more information on `allowSubstitutes`, see [the manual chapter on advanced attributes](../language/advanced-attributes.md). + )"}; + Setting buildersUseSubstitutes{ this, false, "builders-use-substitutes", R"( diff --git a/src/libstore/parsed-derivations.cc b/src/libstore/parsed-derivations.cc index cc4a94fab..1d900c272 100644 --- a/src/libstore/parsed-derivations.cc +++ b/src/libstore/parsed-derivations.cc @@ -122,7 +122,7 @@ bool ParsedDerivation::willBuildLocally(Store & localStore) const bool ParsedDerivation::substitutesAllowed() const { - return getBoolAttr("allowSubstitutes", true); + return settings.alwaysAllowSubstitutes ? true : getBoolAttr("allowSubstitutes", true); } bool ParsedDerivation::useUidRange() const -- cgit v1.2.3