2019-06-04 18:01:21 +00:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "flakeref.hh"
|
|
|
|
|
2019-10-21 20:11:21 +00:00
|
|
|
#include <nlohmann/json_fwd.hpp>
|
2019-06-04 18:01:21 +00:00
|
|
|
|
|
|
|
namespace nix {
|
|
|
|
class Store;
|
|
|
|
}
|
|
|
|
|
|
|
|
namespace nix::flake {
|
|
|
|
|
2019-08-30 14:27:51 +00:00
|
|
|
struct LockedInput;
|
2019-06-04 18:01:21 +00:00
|
|
|
|
|
|
|
/* Lock file information about the dependencies of a flake. */
|
2019-08-30 14:27:51 +00:00
|
|
|
struct LockedInputs
|
2019-06-04 18:01:21 +00:00
|
|
|
{
|
2019-08-30 14:27:51 +00:00
|
|
|
std::map<FlakeId, LockedInput> inputs;
|
2019-06-04 18:01:21 +00:00
|
|
|
|
2019-08-30 14:27:51 +00:00
|
|
|
LockedInputs() {};
|
|
|
|
LockedInputs(const nlohmann::json & json);
|
2019-06-04 18:01:21 +00:00
|
|
|
|
|
|
|
nlohmann::json toJson() const;
|
2019-07-12 11:29:54 +00:00
|
|
|
|
2020-01-21 15:27:53 +00:00
|
|
|
bool isImmutable() const;
|
2019-06-04 18:01:21 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/* Lock file information about a flake input. */
|
2019-08-30 14:27:51 +00:00
|
|
|
struct LockedInput : LockedInputs
|
2019-06-04 18:01:21 +00:00
|
|
|
{
|
2019-09-18 19:17:27 +00:00
|
|
|
FlakeRef ref, originalRef;
|
2019-08-30 14:27:51 +00:00
|
|
|
Hash narHash;
|
2019-06-04 18:01:21 +00:00
|
|
|
|
2019-09-18 19:17:27 +00:00
|
|
|
LockedInput(const FlakeRef & ref, const FlakeRef & originalRef, const Hash & narHash)
|
|
|
|
: ref(ref), originalRef(originalRef), narHash(narHash)
|
2020-01-21 15:27:53 +00:00
|
|
|
{ }
|
2019-06-04 18:01:21 +00:00
|
|
|
|
2019-08-30 14:27:51 +00:00
|
|
|
LockedInput(const nlohmann::json & json);
|
2019-06-04 18:01:21 +00:00
|
|
|
|
2019-08-30 14:27:51 +00:00
|
|
|
bool operator ==(const LockedInput & other) const
|
2019-06-04 18:01:21 +00:00
|
|
|
{
|
|
|
|
return
|
2019-08-30 14:27:51 +00:00
|
|
|
ref == other.ref
|
2019-06-04 18:01:21 +00:00
|
|
|
&& narHash == other.narHash
|
2019-08-30 14:27:51 +00:00
|
|
|
&& inputs == other.inputs;
|
2019-06-04 18:01:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
nlohmann::json toJson() const;
|
2019-08-30 14:27:51 +00:00
|
|
|
|
|
|
|
Path computeStorePath(Store & store) const;
|
2019-06-04 18:01:21 +00:00
|
|
|
};
|
|
|
|
|
2019-06-04 18:08:13 +00:00
|
|
|
/* An entire lock file. Note that this cannot be a FlakeInput for the
|
2019-06-04 18:01:21 +00:00
|
|
|
top-level flake, because then the lock file would need to contain
|
|
|
|
the hash of the top-level flake, but committing the lock file
|
|
|
|
would invalidate that hash. */
|
2019-08-30 14:27:51 +00:00
|
|
|
struct LockFile : LockedInputs
|
2019-06-04 18:01:21 +00:00
|
|
|
{
|
|
|
|
bool operator ==(const LockFile & other) const
|
|
|
|
{
|
2019-08-30 14:27:51 +00:00
|
|
|
return inputs == other.inputs;
|
2019-06-04 18:01:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
LockFile() {}
|
2019-08-30 14:27:51 +00:00
|
|
|
LockFile(const nlohmann::json & json) : LockedInputs(json) {}
|
|
|
|
LockFile(LockedInput && dep)
|
2019-06-04 18:01:21 +00:00
|
|
|
{
|
2019-08-30 14:27:51 +00:00
|
|
|
inputs = std::move(dep.inputs);
|
2019-06-04 18:01:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
nlohmann::json toJson() const;
|
|
|
|
|
|
|
|
static LockFile read(const Path & path);
|
|
|
|
|
|
|
|
void write(const Path & path) const;
|
|
|
|
};
|
|
|
|
|
2019-06-04 18:34:44 +00:00
|
|
|
std::ostream & operator <<(std::ostream & stream, const LockFile & lockFile);
|
|
|
|
|
2019-06-04 18:01:21 +00:00
|
|
|
}
|
|
|
|
|