[M7] lockfile: pin top-level nixpkgs_rev + flake_utils_rev

This commit is contained in:
2026-05-16 00:20:11 +00:00
parent 7c10ea2382
commit 43a7d1f09d
9 changed files with 101 additions and 34 deletions

View File

@@ -54,14 +54,14 @@ auto round_trip(const Lockfile& l) -> Lockfile {
} // namespace
TEST_CASE("write round-trips a minimal lockfile", "[lockfile]") {
Lockfile l{1, {root_pkg("my-project", "0.1.0")}};
Lockfile l{.version = 1, .packages = {root_pkg("my-project", "0.1.0")}};
REQUIRE(round_trip(l) == l);
}
TEST_CASE("write round-trips a lockfile with deps", "[lockfile]") {
Lockfile l{
1,
{
.version = 1,
.packages = {
root_pkg("my-project", "0.1.0", {"fmt 10.2.1", "spdlog 1.13.0"}),
dep_pkg("fmt", "10.2.1", "fmt_10", "8a3f...c2d1"),
dep_pkg("spdlog", "1.13.0", "spdlog", "8a3f...c2d1"),
@@ -72,8 +72,8 @@ TEST_CASE("write round-trips a lockfile with deps", "[lockfile]") {
TEST_CASE("write round-trips lockfile recipe fields", "[lockfile]") {
Lockfile l{
1,
{
.version = 1,
.packages = {
LockfilePackage{
.name = "fmt",
.version = "10.2.1",
@@ -120,8 +120,8 @@ TEST_CASE("write round-trips lockfile recipe fields", "[lockfile]") {
TEST_CASE("Lockfile::nixpkgs_rev returns the shared rev", "[lockfile]") {
Lockfile l{
1,
{
.version = 1,
.packages = {
root_pkg("p", "0.1.0", {"fmt 10.2.1"}),
dep_pkg("fmt", "10.2.1", "fmt_10", "abc123"),
},
@@ -129,8 +129,19 @@ TEST_CASE("Lockfile::nixpkgs_rev returns the shared rev", "[lockfile]") {
REQUIRE(l.nixpkgs_rev() == "abc123");
}
TEST_CASE("write round-trips top-level nixpkgs_rev + flake_utils_rev pins",
"[lockfile]") {
Lockfile l{
.version = 1,
.nixpkgs_rev_pin = "549bd84d6279f9852cae6225e372cc67fb91a4c1",
.flake_utils_rev_pin = "11707dc2f618dd54ca8739b309ec4fc024de578b",
.packages = {root_pkg("p", "0.1.0")},
};
REQUIRE(round_trip(l) == l);
}
TEST_CASE("Lockfile::nixpkgs_rev is nullopt when no deps", "[lockfile]") {
Lockfile l{1, {root_pkg("p", "0.1.0")}};
Lockfile l{.version = 1, .packages = {root_pkg("p", "0.1.0")}};
REQUIRE_FALSE(l.nixpkgs_rev().has_value());
}