From 56d75bf4fcb06da1a577c6e381f4afef57f30243 Mon Sep 17 00:00:00 2001 From: regnat Date: Wed, 17 Jun 2020 15:39:10 +0200 Subject: [PATCH 1/2] Reserve the `__contentAddressed` derivation parameter Not implementing anything here, just throwing an error if a derivation sets `__contentAddressed = true` without `--experimental-features content-addressed-paths` (and also with it as there's nothing implemented yet) --- src/libstore/build.cc | 11 +++++++++++ src/libstore/parsed-derivations.cc | 5 +++++ src/libstore/parsed-derivations.hh | 2 ++ 3 files changed, 18 insertions(+) diff --git a/src/libstore/build.cc b/src/libstore/build.cc index 53a0958aa..9b72175c7 100644 --- a/src/libstore/build.cc +++ b/src/libstore/build.cc @@ -809,6 +809,9 @@ private: /* Whether this is a fixed-output derivation. */ bool fixedOutput; + /* Whether this is a content adressed derivation */ + bool contentAddressed = false; + /* Whether to run the build in a private network namespace. */ bool privateNetwork = false; @@ -1195,6 +1198,14 @@ void DerivationGoal::haveDerivation() parsedDrv = std::make_unique(drvPath, *drv); + contentAddressed = parsedDrv->contentAddressed(); + + if (this->contentAddressed) { + settings.requireExperimentalFeature("content-addressed-paths"); + throw Error("content-addressed-paths isn't implemented yet"); + } + + /* We are first going to try to create the invalid output paths through substitutes. If that doesn't work, we'll build them. */ diff --git a/src/libstore/parsed-derivations.cc b/src/libstore/parsed-derivations.cc index 24f848e46..c7797b730 100644 --- a/src/libstore/parsed-derivations.cc +++ b/src/libstore/parsed-derivations.cc @@ -117,4 +117,9 @@ bool ParsedDerivation::substitutesAllowed() const return getBoolAttr("allowSubstitutes", true); } +bool ParsedDerivation::contentAddressed() const +{ + return getBoolAttr("__contentAddressed", false); +} + } diff --git a/src/libstore/parsed-derivations.hh b/src/libstore/parsed-derivations.hh index 7621342d7..d24d1eb4f 100644 --- a/src/libstore/parsed-derivations.hh +++ b/src/libstore/parsed-derivations.hh @@ -34,6 +34,8 @@ public: bool willBuildLocally() const; bool substitutesAllowed() const; + + bool contentAddressed() const; }; } From 480b54e1c6a200a2d4a39c1fa24fa195db12953f Mon Sep 17 00:00:00 2001 From: regnat Date: Wed, 17 Jun 2020 17:36:33 +0200 Subject: [PATCH 2/2] fixup! Reserve the `__contentAddressed` derivation parameter --- src/libstore/build.cc | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/src/libstore/build.cc b/src/libstore/build.cc index 9b72175c7..e1d812b09 100644 --- a/src/libstore/build.cc +++ b/src/libstore/build.cc @@ -809,9 +809,6 @@ private: /* Whether this is a fixed-output derivation. */ bool fixedOutput; - /* Whether this is a content adressed derivation */ - bool contentAddressed = false; - /* Whether to run the build in a private network namespace. */ bool privateNetwork = false; @@ -1198,9 +1195,7 @@ void DerivationGoal::haveDerivation() parsedDrv = std::make_unique(drvPath, *drv); - contentAddressed = parsedDrv->contentAddressed(); - - if (this->contentAddressed) { + if (parsedDrv->contentAddressed()) { settings.requireExperimentalFeature("content-addressed-paths"); throw Error("content-addressed-paths isn't implemented yet"); }