diff options
author | Eelco Dolstra <edolstra@gmail.com> | 2020-03-09 15:27:49 +0100 |
---|---|---|
committer | Eelco Dolstra <edolstra@gmail.com> | 2020-03-09 15:27:49 +0100 |
commit | 5a1514adb8dcec78c03f949868ae35215b9d62f9 (patch) | |
tree | b5faa90fc7ef54f5f38451d5bb24a3aa4c06c826 /src/libexpr/flake | |
parent | 73b6d87e17bbe3c8612af2b9f369d92d3726efbe (diff) |
Add 'flake' attribute to lock files to denote non-flakes
Diffstat (limited to 'src/libexpr/flake')
-rw-r--r-- | src/libexpr/flake/flake.cc | 2 | ||||
-rw-r--r-- | src/libexpr/flake/lockfile.cc | 2 | ||||
-rw-r--r-- | src/libexpr/flake/lockfile.hh | 14 |
3 files changed, 13 insertions, 5 deletions
diff --git a/src/libexpr/flake/flake.cc b/src/libexpr/flake/flake.cc index a30637262..4fa125f1b 100644 --- a/src/libexpr/flake/flake.cc +++ b/src/libexpr/flake/flake.cc @@ -530,7 +530,7 @@ LockedFlake lockFlake( auto [sourceInfo, lockedRef] = fetchOrSubstituteTree( state, input.ref, {}, lockFlags.useRegistries, flakeCache); newLocks.inputs.insert_or_assign(id, - LockedInput(lockedRef, input.ref, sourceInfo.info)); + LockedInput(lockedRef, input.ref, sourceInfo.info, false)); } } } diff --git a/src/libexpr/flake/lockfile.cc b/src/libexpr/flake/lockfile.cc index bf55b4e3b..0a1795a16 100644 --- a/src/libexpr/flake/lockfile.cc +++ b/src/libexpr/flake/lockfile.cc @@ -72,6 +72,7 @@ LockedInput::LockedInput(const nlohmann::json & json) , lockedRef(getFlakeRef(json, "url", "uri", "locked")) , originalRef(getFlakeRef(json, "originalUrl", "originalUri", "original")) , info(parseTreeInfo(json)) + , isFlake(json.find("flake") != json.end() ? (bool) json["flake"] : true) { if (!lockedRef.input->isImmutable()) throw Error("lockfile contains mutable flakeref '%s'", lockedRef); @@ -95,6 +96,7 @@ nlohmann::json LockedInput::toJson() const json["original"] = fetchers::attrsToJson(originalRef.toAttrs()); json["locked"] = fetchers::attrsToJson(lockedRef.toAttrs()); json["info"] = treeInfoToJson(info); + if (!isFlake) json["flake"] = false; return json; } diff --git a/src/libexpr/flake/lockfile.hh b/src/libexpr/flake/lockfile.hh index 6203c40cb..51649df3d 100644 --- a/src/libexpr/flake/lockfile.hh +++ b/src/libexpr/flake/lockfile.hh @@ -39,9 +39,14 @@ struct LockedInput : LockedInputs { FlakeRef lockedRef, originalRef; TreeInfo info; - - LockedInput(const FlakeRef & lockedRef, const FlakeRef & originalRef, const TreeInfo & info) - : lockedRef(lockedRef), originalRef(originalRef), info(info) + bool isFlake = true; + + LockedInput( + const FlakeRef & lockedRef, + const FlakeRef & originalRef, + const TreeInfo & info, + bool isFlake = true) + : lockedRef(lockedRef), originalRef(originalRef), info(info), isFlake(isFlake) { } LockedInput(const nlohmann::json & json); @@ -52,7 +57,8 @@ struct LockedInput : LockedInputs lockedRef == other.lockedRef && originalRef == other.originalRef && info == other.info - && inputs == other.inputs; + && inputs == other.inputs + && isFlake == other.isFlake; } nlohmann::json toJson() const; |