diff --git a/src/libexpr/call-flake.nix b/src/libexpr/call-flake.nix index c44d64885..79b3e804e 100644 --- a/src/libexpr/call-flake.nix +++ b/src/libexpr/call-flake.nix @@ -45,7 +45,7 @@ let else # FIXME: remove obsolete node.info. # Note: lock file entries are always final. - fetchTree (node.info or {} // removeAttrs node.locked ["dir"] // { final = true; }); + fetchTree (node.info or {} // removeAttrs node.locked ["dir"] // { __final = true; }); subdir = overrides.${key}.dir or node.locked.dir or ""; diff --git a/src/libfetchers/fetchers.cc b/src/libfetchers/fetchers.cc index 9717533d6..cea6e43ae 100644 --- a/src/libfetchers/fetchers.cc +++ b/src/libfetchers/fetchers.cc @@ -101,7 +101,7 @@ Input Input::fromAttrs(const Settings & settings, Attrs && attrs) auto allowedAttrs = inputScheme->allowedAttrs(); for (auto & [name, _] : attrs) - if (name != "type" && name != "final" && allowedAttrs.count(name) == 0) + if (name != "type" && name != "__final" && allowedAttrs.count(name) == 0) throw Error("input attribute '%s' not supported by scheme '%s'", name, schemeName); auto res = inputScheme->inputFromAttrs(settings, attrs); @@ -148,7 +148,7 @@ bool Input::isLocked() const bool Input::isFinal() const { - return maybeGetBoolAttr(attrs, "final").value_or(false); + return maybeGetBoolAttr(attrs, "__final").value_or(false); } Attrs Input::toAttrs() const @@ -189,7 +189,7 @@ std::pair Input::fetchToStore(ref store) const // getAccessorUnchecked(), but then we can't add // narHash. Or maybe narHash should be excluded from the // concept of "final" inputs? - final.attrs.insert_or_assign("final", Explicit(true)); + final.attrs.insert_or_assign("__final", Explicit(true)); assert(final.isFinal()); diff --git a/src/libfetchers/fetchers.hh b/src/libfetchers/fetchers.hh index e74625f7f..ce535e6fe 100644 --- a/src/libfetchers/fetchers.hh +++ b/src/libfetchers/fetchers.hh @@ -78,24 +78,28 @@ public: Attrs toAttrs() const; /** - * Check whether this is a "direct" input, that is, not + * Return whether this is a "direct" input, that is, not * one that goes through a registry. */ bool isDirect() const; /** - * Check whether this is a "locked" input, that is, it has + * Return whether this is a "locked" input, that is, it has * attributes like a Git revision or NAR hash that uniquely * identify its contents. */ bool isLocked() const; /** - * Check whether this is a "final" input, meaning that fetching it + * Return whether this is a "final" input, meaning that fetching it * will not add or change any attributes. For instance, a Git * input with a `rev` attribute but without a `lastModified` * attribute is considered locked but not final. Only "final" * inputs can be substituted from a binary cache. + * + * The "final" state is denoted by the presence of an attribute + * `__final = true`. This attribute is currently undocumented and + * for internal use only. */ bool isFinal() const; @@ -226,15 +230,12 @@ struct InputScheme */ virtual std::optional experimentalFeature() const; - /// See `Input::isDirect()`. virtual bool isDirect(const Input & input) const { return true; } - /// See `Input::getFingerprint()`. virtual std::optional getFingerprint(ref store, const Input & input) const { return std::nullopt; } - /// See `Input::isLocked()`. virtual bool isLocked(const Input & input) const { return false; } diff --git a/src/libfetchers/path.cc b/src/libfetchers/path.cc index 564ad6e71..f12c969af 100644 --- a/src/libfetchers/path.cc +++ b/src/libfetchers/path.cc @@ -72,7 +72,7 @@ struct PathInputScheme : InputScheme auto query = attrsToQuery(input.attrs); query.erase("path"); query.erase("type"); - query.erase("final"); + query.erase("__final"); return ParsedURL { .scheme = "path", .path = getStrAttr(input.attrs, "path"), diff --git a/src/libflake/flake/lockfile.cc b/src/libflake/flake/lockfile.cc index f80c27acd..668ed165f 100644 --- a/src/libflake/flake/lockfile.cc +++ b/src/libflake/flake/lockfile.cc @@ -48,8 +48,8 @@ LockedNode::LockedNode( fetchers::attrsToJSON(lockedRef.input.toAttrs())); // For backward compatibility, lock file entries are implicitly final. - assert(!lockedRef.input.attrs.contains("final")); - lockedRef.input.attrs.insert_or_assign("final", Explicit(true)); + assert(!lockedRef.input.attrs.contains("__final")); + lockedRef.input.attrs.insert_or_assign("__final", Explicit(true)); } StorePath LockedNode::computeStorePath(Store & store) const @@ -194,11 +194,11 @@ std::pair LockFile::toJSON() const if (auto lockedNode = node.dynamic_pointer_cast()) { n["original"] = fetchers::attrsToJSON(lockedNode->originalRef.toAttrs()); n["locked"] = fetchers::attrsToJSON(lockedNode->lockedRef.toAttrs()); - /* For backward compatibility, omit the "final" + /* For backward compatibility, omit the "__final" attribute. We never allow non-final inputs in lock files anyway. */ assert(lockedNode->lockedRef.input.isFinal()); - n["locked"].erase("final"); + n["locked"].erase("__final"); if (!lockedNode->isFlake) n["flake"] = false; }