From ca1b2dc6179f0a4d04f5ed117df9df1f04b38274 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Fri, 25 Apr 2025 21:16:27 +0200 Subject: [PATCH 1/2] Warn against the use of indirect flakerefs in flake inputs --- src/libflake/flake/flake.cc | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/src/libflake/flake/flake.cc b/src/libflake/flake/flake.cc index 6ea9626b9..0c219e267 100644 --- a/src/libflake/flake/flake.cc +++ b/src/libflake/flake/flake.cc @@ -740,6 +740,27 @@ LockedFlake lockFlake( use --no-write-lock-file. */ auto ref = (input2.ref && explicitCliOverrides.contains(inputAttrPath)) ? *input2.ref : *input.ref; + /* Warn against the use of indirect flakerefs + (but only at top-level since we don't want + to annoy users about flakes that are not + under their control). */ + auto warnRegistry = [&](const FlakeRef & resolvedRef) + { + if (inputAttrPath.size() == 1 && !input.ref->input.isDirect()) { + std::ostringstream s; + printLiteralString(s, resolvedRef.to_string()); + warn( + "Flake input '%1%' uses the flake registry. " + "Using the registry in flake inputs is deprecated. " + "To make your flake future-proof, add the following to '%2%':\n" + "\n" + " inputs.%1%.url = %3%;", + inputAttrPathS, + flake.path, + s.str()); + } + }; + if (input.isFlake) { auto inputFlake = getInputFlake(*input.ref); @@ -771,6 +792,8 @@ LockedFlake lockFlake( oldLock ? followsPrefix : inputAttrPath, inputFlake.path, false); + + warnRegistry(inputFlake.resolvedRef); } else { @@ -783,6 +806,8 @@ LockedFlake lockFlake( auto [accessor, resolvedRef, lockedRef] = fetchOrSubstituteTree( state, *input.ref, useRegistries, flakeCache); + warnRegistry(resolvedRef); + // FIXME: allow input to be lazy. auto storePath = copyInputToStore(state, lockedRef.input, input.ref->input, accessor); From a9c1751e2f9d52304db452de86466892aa4fad03 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Fri, 25 Apr 2025 21:51:32 +0200 Subject: [PATCH 2/2] Update src/libflake/flake/flake.cc Co-authored-by: Graham Christensen --- src/libflake/flake/flake.cc | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/libflake/flake/flake.cc b/src/libflake/flake/flake.cc index 0c219e267..3eb1333d5 100644 --- a/src/libflake/flake/flake.cc +++ b/src/libflake/flake/flake.cc @@ -751,10 +751,12 @@ LockedFlake lockFlake( printLiteralString(s, resolvedRef.to_string()); warn( "Flake input '%1%' uses the flake registry. " - "Using the registry in flake inputs is deprecated. " + "Using the registry in flake inputs is deprecated in Determinate Nix. " "To make your flake future-proof, add the following to '%2%':\n" "\n" - " inputs.%1%.url = %3%;", + " inputs.%1%.url = %3%;\n" + "\n" + "For more information, see: https://github.com/DeterminateSystems/nix-src/issues/37", inputAttrPathS, flake.path, s.str());