1
1
Fork 0
mirror of https://github.com/NixOS/nix.git synced 2025-12-15 13:31:05 +01:00

Make storeDir a part of UnkeyedValidPathInfo

The previous commit hacked it into the output of `nix path-info --json`,
this cleans that up my making it an actual field of that data type, and
part of the canonical JSON serializers for it (and `ValidPathInfo` and
`NarInfo`).

Beyond cleaning up the JSON code, this also opens the doors to things
like:

- Binary caches that contain store objects that don't all belong in the
  same store directory

- Relocatable store objects which carefully don't mention any store
  directory by absolute path, and instead use relative paths for
  anything. (#9549)
This commit is contained in:
John Ericson 2025-12-03 20:20:21 -05:00
parent 1ad13a1423
commit f9089deb20
36 changed files with 111 additions and 29 deletions

View file

@ -29,6 +29,7 @@
"references": [],
"registrationTime": null,
"signatures": [],
"storeDir": "/nix/store",
"ultimate": false,
"version": 2
}

View file

@ -15,6 +15,7 @@
"asdf",
"qwer"
],
"storeDir": "/nix/store",
"ultimate": true,
"url": "nar/1w1fff338fvdw53sqgamddn1b2xgds473pv6y13gizdbqjv4i5p3.nar.xz",
"version": 1

View file

@ -6,5 +6,6 @@
"/nix/store/g1w7hy3qg1w7hy3qg1w7hy3qg1w7hy3q-bar",
"/nix/store/n5wkd9frr45pa74if5gpz9j7mifg27fh-foo"
],
"storeDir": "/nix/store",
"version": 1
}

View file

@ -30,6 +30,7 @@
"asdf",
"qwer"
],
"storeDir": "/nix/store",
"ultimate": true,
"url": "nar/1w1fff338fvdw53sqgamddn1b2xgds473pv6y13gizdbqjv4i5p3.nar.xz",
"version": 2

View file

@ -17,5 +17,6 @@
"g1w7hy3qg1w7hy3qg1w7hy3qg1w7hy3q-bar",
"n5wkd9frr45pa74if5gpz9j7mifg27fh-foo"
],
"storeDir": "/nix/store",
"version": 2
}

View file

@ -6,6 +6,7 @@
"references": [],
"registrationTime": null,
"signatures": [],
"storeDir": "/nix/store",
"ultimate": false,
"version": 1
}

View file

@ -3,5 +3,6 @@
"narHash": "sha256-FePFYIlMuycIXPZbWi7LGEiMmZSX9FMbaQenWBzm1Sc=",
"narSize": 0,
"references": [],
"storeDir": "/nix/store",
"version": 1
}

View file

@ -12,6 +12,7 @@
"asdf",
"qwer"
],
"storeDir": "/nix/store",
"ultimate": true,
"version": 1
}

View file

@ -6,5 +6,6 @@
"/nix/store/g1w7hy3qg1w7hy3qg1w7hy3qg1w7hy3q-bar",
"/nix/store/n5wkd9frr45pa74if5gpz9j7mifg27fh-foo"
],
"storeDir": "/nix/store",
"version": 1
}

View file

@ -10,6 +10,7 @@
"references": [],
"registrationTime": null,
"signatures": [],
"storeDir": "/nix/store",
"ultimate": false,
"version": 2
}

View file

@ -7,5 +7,6 @@
},
"narSize": 0,
"references": [],
"storeDir": "/nix/store",
"version": 2
}

View file

@ -23,6 +23,7 @@
"asdf",
"qwer"
],
"storeDir": "/nix/store",
"ultimate": true,
"version": 2
}

View file

@ -17,5 +17,6 @@
"g1w7hy3qg1w7hy3qg1w7hy3qg1w7hy3q-bar",
"n5wkd9frr45pa74if5gpz9j7mifg27fh-foo"
],
"storeDir": "/nix/store",
"version": 2
}

View file

@ -11,6 +11,7 @@
"references": [],
"registrationTime": null,
"signatures": [],
"storeDir": "/nix/store",
"ultimate": false,
"version": 2
},
@ -28,6 +29,7 @@
],
"registrationTime": null,
"signatures": [],
"storeDir": "/nix/store",
"ultimate": false,
"version": 2
}

View file

@ -13,6 +13,7 @@
],
"registrationTime": null,
"signatures": [],
"storeDir": "/nix/store",
"ultimate": false,
"version": 2
},
@ -41,6 +42,7 @@
"fake-sig-1",
"fake-sig-2"
],
"storeDir": "/nix/store",
"ultimate": false,
"version": 2
}

View file

@ -11,6 +11,7 @@
"references": [],
"registrationTime": 23423,
"signatures": [],
"storeDir": "/nix/store",
"ultimate": false,
"version": 2
},
@ -28,6 +29,7 @@
],
"registrationTime": 23423,
"signatures": [],
"storeDir": "/nix/store",
"ultimate": false,
"version": 2
}

View file

@ -12,6 +12,7 @@
"references": [],
"registrationTime": 23423,
"signatures": [],
"storeDir": "/nix/store",
"ultimate": false,
"version": 2
},
@ -31,6 +32,7 @@
],
"registrationTime": 23423,
"signatures": [],
"storeDir": "/nix/store",
"ultimate": false,
"version": 2
}

