Skip to content

Commit bbde3da

Browse files
authored
Merge pull request #38 from DeterminateSystems/warn-registry-inputs
Warn against the use of indirect flakerefs in flake inputs
2 parents 97487c5 + a9c1751 commit bbde3da

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

src/libflake/flake/flake.cc

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -740,6 +740,29 @@ LockedFlake lockFlake(
740740
use --no-write-lock-file. */
741741
auto ref = (input2.ref && explicitCliOverrides.contains(inputAttrPath)) ? *input2.ref : *input.ref;
742742

743+
/* Warn against the use of indirect flakerefs
744+
(but only at top-level since we don't want
745+
to annoy users about flakes that are not
746+
under their control). */
747+
auto warnRegistry = [&](const FlakeRef & resolvedRef)
748+
{
749+
if (inputAttrPath.size() == 1 && !input.ref->input.isDirect()) {
750+
std::ostringstream s;
751+
printLiteralString(s, resolvedRef.to_string());
752+
warn(
753+
"Flake input '%1%' uses the flake registry. "
754+
"Using the registry in flake inputs is deprecated in Determinate Nix. "
755+
"To make your flake future-proof, add the following to '%2%':\n"
756+
"\n"
757+
" inputs.%1%.url = %3%;\n"
758+
"\n"
759+
"For more information, see: https://github.com/DeterminateSystems/nix-src/issues/37",
760+
inputAttrPathS,
761+
flake.path,
762+
s.str());
763+
}
764+
};
765+
743766
if (input.isFlake) {
744767
auto inputFlake = getInputFlake(*input.ref);
745768

@@ -771,6 +794,8 @@ LockedFlake lockFlake(
771794
oldLock ? followsPrefix : inputAttrPath,
772795
inputFlake.path,
773796
false);
797+
798+
warnRegistry(inputFlake.resolvedRef);
774799
}
775800

776801
else {
@@ -783,6 +808,8 @@ LockedFlake lockFlake(
783808
auto [accessor, resolvedRef, lockedRef] = fetchOrSubstituteTree(
784809
state, *input.ref, useRegistries, flakeCache);
785810

811+
warnRegistry(resolvedRef);
812+
786813
// FIXME: allow input to be lazy.
787814
auto storePath = copyInputToStore(state, lockedRef.input, input.ref->input, accessor);
788815

0 commit comments

Comments
 (0)