mirror of
https://github.com/NixOS/nix
synced 2025-06-28 17:51:15 +02:00
Fix GC closure generation
This commit is contained in:
parent
6dbd5c26e6
commit
278114d559
4 changed files with 40 additions and 25 deletions
|
@ -50,7 +50,7 @@ void writeRegistry(const FlakeRegistry & registry, const Path & path)
|
|||
writeFile(path, json.dump(4)); // The '4' is the number of spaces used in the indentation in the json file.
|
||||
}
|
||||
|
||||
NonFlakeDep::NonFlakeDep(const nlohmann::json & json)
|
||||
AbstractDep::AbstractDep(const nlohmann::json & json)
|
||||
: ref(json["uri"])
|
||||
, narHash(Hash((std::string) json["narHash"]))
|
||||
{
|
||||
|
@ -58,7 +58,7 @@ NonFlakeDep::NonFlakeDep(const nlohmann::json & json)
|
|||
throw Error("lockfile contains mutable flakeref '%s'", ref);
|
||||
}
|
||||
|
||||
nlohmann::json NonFlakeDep::toJson() const
|
||||
nlohmann::json AbstractDep::toJson() const
|
||||
{
|
||||
nlohmann::json json;
|
||||
json["uri"] = ref.to_string();
|
||||
|
@ -66,22 +66,23 @@ nlohmann::json NonFlakeDep::toJson() const
|
|||
return json;
|
||||
}
|
||||
|
||||
Path AbstractDep::computeStorePath(Store & store) const
|
||||
{
|
||||
return store.makeFixedOutputPath(true, narHash, "source");
|
||||
}
|
||||
|
||||
FlakeDep::FlakeDep(const nlohmann::json & json)
|
||||
: FlakeInputs(json)
|
||||
, AbstractDep(json)
|
||||
, id(json["id"])
|
||||
, ref(json["uri"])
|
||||
, narHash(Hash((std::string) json["narHash"]))
|
||||
{
|
||||
if (!ref.isImmutable())
|
||||
throw Error("lockfile contains mutable flakeref '%s'", ref);
|
||||
}
|
||||
|
||||
nlohmann::json FlakeDep::toJson() const
|
||||
{
|
||||
auto json = FlakeInputs::toJson();
|
||||
json.update(AbstractDep::toJson());
|
||||
json["id"] = id;
|
||||
json["uri"] = ref.to_string();
|
||||
json["narHash"] = narHash.to_string(SRI);
|
||||
return json;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
#pragma once
|
||||
|
||||
#include "types.hh"
|
||||
#include "flakeref.hh"
|
||||
|
||||
|
@ -8,6 +10,7 @@ namespace nix {
|
|||
|
||||
struct Value;
|
||||
class EvalState;
|
||||
class Store;
|
||||
|
||||
namespace flake {
|
||||
|
||||
|
@ -37,22 +40,29 @@ enum HandleLockFile : unsigned int
|
|||
, UseNewLockFile // `RecreateLockFile` without writing to file
|
||||
};
|
||||
|
||||
struct NonFlakeDep
|
||||
struct AbstractDep
|
||||
{
|
||||
FlakeRef ref;
|
||||
Hash narHash;
|
||||
|
||||
NonFlakeDep(const FlakeRef & flakeRef, const Hash & narHash)
|
||||
AbstractDep(const FlakeRef & flakeRef, const Hash & narHash)
|
||||
: ref(flakeRef), narHash(narHash) {};
|
||||
|
||||
NonFlakeDep(const nlohmann::json & json);
|
||||
AbstractDep(const nlohmann::json & json);
|
||||
|
||||
nlohmann::json toJson() const;
|
||||
|
||||
Path computeStorePath(Store & store) const;
|
||||
};
|
||||
|
||||
struct NonFlakeDep : AbstractDep
|
||||
{
|
||||
using AbstractDep::AbstractDep;
|
||||
|
||||
bool operator ==(const NonFlakeDep & other) const
|
||||
{
|
||||
return ref == other.ref && narHash == other.narHash;
|
||||
}
|
||||
|
||||
nlohmann::json toJson() const;
|
||||
};
|
||||
|
||||
struct FlakeDep;
|
||||
|
@ -68,14 +78,12 @@ struct FlakeInputs
|
|||
nlohmann::json toJson() const;
|
||||
};
|
||||
|
||||
struct FlakeDep : FlakeInputs
|
||||
struct FlakeDep : FlakeInputs, AbstractDep
|
||||
{
|
||||
FlakeId id;
|
||||
FlakeRef ref;
|
||||
Hash narHash;
|
||||
|
||||
FlakeDep(const FlakeId & id, const FlakeRef & flakeRef, const Hash & narHash)
|
||||
: id(id), ref(flakeRef), narHash(narHash) {};
|
||||
: AbstractDep(flakeRef, narHash), id(id) {};
|
||||
|
||||
FlakeDep(const nlohmann::json & json);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue