mirror of
https://github.com/NixOS/nix
synced 2025-07-04 03:01:47 +02:00
Merge pull request #38 from DeterminateSystems/warn-registry-inputs
Warn against the use of indirect flakerefs in flake inputs
This commit is contained in:
commit
bbde3da254
1 changed files with 27 additions and 0 deletions
|
@ -740,6 +740,29 @@ 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 in Determinate Nix. "
|
||||||
|
"To make your flake future-proof, add the following to '%2%':\n"
|
||||||
|
"\n"
|
||||||
|
" inputs.%1%.url = %3%;\n"
|
||||||
|
"\n"
|
||||||
|
"For more information, see: https://github.com/DeterminateSystems/nix-src/issues/37",
|
||||||
|
inputAttrPathS,
|
||||||
|
flake.path,
|
||||||
|
s.str());
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
if (input.isFlake) {
|
if (input.isFlake) {
|
||||||
auto inputFlake = getInputFlake(*input.ref);
|
auto inputFlake = getInputFlake(*input.ref);
|
||||||
|
|
||||||
|
@ -771,6 +794,8 @@ LockedFlake lockFlake(
|
||||||
oldLock ? followsPrefix : inputAttrPath,
|
oldLock ? followsPrefix : inputAttrPath,
|
||||||
inputFlake.path,
|
inputFlake.path,
|
||||||
false);
|
false);
|
||||||
|
|
||||||
|
warnRegistry(inputFlake.resolvedRef);
|
||||||
}
|
}
|
||||||
|
|
||||||
else {
|
else {
|
||||||
|
@ -783,6 +808,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