1
0
Fork 0
mirror of https://github.com/NixOS/nix synced 2025-06-30 19:57:59 +02:00

Record original flakerefs in the lock file again

If 'input.<name>.uri' changes, then the entry in the lockfile for
input <name> should be considered stale.

Also print some messages when lock file entries are added/updated.
This commit is contained in:
Eelco Dolstra 2019-09-18 21:17:27 +02:00
parent 092ee24627
commit c67407172d
No known key found for this signature in database
GPG key ID: 8170B4726D7198DE
6 changed files with 45 additions and 26 deletions

View file

@ -6,6 +6,7 @@ namespace nix::flake {
LockedInput::LockedInput(const nlohmann::json & json)
: LockedInputs(json)
, ref(json["uri"])
, originalRef(json["originalUri"])
, narHash(Hash((std::string) json["narHash"]))
{
if (!ref.isImmutable())
@ -16,6 +17,7 @@ nlohmann::json LockedInput::toJson() const
{
auto json = LockedInputs::toJson();
json["uri"] = ref.to_string();
json["originalUri"] = originalRef.to_string();
json["narHash"] = narHash.to_string(SRI);
return json;
}
@ -54,7 +56,7 @@ bool LockedInputs::isDirty() const
nlohmann::json LockFile::toJson() const
{
auto json = LockedInputs::toJson();
json["version"] = 2;
json["version"] = 3;
return json;
}
@ -64,7 +66,7 @@ LockFile LockFile::read(const Path & path)
auto json = nlohmann::json::parse(readFile(path));
auto version = json.value("version", 0);
if (version != 2)
if (version != 3)
throw Error("lock file '%s' has unsupported version %d", path, version);
return LockFile(json);