Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ $defs:
- narSize
- references
- ca
- storeDir
properties:
version:
type: integer
Expand Down Expand Up @@ -101,6 +102,12 @@ $defs:
If the store object is [content-addressed](@docroot@/store/store-object/content-address.md),
this is the content address of this store object's file system object, used to compute its store path.
Otherwise (i.e. if it is [input-addressed](@docroot@/glossary.md#gloss-input-addressed-store-object)), this is `null`.

storeDir:
type: string
title: Store Directory
description: |
The [store directory](@docroot@/store/store-path.md#store-directory) this store object belongs to (e.g. `/nix/store`).
additionalProperties: false

impure:
Expand All @@ -115,6 +122,7 @@ $defs:
- narSize
- references
- ca
- storeDir
# impure
- deriver
- registrationTime
Expand All @@ -127,6 +135,7 @@ $defs:
narSize: { $ref: "#/$defs/base/properties/narSize" }
references: { $ref: "#/$defs/base/properties/references" }
ca: { $ref: "#/$defs/base/properties/ca" }
storeDir: { $ref: "#/$defs/base/properties/storeDir" }
deriver:
oneOf:
- "$ref": "./store-path-v1.yaml"
Expand Down Expand Up @@ -192,6 +201,7 @@ $defs:
- narSize
- references
- ca
- storeDir
# impure
- deriver
- registrationTime
Expand All @@ -209,6 +219,7 @@ $defs:
narSize: { $ref: "#/$defs/base/properties/narSize" }
references: { $ref: "#/$defs/base/properties/references" }
ca: { $ref: "#/$defs/base/properties/ca" }
storeDir: { $ref: "#/$defs/base/properties/storeDir" }
deriver: { $ref: "#/$defs/impure/properties/deriver" }
registrationTime: { $ref: "#/$defs/impure/properties/registrationTime" }
ultimate: { $ref: "#/$defs/impure/properties/ultimate" }
Expand Down
1 change: 1 addition & 0 deletions src/libstore-tests/data/dummy-store/one-flat-file.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
"references": [],
"registrationTime": null,
"signatures": [],
"storeDir": "/nix/store",
"ultimate": false,
"version": 2
}
Expand Down
1 change: 1 addition & 0 deletions src/libstore-tests/data/nar-info/json-1/impure.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
"asdf",
"qwer"
],
"storeDir": "/nix/store",
"ultimate": true,
"url": "nar/1w1fff338fvdw53sqgamddn1b2xgds473pv6y13gizdbqjv4i5p3.nar.xz",
"version": 1
Expand Down
1 change: 1 addition & 0 deletions src/libstore-tests/data/nar-info/json-1/pure.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,6 @@
"/nix/store/g1w7hy3qg1w7hy3qg1w7hy3qg1w7hy3q-bar",
"/nix/store/n5wkd9frr45pa74if5gpz9j7mifg27fh-foo"
],
"storeDir": "/nix/store",
"version": 1
}
1 change: 1 addition & 0 deletions src/libstore-tests/data/nar-info/json-2/impure.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
"asdf",
"qwer"
],
"storeDir": "/nix/store",
"ultimate": true,
"url": "nar/1w1fff338fvdw53sqgamddn1b2xgds473pv6y13gizdbqjv4i5p3.nar.xz",
"version": 2
Expand Down
1 change: 1 addition & 0 deletions src/libstore-tests/data/nar-info/json-2/pure.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,6 @@
"g1w7hy3qg1w7hy3qg1w7hy3qg1w7hy3q-bar",
"n5wkd9frr45pa74if5gpz9j7mifg27fh-foo"
],
"storeDir": "/nix/store",
"version": 2
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"references": [],
"registrationTime": null,
"signatures": [],
"storeDir": "/nix/store",
"ultimate": false,
"version": 1
}
1 change: 1 addition & 0 deletions src/libstore-tests/data/path-info/json-1/empty_pure.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@
"narHash": "sha256-FePFYIlMuycIXPZbWi7LGEiMmZSX9FMbaQenWBzm1Sc=",
"narSize": 0,
"references": [],
"storeDir": "/nix/store",
"version": 1
}
1 change: 1 addition & 0 deletions src/libstore-tests/data/path-info/json-1/impure.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"asdf",
"qwer"
],
"storeDir": "/nix/store",
"ultimate": true,
"version": 1
}
1 change: 1 addition & 0 deletions src/libstore-tests/data/path-info/json-1/pure.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,6 @@
"/nix/store/g1w7hy3qg1w7hy3qg1w7hy3qg1w7hy3q-bar",
"/nix/store/n5wkd9frr45pa74if5gpz9j7mifg27fh-foo"
],
"storeDir": "/nix/store",
"version": 1
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
"references": [],
"registrationTime": null,
"signatures": [],
"storeDir": "/nix/store",
"ultimate": false,
"version": 2
}
1 change: 1 addition & 0 deletions src/libstore-tests/data/path-info/json-2/empty_pure.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,6 @@
},
"narSize": 0,
"references": [],
"storeDir": "/nix/store",
"version": 2
}
1 change: 1 addition & 0 deletions src/libstore-tests/data/path-info/json-2/impure.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
"asdf",
"qwer"
],
"storeDir": "/nix/store",
"ultimate": true,
"version": 2
}
1 change: 1 addition & 0 deletions src/libstore-tests/data/path-info/json-2/pure.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,6 @@
"g1w7hy3qg1w7hy3qg1w7hy3qg1w7hy3q-bar",
"n5wkd9frr45pa74if5gpz9j7mifg27fh-foo"
],
"storeDir": "/nix/store",
"version": 2
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
"references": [],
"registrationTime": null,
"signatures": [],
"storeDir": "/nix/store",
"ultimate": false,
"version": 2
},
Expand All @@ -28,6 +29,7 @@
],
"registrationTime": null,
"signatures": [],
"storeDir": "/nix/store",
"ultimate": false,
"version": 2
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
],
"registrationTime": null,
"signatures": [],
"storeDir": "/nix/store",
"ultimate": false,
"version": 2
},
Expand Down Expand Up @@ -41,6 +42,7 @@
"fake-sig-1",
"fake-sig-2"
],
"storeDir": "/nix/store",
"ultimate": false,
"version": 2
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
"references": [],
"registrationTime": 23423,
"signatures": [],
"storeDir": "/nix/store",
"ultimate": false,
"version": 2
},
Expand All @@ -28,6 +29,7 @@
],
"registrationTime": 23423,
"signatures": [],
"storeDir": "/nix/store",
"ultimate": false,
"version": 2
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"references": [],
"registrationTime": 23423,
"signatures": [],
"storeDir": "/nix/store",
"ultimate": false,
"version": 2
},
Expand All @@ -31,6 +32,7 @@
],
"registrationTime": 23423,
"signatures": [],
"storeDir": "/nix/store",
"ultimate": false,
"version": 2
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"references": [],
"registrationTime": 23423,
"signatures": [],
"storeDir": "/nix/store",
"ultimate": true,
"version": 2
},
Expand All @@ -34,6 +35,7 @@
"fake-sig-1",
"fake-sig-2"
],
"storeDir": "/nix/store",
"ultimate": false,
"version": 2
},
Expand All @@ -60,6 +62,7 @@
],
"registrationTime": 23423,
"signatures": [],
"storeDir": "/nix/store",
"ultimate": false,
"version": 2
}
Expand Down
1 change: 1 addition & 0 deletions src/libstore-tests/path-info.cc
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ class PathInfoTestV2 : public CharacterizationTest, public LibStoreTest
static UnkeyedValidPathInfo makeEmpty()
{
return {
"/nix/store",
Hash::parseSRI("sha256-FePFYIlMuycIXPZbWi7LGEiMmZSX9FMbaQenWBzm1Sc="),
};
}
Expand Down
7 changes: 5 additions & 2 deletions src/libstore-tests/serve-protocol.cc
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ namespace nix {

const char serveProtoDir[] = "serve-protocol";

static constexpr std::string_view defaultStoreDir = "/nix/store";

struct ServeProtoTest : VersionedProtoTest<ServeProto, serveProtoDir>
{
/**
Expand Down Expand Up @@ -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",
};
Expand All @@ -290,6 +292,7 @@ VERSIONED_CHARACTERIZATION_TEST(
(std::tuple<UnkeyedValidPathInfo, UnkeyedValidPathInfo>{
({
UnkeyedValidPathInfo info{
std::string{defaultStoreDir},
Hash::parseSRI("sha256-FePFYIlMuycIXPZbWi7LGEiMmZSX9FMbaQenWBzm1Sc="),
};
info.deriver = StorePath{
Expand Down
8 changes: 8 additions & 0 deletions src/libstore-tests/worker-protocol.cc
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ namespace nix {

const char workerProtoDir[] = "worker-protocol";

static constexpr std::string_view defaultStoreDir = "/nix/store";

struct WorkerProtoTest : VersionedProtoTest<WorkerProto, workerProtoDir>
{
/**
Expand Down Expand Up @@ -426,6 +428,7 @@ VERSIONED_CHARACTERIZATION_TEST(
(std::tuple<UnkeyedValidPathInfo, UnkeyedValidPathInfo>{
({
UnkeyedValidPathInfo info{
std::string{defaultStoreDir},
Hash::parseSRI("sha256-FePFYIlMuycIXPZbWi7LGEiMmZSX9FMbaQenWBzm1Sc="),
};
info.registrationTime = 23423;
Expand All @@ -434,6 +437,7 @@ VERSIONED_CHARACTERIZATION_TEST(
}),
({
UnkeyedValidPathInfo info{
std::string{defaultStoreDir},
Hash::parseSRI("sha256-FePFYIlMuycIXPZbWi7LGEiMmZSX9FMbaQenWBzm1Sc="),
};
info.deriver = StorePath{
Expand Down Expand Up @@ -462,6 +466,7 @@ VERSIONED_CHARACTERIZATION_TEST(
"g1w7hy3qg1w7hy3qg1w7hy3qg1w7hy3q-bar",
},
UnkeyedValidPathInfo{
std::string{defaultStoreDir},
Hash::parseSRI("sha256-FePFYIlMuycIXPZbWi7LGEiMmZSX9FMbaQenWBzm1Sc="),
},
};
Expand All @@ -475,6 +480,7 @@ VERSIONED_CHARACTERIZATION_TEST(
"g1w7hy3qg1w7hy3qg1w7hy3qg1w7hy3q-bar",
},
UnkeyedValidPathInfo{
std::string{defaultStoreDir},
Hash::parseSRI("sha256-FePFYIlMuycIXPZbWi7LGEiMmZSX9FMbaQenWBzm1Sc="),
},
};
Expand Down Expand Up @@ -509,6 +515,7 @@ VERSIONED_CHARACTERIZATION_TEST(
"g1w7hy3qg1w7hy3qg1w7hy3qg1w7hy3q-bar",
},
UnkeyedValidPathInfo{
std::string{defaultStoreDir},
Hash::parseSRI("sha256-FePFYIlMuycIXPZbWi7LGEiMmZSX9FMbaQenWBzm1Sc="),
},
};
Expand All @@ -523,6 +530,7 @@ VERSIONED_CHARACTERIZATION_TEST(
"g1w7hy3qg1w7hy3qg1w7hy3qg1w7hy3q-bar",
},
UnkeyedValidPathInfo{
std::string{defaultStoreDir},
Hash::parseSRI("sha256-FePFYIlMuycIXPZbWi7LGEiMmZSX9FMbaQenWBzm1Sc="),
},
};
Expand Down
2 changes: 1 addition & 1 deletion src/libstore/daemon.cc
Original file line number Diff line number Diff line change
Expand Up @@ -905,7 +905,7 @@ static void performOp(
auto path = WorkerProto::Serialise<StorePath>::read(*store, rconn);
auto deriver = WorkerProto::Serialise<std::optional<StorePath>>::read(*store, rconn);
auto narHash = Hash::parseAny(readString(conn.from), HashAlgorithm::SHA256);
ValidPathInfo info{path, narHash};
ValidPathInfo info{path, {*store, narHash}};
info.deriver = std::move(deriver);
info.references = WorkerProto::Serialise<StorePathSet>::read(*store, rconn);
conn.from >> info.registrationTime >> info.narSize >> info.ultimate;
Expand Down
2 changes: 1 addition & 1 deletion src/libstore/dummy-store.cc
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ struct DummyStoreImpl : DummyStore
/* compute path info on demand */
auto narHash =
hashPath({accessor, CanonPath::root}, FileSerialisationMethod::NixArchive, HashAlgorithm::SHA256);
auto info = std::make_shared<ValidPathInfo>(path, UnkeyedValidPathInfo{narHash.hash});
auto info = std::make_shared<ValidPathInfo>(path, UnkeyedValidPathInfo{*this, narHash.hash});
info->narSize = narHash.numBytesDigested;
info->ca = ContentAddress{
.method = ContentAddressMethod::Raw::Text,
Expand Down
2 changes: 1 addition & 1 deletion src/libstore/export-import.cc
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ StorePaths importPaths(Store & store, Source & source, CheckSigsFlag checkSigs)
auto deriver = readString(source);
auto narHash = hashString(HashAlgorithm::SHA256, saved.s);

ValidPathInfo info{path, narHash};
ValidPathInfo info{path, {store, narHash}};
if (deriver != "")
info.deriver = store.parseStorePath(deriver);
info.references = references;
Expand Down
9 changes: 7 additions & 2 deletions src/libstore/include/nix/store/nar-info.hh
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,13 @@ struct NarInfo : ValidPathInfo, UnkeyedNarInfo
{
}

NarInfo(StorePath path, Hash narHash)
: NarInfo{ValidPathInfo{std::move(path), UnkeyedValidPathInfo(narHash)}}
NarInfo(const StoreDirConfig & store, StorePath path, Hash narHash)
: NarInfo{ValidPathInfo{std::move(path), UnkeyedValidPathInfo{store, narHash}}}
{
}

NarInfo(std::string storeDir, StorePath path, Hash narHash)
: NarInfo{ValidPathInfo{std::move(path), UnkeyedValidPathInfo{std::move(storeDir), narHash}}}
{
}

Expand Down
Loading
Loading