aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--doc/manual/src/language/advanced-attributes.md6
-rw-r--r--src/libexpr/eval.cc6
-rw-r--r--src/libexpr/eval.hh5
-rw-r--r--src/libexpr/primops.cc14
-rw-r--r--src/libstore/build/local-derivation-goal.cc18
-rw-r--r--tests/functional/lang/eval-okay-derivation-legacy.err.exp6
-rw-r--r--tests/functional/lang/eval-okay-derivation-legacy.exp1
-rw-r--r--tests/functional/lang/eval-okay-derivation-legacy.nix12
8 files changed, 67 insertions, 1 deletions
diff --git a/doc/manual/src/language/advanced-attributes.md b/doc/manual/src/language/advanced-attributes.md
index ec21b9990..849c368c1 100644
--- a/doc/manual/src/language/advanced-attributes.md
+++ b/doc/manual/src/language/advanced-attributes.md
@@ -292,6 +292,12 @@ Derivations can declare some infrequently used optional attributes.
(associative) arrays. For example, the attribute `hardening.format = true`
ends up as the Bash associative array element `${hardening[format]}`.
+ > **Warning**
+ >
+ > If set to `true`, other advanced attributes such as [`allowedReferences`](#adv-attr-allowedReferences), [`allowedReferences`](#adv-attr-allowedReferences), [`allowedRequisites`](#adv-attr-allowedRequisites),
+ [`disallowedReferences`](#adv-attr-disallowedReferences) and [`disallowedRequisites`](#adv-attr-disallowedRequisites), maxSize, and maxClosureSize.
+ will have no effect.
+
- [`outputChecks`]{#adv-attr-outputChecks}\
When using [structured attributes](#adv-attr-structuredAttrs), the `outputChecks`
attribute allows defining checks per-output.
diff --git a/src/libexpr/eval.cc b/src/libexpr/eval.cc
index a925ce2d8..120130eb3 100644
--- a/src/libexpr/eval.cc
+++ b/src/libexpr/eval.cc
@@ -249,6 +249,12 @@ EvalState::EvalState(
, sRight(symbols.create("right"))
, sWrong(symbols.create("wrong"))
, sStructuredAttrs(symbols.create("__structuredAttrs"))
+ , sAllowedReferences(symbols.create("allowedReferences"))
+ , sAllowedRequisites(symbols.create("allowedRequisites"))
+ , sDisallowedReferences(symbols.create("disallowedReferences"))
+ , sDisallowedRequisites(symbols.create("disallowedRequisites"))
+ , sMaxSize(symbols.create("maxSize"))
+ , sMaxClosureSize(symbols.create("maxClosureSize"))
, sBuilder(symbols.create("builder"))
, sArgs(symbols.create("args"))
, sContentAddressed(symbols.create("__contentAddressed"))
diff --git a/src/libexpr/eval.hh b/src/libexpr/eval.hh
index e54eede40..086092518 100644
--- a/src/libexpr/eval.hh
+++ b/src/libexpr/eval.hh
@@ -162,7 +162,10 @@ public:
const Symbol sWith, sOutPath, sDrvPath, sType, sMeta, sName, sValue,
sSystem, sOverrides, sOutputs, sOutputName, sIgnoreNulls,
sFile, sLine, sColumn, sFunctor, sToString,
- sRight, sWrong, sStructuredAttrs, sBuilder, sArgs,
+ sRight, sWrong, sStructuredAttrs,
+ sAllowedReferences, sAllowedRequisites, sDisallowedReferences, sDisallowedRequisites,
+ sMaxSize, sMaxClosureSize,
+ sBuilder, sArgs,
sContentAddressed, sImpure,
sOutputHash, sOutputHashAlgo, sOutputHashMode,
sRecurseForDerivations,
diff --git a/src/libexpr/primops.cc b/src/libexpr/primops.cc
index 0951a54de..561492f86 100644
--- a/src/libexpr/primops.cc
+++ b/src/libexpr/primops.cc
@@ -1213,6 +1213,20 @@ drvName, Bindings * attrs, Value & v)
handleOutputs(ss);
}
+ if (i->name == state.sAllowedReferences)
+ warn("In a derivation named '%s', 'structuredAttrs' disables the effect of the derivation attribute 'allowedReferences'; use 'outputChecks.<output>.allowedReferences' instead", drvName);
+ if (i->name == state.sAllowedRequisites)
+ warn("In a derivation named '%s', 'structuredAttrs' disables the effect of the derivation attribute 'allowedRequisites'; use 'outputChecks.<output>.allowedRequisites' instead", drvName);
+ if (i->name == state.sDisallowedReferences)
+ warn("In a derivation named '%s', 'structuredAttrs' disables the effect of the derivation attribute 'disallowedReferences'; use 'outputChecks.<output>.disallowedReferences' instead", drvName);
+ if (i->name == state.sDisallowedRequisites)
+ warn("In a derivation named '%s', 'structuredAttrs' disables the effect of the derivation attribute 'disallowedRequisites'; use 'outputChecks.<output>.disallowedRequisites' instead", drvName);
+ if (i->name == state.sMaxSize)
+ warn("In a derivation named '%s', 'structuredAttrs' disables the effect of the derivation attribute 'maxSize'; use 'outputChecks.<output>.maxSize' instead", drvName);
+ if (i->name == state.sMaxClosureSize)
+ warn("In a derivation named '%s', 'structuredAttrs' disables the effect of the derivation attribute 'maxClosureSize'; use 'outputChecks.<output>.maxClosureSize' instead", drvName);
+
+
} else {
auto s = state.coerceToString(pos, *i->value, context, context_below, true).toOwned();
drv.env.emplace(key, s);
diff --git a/src/libstore/build/local-derivation-goal.cc b/src/libstore/build/local-derivation-goal.cc
index fb5ccc6f1..2c4e7f32d 100644
--- a/src/libstore/build/local-derivation-goal.cc
+++ b/src/libstore/build/local-derivation-goal.cc
@@ -3116,6 +3116,24 @@ void LocalDerivationGoal::checkOutputs(const std::map<std::string, ValidPathInfo
};
if (auto structuredAttrs = parsedDrv->getStructuredAttrs()) {
+ if (get(*structuredAttrs, "allowedReferences")){
+ warn("'structuredAttrs' disables the effect of the top-level attribute 'allowedReferences'; use 'outputChecks' instead");
+ }
+ if (get(*structuredAttrs, "allowedRequisites")){
+ warn("'structuredAttrs' disables the effect of the top-level attribute 'allowedRequisites'; use 'outputChecks' instead");
+ }
+ if (get(*structuredAttrs, "disallowedRequisites")){
+ warn("'structuredAttrs' disables the effect of the top-level attribute 'disallowedRequisites'; use 'outputChecks' instead");
+ }
+ if (get(*structuredAttrs, "disallowedReferences")){
+ warn("'structuredAttrs' disables the effect of the top-level attribute 'disallowedReferences'; use 'outputChecks' instead");
+ }
+ if (get(*structuredAttrs, "maxSize")){
+ warn("'structuredAttrs' disables the effect of the top-level attribute 'maxSize'; use 'outputChecks' instead");
+ }
+ if (get(*structuredAttrs, "maxClosureSize")){
+ warn("'structuredAttrs' disables the effect of the top-level attribute 'maxClosureSize'; use 'outputChecks' instead");
+ }
if (auto outputChecks = get(*structuredAttrs, "outputChecks")) {
if (auto output = get(*outputChecks, outputName)) {
Checks checks;
diff --git a/tests/functional/lang/eval-okay-derivation-legacy.err.exp b/tests/functional/lang/eval-okay-derivation-legacy.err.exp
new file mode 100644
index 000000000..94f0854dd
--- /dev/null
+++ b/tests/functional/lang/eval-okay-derivation-legacy.err.exp
@@ -0,0 +1,6 @@
+warning: In a derivation named 'eval-okay-derivation-legacy', 'structuredAttrs' disables the effect of the derivation attribute 'allowedReferences'; use 'outputChecks.<output>.allowedReferences' instead
+warning: In a derivation named 'eval-okay-derivation-legacy', 'structuredAttrs' disables the effect of the derivation attribute 'allowedRequisites'; use 'outputChecks.<output>.allowedRequisites' instead
+warning: In a derivation named 'eval-okay-derivation-legacy', 'structuredAttrs' disables the effect of the derivation attribute 'disallowedReferences'; use 'outputChecks.<output>.disallowedReferences' instead
+warning: In a derivation named 'eval-okay-derivation-legacy', 'structuredAttrs' disables the effect of the derivation attribute 'disallowedRequisites'; use 'outputChecks.<output>.disallowedRequisites' instead
+warning: In a derivation named 'eval-okay-derivation-legacy', 'structuredAttrs' disables the effect of the derivation attribute 'maxClosureSize'; use 'outputChecks.<output>.maxClosureSize' instead
+warning: In a derivation named 'eval-okay-derivation-legacy', 'structuredAttrs' disables the effect of the derivation attribute 'maxSize'; use 'outputChecks.<output>.maxSize' instead
diff --git a/tests/functional/lang/eval-okay-derivation-legacy.exp b/tests/functional/lang/eval-okay-derivation-legacy.exp
new file mode 100644
index 000000000..4f374a1aa
--- /dev/null
+++ b/tests/functional/lang/eval-okay-derivation-legacy.exp
@@ -0,0 +1 @@
+"/nix/store/mzgwvrjjir216ra58mwwizi8wj6y9ddr-eval-okay-derivation-legacy"
diff --git a/tests/functional/lang/eval-okay-derivation-legacy.nix b/tests/functional/lang/eval-okay-derivation-legacy.nix
new file mode 100644
index 000000000..b529cdf90
--- /dev/null
+++ b/tests/functional/lang/eval-okay-derivation-legacy.nix
@@ -0,0 +1,12 @@
+(builtins.derivationStrict {
+ name = "eval-okay-derivation-legacy";
+ system = "x86_64-linux";
+ builder = "/dontcare";
+ __structuredAttrs = true;
+ allowedReferences = [ ];
+ disallowedReferences = [ ];
+ allowedRequisites = [ ];
+ disallowedRequisites = [ ];
+ maxSize = 1234;
+ maxClosureSize = 12345;
+}).out