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 @@ -83,7 +83,7 @@ properties:
description: |
A mapping from output names to their build trace entries.
additionalProperties:
"$ref": "build-trace-entry-v2.yaml#/$defs/value"
"$ref": "build-trace-entry-v2.yaml"

failure:
type: object
Expand Down
57 changes: 35 additions & 22 deletions doc/manual/source/protocols/json/schema/build-trace-entry-v2.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,21 +16,24 @@ description: |

- Version 1: Original format

- Version 2:
- Use `drvPath` not `drvHash` to refer to derivation in a more conventional way.
- Remove `dependentRealisations`
- Separate into `key` and `value`
- Version 2: Remove `dependentRealisations`

type: object
required:
- key
- value
- id
- outPath
- signatures
allOf:
- "$ref": "#/$defs/key"
- "$ref": "#/$defs/value"
properties:
key:
"$ref": "#/$defs/key"
value:
"$ref": "#/$defs/value"
additionalProperties: false
id: {}
outPath: {}
signatures: {}
additionalProperties:
dependentRealisations:
description: deprecated field
type: object

"$defs":
key:
Expand All @@ -40,20 +43,23 @@ additionalProperties: false
This is the "key" part, refering to a derivation and output.
type: object
required:
- drvPath
- outputName
- id
properties:
drvPath:
"$ref": "store-path-v1.yaml"
title: Derivation Path
description: |
The store path of the derivation that was built.
outputName:
id:
type: string
title: Output Name
title: Derivation Output ID
pattern: "^sha256:[0-9a-f]{64}![a-zA-Z_][a-zA-Z0-9_-]*$"
description: |
Name of the specific output (e.g., "out", "dev", "doc")
additionalProperties: false
Unique identifier for the derivation output that was built.

Format: `{hash-quotient-drv}!{output-name}`

