mirror of
https://github.com/NixOS/nix
synced 2025-07-06 09:11:47 +02:00
Warn against the use of indirect flakerefs in flake inputs
This commit is contained in:
parent
97487c58a1
commit
ca1b2dc617
1 changed files with 25 additions and 0 deletions
|
@ -740,6 +740,27 @@ LockedFlake lockFlake(
|
||||||
use --no-write-lock-file. */
|
use --no-write-lock-file. */
|
||||||
auto ref = (input2.ref && explicitCliOverrides.contains(inputAttrPath)) ? *input2.ref : *input.ref;
|
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) {
|
if (input.isFlake) {
|
||||||
auto inputFlake = getInputFlake(*input.ref);
|
auto inputFlake = getInputFlake(*input.ref);
|
||||||
|
|
||||||
|
@ -771,6 +792,8 @@ LockedFlake lockFlake(
|
||||||
oldLock ? followsPrefix : inputAttrPath,
|
oldLock ? followsPrefix : inputAttrPath,
|
||||||
inputFlake.path,
|
inputFlake.path,
|
||||||
false);
|
false);
|
||||||
|
|
||||||
|
warnRegistry(inputFlake.resolvedRef);
|
||||||
}
|
}
|
||||||
|
|
||||||
else {
|
else {
|
||||||
|
@ -783,6 +806,8 @@ LockedFlake lockFlake(
|
||||||
auto [accessor, resolvedRef, lockedRef] = fetchOrSubstituteTree(
|
auto [accessor, resolvedRef, lockedRef] = fetchOrSubstituteTree(
|
||||||
state, *input.ref, useRegistries, flakeCache);
|
state, *input.ref, useRegistries, flakeCache);
|
||||||
|
|
||||||
|
warnRegistry(resolvedRef);
|
||||||
|
|
||||||
// FIXME: allow input to be lazy.
|
// FIXME: allow input to be lazy.
|
||||||
auto storePath = copyInputToStore(state, lockedRef.input, input.ref->input, accessor);
|
auto storePath = copyInputToStore(state, lockedRef.input, input.ref->input, accessor);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue