[M7] lockfile: pin top-level nixpkgs_rev + flake_utils_rev
This commit is contained in:
@@ -131,6 +131,12 @@ auto parse(const std::filesystem::path& path) -> util::Result<Lockfile> {
|
||||
if (auto v = root["version"].value<int>()) {
|
||||
lock.version = *v;
|
||||
}
|
||||
if (auto v = root["nixpkgs_rev"].value<std::string>()) {
|
||||
lock.nixpkgs_rev_pin = *v;
|
||||
}
|
||||
if (auto v = root["flake_utils_rev"].value<std::string>()) {
|
||||
lock.flake_utils_rev_pin = *v;
|
||||
}
|
||||
|
||||
if (const auto* arr = root["package"].as_array()) {
|
||||
lock.packages.reserve(arr->size());
|
||||
@@ -154,6 +160,12 @@ auto parse(const std::filesystem::path& path) -> util::Result<Lockfile> {
|
||||
auto write(const Lockfile& lock, const std::filesystem::path& path) -> util::Result<void> {
|
||||
toml::table root;
|
||||
root.insert_or_assign("version", lock.version);
|
||||
if (lock.nixpkgs_rev_pin) {
|
||||
root.insert_or_assign("nixpkgs_rev", *lock.nixpkgs_rev_pin);
|
||||
}
|
||||
if (lock.flake_utils_rev_pin) {
|
||||
root.insert_or_assign("flake_utils_rev", *lock.flake_utils_rev_pin);
|
||||
}
|
||||
|
||||
toml::array packages;
|
||||
for (const auto& p : lock.packages) {
|
||||
|
||||
@@ -24,12 +24,12 @@ struct LockfilePackage {
|
||||
|
||||
struct Lockfile {
|
||||
int version = 1;
|
||||
std::optional<std::string> nixpkgs_rev_pin;
|
||||
std::optional<std::string> flake_utils_rev_pin;
|
||||
std::vector<LockfilePackage> packages;
|
||||
|
||||
bool operator==(const Lockfile&) const = default;
|
||||
|
||||
// The nixpkgs revision is shared across every dep package per SPEC §5.
|
||||
// Returns the first non-empty rev seen, or nullopt if no deps are pinned.
|
||||
[[nodiscard]] auto nixpkgs_rev() const -> std::optional<std::string>;
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user