- **hash-quotient-drv**: SHA-256 [hash of the quotient derivation](@docroot@/store/derivation/outputs/input-address.md#hash-quotient-drv).
Begins with `sha256:`.

- **output-name**: Name of the specific output (e.g., "out", "dev", "doc")

Example: `"sha256:ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad!foo"`

value:
title: Build Trace Value
Expand All @@ -71,6 +77,13 @@ additionalProperties: false
description: |
The path to the store object that resulted from building this derivation for the given output name.

patternProperties:
"^sha256:[0-9a-f]{64}![a-zA-Z_][a-zA-Z0-9_-]*$":
"$ref": "store-path-v1.yaml"
title: Dependent Store Path
description: Store path that this dependency resolved to during the build
additionalProperties: false

signatures:
type: array
title: Build Signatures
Expand Down
3 changes: 3 additions & 0 deletions src/json-schema-checks/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,9 @@ schemas = [
'schema' : schema_dir / 'build-trace-entry-v2.yaml',
'files' : [
'simple.json',
# The field is no longer supported, but we want to show that we
# ignore it during parsing.
'with-dependent-realisations.json',
'with-signature.json',
],
},
Expand Down
18 changes: 11 additions & 7 deletions src/libcmd/built-path.cc
Original file line number Diff line number Diff line change
Expand Up @@ -108,16 +108,20 @@ RealisedPath::Set BuiltPath::toRealisedPaths(Store & store) const
overloaded{
[&](const BuiltPath::Opaque & p) { res.insert(p.path); },
[&](const BuiltPath::Built & p) {
auto drvHashes = staticOutputHashes(store, store.readDerivation(p.drvPath->outPath()));
for (auto & [outputName, outputPath] : p.outputs) {
if (experimentalFeatureSettings.isEnabled(Xp::CaDerivations)) {
DrvOutput key{
.drvPath = p.drvPath->outPath(),
.outputName = outputName,
};
auto drvOutput = get(drvHashes, outputName);
if (!drvOutput)
throw Error(
"the derivation '%s' has unrealised output '%s' (derived-path.cc/toRealisedPaths)",
store.printStorePath(p.drvPath->outPath()),
outputName);
DrvOutput key{*drvOutput, outputName};
auto thisRealisation = store.queryRealisation(key);
// We’ve built it, so we must have the realisation.
assert(thisRealisation);
res.insert(Realisation{*thisRealisation, key});
assert(thisRealisation); // We’ve built it, so we must
// have the realisation
res.insert(Realisation{*thisRealisation, std::move(key)});
} else {
res.insert(outputPath);
}
Expand Down
16 changes: 14 additions & 2 deletions src/libstore-tests/build-result.cc
Original file line number Diff line number Diff line change
Expand Up @@ -75,13 +75,25 @@ INSTANTIATE_TEST_SUITE_P(
{
"foo",
{
.outPath = StorePath{"g1w7hy3qg1w7hy3qg1w7hy3qg1w7hy3q-foo"},
{
.outPath = StorePath{"g1w7hy3qg1w7hy3qg1w7hy3qg1w7hy3q-foo"},
},
DrvOutput{
.drvHash = Hash::parseSRI("sha256-b4afnqKCO9oWXgYHb9DeQ2berSwOjS27rSd9TxXDc/U="),
.outputName = "foo",
},
},
},
{
"bar",
{
.outPath = StorePath{"g1w7hy3qg1w7hy3qg1w7hy3qg1w7hy3q-bar"},
{
.outPath = StorePath{"g1w7hy3qg1w7hy3qg1w7hy3qg1w7hy3q-bar"},
},
DrvOutput{
.drvHash = Hash::parseSRI("sha256-b4afnqKCO9oWXgYHb9DeQ2berSwOjS27rSd9TxXDc/U="),
.outputName = "bar",
},
},
},
},
Expand Down
63 changes: 63 additions & 0 deletions src/libstore-tests/common-protocol.cc
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,69 @@ CHARACTERIZATION_TEST(
},
}))

CHARACTERIZATION_TEST(
drvOutput,
"drv-output",
(std::tuple<DrvOutput, DrvOutput>{
{
.drvHash = Hash::parseSRI("sha256-FePFYIlMuycIXPZbWi7LGEiMmZSX9FMbaQenWBzm1Sc="),
.outputName = "baz",
},
DrvOutput{
.drvHash = Hash::parseSRI("sha256-b4afnqKCO9oWXgYHb9DeQ2berSwOjS27rSd9TxXDc/U="),
.outputName = "quux",
},
}))

CHARACTERIZATION_TEST(
realisation,
"realisation",
(std::tuple<Realisation, Realisation>{
Realisation{
{
.outPath = StorePath{"g1w7hy3qg1w7hy3qg1w7hy3qg1w7hy3q-foo"},
},
{
.drvHash = Hash::parseSRI("sha256-FePFYIlMuycIXPZbWi7LGEiMmZSX9FMbaQenWBzm1Sc="),
.outputName = "baz",
},
},
Realisation{
{
.outPath = StorePath{"g1w7hy3qg1w7hy3qg1w7hy3qg1w7hy3q-foo"},
.signatures =
{
Signature{.keyName = "asdf", .sig = std::string(64, '\0')},
Signature{.keyName = "qwer", .sig = std::string(64, '\0')},
},
},
{
.drvHash = Hash::parseSRI("sha256-FePFYIlMuycIXPZbWi7LGEiMmZSX9FMbaQenWBzm1Sc="),
.outputName = "baz",
},
},
}))

READ_CHARACTERIZATION_TEST(
realisation_with_deps,
"realisation-with-deps",
(std::tuple<Realisation>{
Realisation{
{
.outPath = StorePath{"g1w7hy3qg1w7hy3qg1w7hy3qg1w7hy3q-foo"},
.signatures =
{
Signature{.keyName = "asdf", .sig = std::string(64, '\0')},
Signature{.keyName = "qwer", .sig = std::string(64, '\0')},
},
},
{
.drvHash = Hash::parseSRI("sha256-FePFYIlMuycIXPZbWi7LGEiMmZSX9FMbaQenWBzm1Sc="),
.outputName = "baz",
},
},
}))

CHARACTERIZATION_TEST(
vector,
"vector",
Expand Down
4 changes: 4 additions & 0 deletions src/libstore-tests/data/build-result/success.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
{
"builtOutputs": {
"bar": {
"dependentRealisations": {},
"id": "sha256:6f869f9ea2823bda165e06076fd0de4366dead2c0e8d2dbbad277d4f15c373f5!bar",
"outPath": "g1w7hy3qg1w7hy3qg1w7hy3qg1w7hy3q-bar",
"signatures": []
},
"foo": {
"dependentRealisations": {},
"id": "sha256:6f869f9ea2823bda165e06076fd0de4366dead2c0e8d2dbbad277d4f15c373f5!foo",
"outPath": "g1w7hy3qg1w7hy3qg1w7hy3qg1w7hy3q-foo",
"signatures": []
}
Expand Down
3 changes: 2 additions & 1 deletion src/libstore-tests/data/dummy-store/one-realisation.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
{
"buildTrace": {
"g1w7hy3qg1w7hy3qg1w7hy3qg1w7hy3q-bar.drv": {
"ungWv48Bz+pBQUDeXa4iI7ADYaOWF3qctBD/YfIAFa0=": {
"out": {
"dependentRealisations": {},
"outPath": "g1w7hy3qg1w7hy3qg1w7hy3qg1w7hy3q-foo",
"signatures": []
}
Expand Down
12 changes: 4 additions & 8 deletions src/libstore-tests/data/realisation/simple.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
{
"key": {
"drvPath": "g1w7hy3qg1w7hy3qg1w7hy3qg1w7hy3q-bar.drv",
"outputName": "foo"
},
"value": {
"outPath": "g1w7hy3qg1w7hy3qg1w7hy3qg1w7hy3q-foo",
"signatures": []
}
"dependentRealisations": {},
"id": "sha256:ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad!foo",
"outPath": "g1w7hy3qg1w7hy3qg1w7hy3qg1w7hy3q-foo.drv",
"signatures": []
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"dependentRealisations": {
"sha256:ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad!foo": "g1w7hy3qg1w7hy3qg1w7hy3qg1w7hy3q-foo.drv"
},
"id": "sha256:ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad!foo",
"outPath": "g1w7hy3qg1w7hy3qg1w7hy3qg1w7hy3q-foo.drv",
"signatures": []
}
16 changes: 6 additions & 10 deletions src/libstore-tests/data/realisation/with-signature.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
{
"key": {
"drvPath": "g1w7hy3qg1w7hy3qg1w7hy3qg1w7hy3q-bar.drv",
"outputName": "foo"
},
"value": {
"outPath": "g1w7hy3qg1w7hy3qg1w7hy3qg1w7hy3q-foo",
"signatures": [
"asdf:AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=="
]
}
"dependentRealisations": {},
"id": "sha256:ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad!foo",
"outPath": "g1w7hy3qg1w7hy3qg1w7hy3qg1w7hy3q-foo.drv",
"signatures": [
"asdf:AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=="
]
}
Binary file not shown.
37 changes: 0 additions & 37 deletions src/libstore-tests/data/serve-protocol/build-result-2.8.json

This file was deleted.

Binary file not shown.
10 changes: 0 additions & 10 deletions src/libstore-tests/data/serve-protocol/drv-output-2.8.json

This file was deleted.

Binary file not shown.
13 changes: 0 additions & 13 deletions src/libstore-tests/data/serve-protocol/realisation-2.8.json

This file was deleted.

Binary file not shown.

This file was deleted.

Binary file not shown.
Loading
Loading