View file

@ -12,6 +12,7 @@
"references": [],
"registrationTime": 23423,
"signatures": [],
"storeDir": "/nix/store",
"ultimate": true,
"version": 2
},
@ -34,6 +35,7 @@
"fake-sig-1",
"fake-sig-2"
],
"storeDir": "/nix/store",
"ultimate": false,
"version": 2
},
@ -60,6 +62,7 @@
],
"registrationTime": 23423,
"signatures": [],
"storeDir": "/nix/store",
"ultimate": false,
"version": 2
}

View file

@ -33,6 +33,7 @@ class PathInfoTestV2 : public CharacterizationTest, public LibStoreTest
static UnkeyedValidPathInfo makeEmpty()
{
return {
"/nix/store",
Hash::parseSRI("sha256-FePFYIlMuycIXPZbWi7LGEiMmZSX9FMbaQenWBzm1Sc="),
};
}

View file

@ -17,6 +17,8 @@ namespace nix {
const char serveProtoDir[] = "serve-protocol";
static constexpr std::string_view defaultStoreDir = "/nix/store";
struct ServeProtoTest : VersionedProtoTest<ServeProto, serveProtoDir>
{
/**
@ -263,12 +265,12 @@ VERSIONED_CHARACTERIZATION_TEST(
2 << 8 | 3,
(std::tuple<UnkeyedValidPathInfo, UnkeyedValidPathInfo>{
({
UnkeyedValidPathInfo info{Hash::dummy};
UnkeyedValidPathInfo info{std::string{defaultStoreDir}, Hash::dummy};
info.narSize = 34878;
info;
}),
({
UnkeyedValidPathInfo info{Hash::dummy};
UnkeyedValidPathInfo info{std::string{defaultStoreDir}, Hash::dummy};
info.deriver = StorePath{
"g1w7hy3qg1w7hy3qg1w7hy3qg1w7hy3q-bar.drv",
};
@ -290,6 +292,7 @@ VERSIONED_CHARACTERIZATION_TEST(
(std::tuple<UnkeyedValidPathInfo, UnkeyedValidPathInfo>{
({
UnkeyedValidPathInfo info{
std::string{defaultStoreDir},
Hash::parseSRI("sha256-FePFYIlMuycIXPZbWi7LGEiMmZSX9FMbaQenWBzm1Sc="),
};
info.deriver = StorePath{

View file

@ -17,6 +17,8 @@ namespace nix {
const char workerProtoDir[] = "worker-protocol";
static constexpr std::string_view defaultStoreDir = "/nix/store";
struct WorkerProtoTest : VersionedProtoTest<WorkerProto, workerProtoDir>
{
/**
@ -426,6 +428,7 @@ VERSIONED_CHARACTERIZATION_TEST(
(std::tuple<UnkeyedValidPathInfo, UnkeyedValidPathInfo>{
({
UnkeyedValidPathInfo info{
std::string{defaultStoreDir},
Hash::parseSRI("sha256-FePFYIlMuycIXPZbWi7LGEiMmZSX9FMbaQenWBzm1Sc="),
};
info.registrationTime = 23423;
@ -434,6 +437,7 @@ VERSIONED_CHARACTERIZATION_TEST(
}),
({
UnkeyedValidPathInfo info{
std::string{defaultStoreDir},
Hash::parseSRI("sha256-FePFYIlMuycIXPZbWi7LGEiMmZSX9FMbaQenWBzm1Sc="),
};
info.deriver = StorePath{
@ -462,6 +466,7 @@ VERSIONED_CHARACTERIZATION_TEST(
"g1w7hy3qg1w7hy3qg1w7hy3qg1w7hy3q-bar",
},
UnkeyedValidPathInfo{
std::string{defaultStoreDir},
Hash::parseSRI("sha256-FePFYIlMuycIXPZbWi7LGEiMmZSX9FMbaQenWBzm1Sc="),
},
};
@ -475,6 +480,7 @@ VERSIONED_CHARACTERIZATION_TEST(
"g1w7hy3qg1w7hy3qg1w7hy3qg1w7hy3q-bar",
},
UnkeyedValidPathInfo{
std::string{defaultStoreDir},
Hash::parseSRI("sha256-FePFYIlMuycIXPZbWi7LGEiMmZSX9FMbaQenWBzm1Sc="),
},
};
@ -509,6 +515,7 @@ VERSIONED_CHARACTERIZATION_TEST(
"g1w7hy3qg1w7hy3qg1w7hy3qg1w7hy3q-bar",
},
UnkeyedValidPathInfo{
std::string{defaultStoreDir},
Hash::parseSRI("sha256-FePFYIlMuycIXPZbWi7LGEiMmZSX9FMbaQenWBzm1Sc="),
},
};
@ -523,6 +530,7 @@ VERSIONED_CHARACTERIZATION_TEST(
"g1w7hy3qg1w7hy3qg1w7hy3qg1w7hy3q-bar",
},
UnkeyedValidPathInfo{
std::string{defaultStoreDir},
Hash::parseSRI("sha256-FePFYIlMuycIXPZbWi7LGEiMmZSX9FMbaQenWBzm1Sc="),
},
};