diff --git a/doc/manual/src/release-notes/rl-next.md b/doc/manual/src/release-notes/rl-next.md index 1c995f19f42..b2e0911b9d1 100644 --- a/doc/manual/src/release-notes/rl-next.md +++ b/doc/manual/src/release-notes/rl-next.md @@ -34,7 +34,7 @@ - The flake output function now accepts a parameter `meta`, which gives access to `sourceInfo` and such parameters in a robust manner, even when `self` can not be evaluated. This helps frameworks report error messages with locations, as trying to access the location previously resulted in an unhelpful infinite recursion when the error condition caused `self` to fail. - If an `outputs` function has a binding for all attributes (using `@`), you will be asked to add an ellipsis to avoid later confusion as to why `meta` is missing - which is necessary because of a limitation of Nix function semantics. This warning may occur in a dependency. + If an `outputs` function has a binding for all attributes (using `@`), you will be asked to add an ellipsis to avoid later confusion as to why `meta` is missing - which is necessary because of a limitation of Nix function semantics. - Flake follow paths at depths greater than 2 are now handled correctly, preventing "follows a non-existent input" errors. diff --git a/src/libexpr/flake/call-flake.nix b/src/libexpr/flake/call-flake.nix index 617723f33fc..75d59a074eb 100644 --- a/src/libexpr/flake/call-flake.nix +++ b/src/libexpr/flake/call-flake.nix @@ -84,7 +84,7 @@ let canRemove = isClosed && (builtins.functionBindsAllAttrs flake.outputs == false); removals = if acceptsMeta then [] else [ "meta" ]; - checked = if !acceptsMeta && !canRemove then warning else x: x; + checked = if isRoot && !acceptsMeta && !canRemove then warning else x: x; warning = warn "in flake ${toString outPath}: The flake's ${emphasize "outputs"} function does not accept the ${emphasize "meta"} argument.\nThis will become an error.\nPlease add ellipsis (${emphasize "..."}) to the function header for it to be compatible with both dated and upcoming versions of Flakes. Example use of ellipsis: ${emphasize "outputs = { self, ... }: "}."; in diff --git a/tests/flakes/check.sh b/tests/flakes/check.sh index 9c1e6880f39..a681effb390 100644 --- a/tests/flakes/check.sh +++ b/tests/flakes/check.sh @@ -2,7 +2,8 @@ source common.sh flakeDir=$TEST_ROOT/flake3 depDir=$TEST_ROOT/flakedep -mkdir -p $flakeDir $depDir +depDirB=$TEST_ROOT/flakedep2 +mkdir -p $flakeDir $depDir $depDirB cat > $depDir/flake.nix < $flakeDir/flake.nix < $depDirB/flake.nix +cat > $depDirB/flake.nix <&1 | grep -F "Please add ellipsis" + +cat $depDirB/flake.nix + +# However it should not warn when the flake is used as a dependency, because in that case the user may not own the flake and can't change it. If they do own it, they only need to know about it when working on the flake itself. +cat > $flakeDir/flake.nix <&1 | grep -F "Please add ellipsis" +nix flake check $flakeDir 2>&1 | grepQuietInverse "Please add ellipsis" cat > $flakeDir/flake.nix < $flakeDir/flake.nix <&1 | grep -v "Please add ellipsis" +nix flake check $flakeDir 2>&1 | grepQuietInverse "Please add ellipsis"