Skip to content

Commit 0c33c8d

Browse files
committed
Remove dependent realisations
This progress on #11896. It introduces some issues temporarily which will be fixed when #11928 is fixed.
1 parent 9246dca commit 0c33c8d

File tree

24 files changed

+146
-434
lines changed

24 files changed

+146
-434
lines changed
Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,21 @@
1-
{{#include build-trace-entry-v1-fixed.md}}
1+
{{#include build-trace-entry-v2-fixed.md}}
22

33
## Examples
44

55
### Simple build trace entry
66

77
```json
8-
{{#include schema/build-trace-entry-v1/simple.json}}
9-
```
10-
11-
### Build trace entry with dependencies
12-
13-
```json
14-
{{#include schema/build-trace-entry-v1/with-dependent-realisations.json}}
8+
{{#include schema/build-trace-entry-v2/simple.json}}
159
```
1610

1711
### Build trace entry with signature
1812

1913
```json
20-
{{#include schema/build-trace-entry-v1/with-signature.json}}
14+
{{#include schema/build-trace-entry-v2/with-signature.json}}
2115
```
2216

2317
<!--
2418
## Raw Schema
2519
26-
[JSON Schema for Build Trace Entry v1](schema/build-trace-entry-v1.json)
27-
-->
20+
[JSON Schema for Build Trace Entry v1](schema/build-trace-entry-v2.json)
21+
-->

doc/manual/source/protocols/json/meson.build

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ schemas = [
1717
'derivation-v4',
1818
'derivation-options-v1',
1919
'deriving-path-v1',
20-
'build-trace-entry-v1',
20+
'build-trace-entry-v2',
2121
'build-result-v1',
2222
'store-v1',
2323
]

doc/manual/source/protocols/json/schema/build-result-v1.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ properties:
8383
description: |
8484
A mapping from output names to their build trace entries.
8585
additionalProperties:
86-
"$ref": "build-trace-entry-v1.yaml"
86+
"$ref": "build-trace-entry-v2.yaml"
8787

8888
failure:
8989
type: object

doc/manual/source/protocols/json/schema/build-trace-entry-v1.yaml renamed to doc/manual/source/protocols/json/schema/build-trace-entry-v2.yaml

Lines changed: 13 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
"$schema": "http://json-schema.org/draft-04/schema"
2-
"$id": "https://nix.dev/manual/nix/latest/protocols/json/schema/build-trace-entry-v1.json"
2+
"$id": "https://nix.dev/manual/nix/latest/protocols/json/schema/build-trace-entry-v2.json"
33
title: Build Trace Entry
44
description: |
55
A record of a successful build outcome for a specific derivation output.
@@ -11,20 +11,29 @@ description: |
1111
> This JSON format is currently
1212
> [**experimental**](@docroot@/development/experimental-features.md#xp-feature-ca-derivations)
1313
> and subject to change.
14+
15+
Verision history:
16+
17+
- Version 1: Original format
18+
19+
- Version 2: Remove `dependentRealisations`
20+
21+
type: object
1422
required:
1523
- id
1624
- outPath
17-
- dependentRealisations
1825
- signatures
1926
allOf:
2027
- "$ref": "#/$defs/key"
2128
- "$ref": "#/$defs/value"
2229
properties:
2330
id: {}
2431
outPath: {}
25-
dependentRealisations: {}
2632
signatures: {}
27-
additionalProperties: false
33+
additionalProperties:
34+
dependentRealisations:
35+
description: deprecated field
36+
type: object
2837

2938
"$defs":
3039
key:
@@ -60,7 +69,6 @@ additionalProperties: false
6069
type: object
6170
required:
6271
- outPath
63-
- dependentRealisations
6472
- signatures
6573
properties:
6674
outPath:
@@ -69,19 +77,6 @@ additionalProperties: false
6977
description: |
7078
The path to the store object that resulted from building this derivation for the given output name.
7179
72-
dependentRealisations:
73-
type: object
74-
title: Underlying Base Build Trace
75-
description: |
76-
This is for [*derived*](@docroot@/store/build-trace.md#derived) build trace entries to ensure coherence.
77-
78-
Keys are derivation output IDs (same format as the main `id` field).
79-
Values are the store paths that those dependencies resolved to.
80-
81-
As described in the linked section on derived build trace traces, derived build trace entries must be kept in addition and not instead of the underlying base build entries.
82-
This is the set of base build trace entries that this derived build trace is derived from.
83-
(The set is also a map since this miniature base build trace must be coherent, mapping each key to a single value.)
84-
8580
patternProperties:
8681
"^sha256:[0-9a-f]{64}![a-zA-Z_][a-zA-Z0-9_-]*$":
8782
"$ref": "store-path-v1.yaml"

doc/manual/source/protocols/json/schema/store-v1.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ properties:
7070
"^[A-Za-z0-9+/]{43}=$":
7171
type: object
7272
additionalProperties:
73-
"$ref": "./build-trace-entry-v1.yaml#/$defs/value"
73+
"$ref": "./build-trace-entry-v2.yaml#/$defs/value"
7474
additionalProperties: false
7575

7676
"$defs":

src/json-schema-checks/meson.build

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,11 @@ schemas = [
6262
},
6363
{
6464
'stem' : 'build-trace-entry',
65-
'schema' : schema_dir / 'build-trace-entry-v1.yaml',
65+
'schema' : schema_dir / 'build-trace-entry-v2.yaml',
6666
'files' : [
6767
'simple.json',
68+
# The field is no longer supported, but we want to show that we
69+
# ignore it during parsing.
6870
'with-dependent-realisations.json',
6971
'with-signature.json',
7072
],

src/libstore-test-support/include/nix/store/tests/protocol.hh

Lines changed: 30 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -88,25 +88,38 @@ public:
8888
}
8989
};
9090

91-
#define VERSIONED_CHARACTERIZATION_TEST_NO_JSON(FIXTURE, NAME, STEM, VERSION, VALUE) \
92-
TEST_F(FIXTURE, NAME##_read) \
93-
{ \
94-
readProtoTest(STEM, VERSION, VALUE); \
95-
} \
96-
TEST_F(FIXTURE, NAME##_write) \
97-
{ \
98-
writeProtoTest(STEM, VERSION, VALUE); \
91+
#define VERSIONED_READ_CHARACTERIZATION_TEST_NO_JSON(FIXTURE, NAME, STEM, VERSION, VALUE) \
92+
TEST_F(FIXTURE, NAME##_read) \
93+
{ \
94+
readProtoTest(STEM, VERSION, VALUE); \
9995
}
10096

101-
#define VERSIONED_CHARACTERIZATION_TEST(FIXTURE, NAME, STEM, VERSION, VALUE) \
102-
VERSIONED_CHARACTERIZATION_TEST_NO_JSON(FIXTURE, NAME, STEM, VERSION, VALUE) \
103-
TEST_F(FIXTURE, NAME##_json_read) \
104-
{ \
105-
readJsonTest(STEM, VALUE); \
106-
} \
107-
TEST_F(FIXTURE, NAME##_json_write) \
108-
{ \
109-
writeJsonTest(STEM, VALUE); \
97+
#define VERSIONED_WRITE_CHARACTERIZATION_TEST_NO_JSON(FIXTURE, NAME, STEM, VERSION, VALUE) \
98+
TEST_F(FIXTURE, NAME##_write) \
99+
{ \
100+
writeProtoTest(STEM, VERSION, VALUE); \
110101
}
111102

103+
#define VERSIONED_CHARACTERIZATION_TEST_NO_JSON(FIXTURE, NAME, STEM, VERSION, VALUE) \
104+
VERSIONED_READ_CHARACTERIZATION_TEST_NO_JSON(FIXTURE, NAME, STEM, VERSION, VALUE) \
105+
VERSIONED_WRITE_CHARACTERIZATION_TEST_NO_JSON(FIXTURE, NAME, STEM, VERSION, VALUE)
106+
107+
#define VERSIONED_READ_CHARACTERIZATION_TEST(FIXTURE, NAME, STEM, VERSION, VALUE) \
108+
VERSIONED_READ_CHARACTERIZATION_TEST_NO_JSON(FIXTURE, NAME, STEM, VERSION, VALUE) \
109+
TEST_F(FIXTURE, NAME##_json_read) \
110+
{ \
111+
readJsonTest(STEM, VALUE); \
112+
}
113+
114+
#define VERSIONED_WRITE_CHARACTERIZATION_TEST(FIXTURE, NAME, STEM, VERSION, VALUE) \
115+
VERSIONED_WRITE_CHARACTERIZATION_TEST_NO_JSON(FIXTURE, NAME, STEM, VERSION, VALUE) \
116+
TEST_F(FIXTURE, NAME##_json_write) \
117+
{ \
118+
writeJsonTest(STEM, VALUE); \
119+
}
120+
121+
#define VERSIONED_CHARACTERIZATION_TEST(FIXTURE, NAME, STEM, VERSION, VALUE) \
122+
VERSIONED_READ_CHARACTERIZATION_TEST(FIXTURE, NAME, STEM, VERSION, VALUE) \
123+
VERSIONED_WRITE_CHARACTERIZATION_TEST(FIXTURE, NAME, STEM, VERSION, VALUE)
124+
112125
} // namespace nix

src/libstore-tests/common-protocol.cc

Lines changed: 23 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -47,24 +47,30 @@ class CommonProtoTest : public ProtoTest<CommonProto, commonProtoDir>
4747
}
4848
};
4949

50-
#define CHARACTERIZATION_TEST(NAME, STEM, VALUE) \
51-
TEST_F(CommonProtoTest, NAME##_read) \
52-
{ \
53-
readProtoTest(STEM, VALUE); \
54-
} \
55-
TEST_F(CommonProtoTest, NAME##_write) \
56-
{ \
57-
writeProtoTest(STEM, VALUE); \
58-
} \
59-
TEST_F(CommonProtoTest, NAME##_json_read) \
60-
{ \
61-
readJsonTest(STEM, VALUE); \
62-
} \
63-
TEST_F(CommonProtoTest, NAME##_json_write) \
64-
{ \
65-
writeJsonTest(STEM, VALUE); \
50+
#define READ_CHARACTERIZATION_TEST(NAME, STEM, VALUE) \
51+
TEST_F(CommonProtoTest, NAME##_read) \
52+
{ \
53+
readProtoTest(STEM, VALUE); \
54+
} \
55+
TEST_F(CommonProtoTest, NAME##_json_read) \
56+
{ \
57+
readJsonTest(STEM, VALUE); \
6658
}
6759

60+
#define WRITE_CHARACTERIZATION_TEST(NAME, STEM, VALUE) \
61+
TEST_F(CommonProtoTest, NAME##_write) \
62+
{ \
63+
writeProtoTest(STEM, VALUE); \
64+
} \
65+
TEST_F(CommonProtoTest, NAME##_json_write) \
66+
{ \
67+
writeJsonTest(STEM, VALUE); \
68+
}
69+
70+
#define CHARACTERIZATION_TEST(NAME, STEM, VALUE) \
71+
READ_CHARACTERIZATION_TEST(NAME, STEM, VALUE) \
72+
WRITE_CHARACTERIZATION_TEST(NAME, STEM, VALUE)
73+
6874
CHARACTERIZATION_TEST(
6975
string,
7076
"string",
@@ -141,24 +147,14 @@ CHARACTERIZATION_TEST(
141147
},
142148
}))
143149

144-
CHARACTERIZATION_TEST(
150+
READ_CHARACTERIZATION_TEST(
145151
realisation_with_deps,
146152
"realisation-with-deps",
147153
(std::tuple<Realisation>{
148154
Realisation{
149155
{
150156
.outPath = StorePath{"g1w7hy3qg1w7hy3qg1w7hy3qg1w7hy3q-foo"},
151157
.signatures = {"asdf", "qwer"},
152-
.dependentRealisations =
153-
{
154-
{
155-
DrvOutput{
156-
.drvHash = Hash::parseSRI("sha256-b4afnqKCO9oWXgYHb9DeQ2berSwOjS27rSd9TxXDc/U="),
157-
.outputName = "quux",
158-
},
159-
StorePath{"g1w7hy3qg1w7hy3qg1w7hy3qg1w7hy3q-foo"},
160-
},
161-
},
162158
},
163159
{
164160
.drvHash = Hash::parseSRI("sha256-FePFYIlMuycIXPZbWi7LGEiMmZSX9FMbaQenWBzm1Sc="),

src/libstore-tests/realisation.cc

Lines changed: 36 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -44,54 +44,45 @@ TEST_P(RealisationJsonTest, to_json)
4444
writeJsonTest(name, value);
4545
}
4646

47+
Realisation simple{
48+
{
49+
.outPath = StorePath{"g1w7hy3qg1w7hy3qg1w7hy3qg1w7hy3q-foo.drv"},
50+
},
51+
{
52+
.drvHash = Hash::parseExplicitFormatUnprefixed(
53+
"ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad",
54+
HashAlgorithm::SHA256,
55+
HashFormat::Base16),
56+
.outputName = "foo",
57+
},
58+
};
59+
4760
INSTANTIATE_TEST_SUITE_P(
4861
RealisationJSON,
4962
RealisationJsonTest,
50-
([] {
51-
Realisation simple{
52-
{
53-
.outPath = StorePath{"g1w7hy3qg1w7hy3qg1w7hy3qg1w7hy3q-foo.drv"},
54-
},
55-
{
56-
.drvHash = Hash::parseExplicitFormatUnprefixed(
57-
"ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad",
58-
HashAlgorithm::SHA256,
59-
HashFormat::Base16),
60-
.outputName = "foo",
61-
},
62-
};
63-
return ::testing::Values(
64-
std::pair{
65-
"simple",
66-
simple,
67-
},
68-
std::pair{
69-
"with-signature",
70-
[&] {
71-
auto r = simple;
72-
// FIXME actually sign properly
73-
r.signatures = {"asdfasdfasdf"};
74-
return r;
75-
}()},
76-
std::pair{
77-
"with-dependent-realisations",
78-
[&] {
79-
auto r = simple;
80-
r.dependentRealisations = {{
81-
{
82-
.drvHash = Hash::parseExplicitFormatUnprefixed(
83-
"ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad",
84-
HashAlgorithm::SHA256,
85-
HashFormat::Base16),
86-
.outputName = "foo",
87-
},
88-
StorePath{"g1w7hy3qg1w7hy3qg1w7hy3qg1w7hy3q-foo.drv"},
89-
}};
90-
return r;
91-
}(),
92-
});
93-
}
63+
::testing::Values(
64+
std::pair{
65+
"simple",
66+
simple,
67+
},
68+
std::pair{
69+
"with-signature",
70+
[&] {
71+
auto r = simple;
72+
// FIXME actually sign properly
73+
r.signatures = {"asdfasdfasdf"};
74+
return r;
75+
}(),
76+
}));
9477

95-
()));
78+
/**
79+
* We no longer have a notion of "dependent realisations", but we still
80+
* want to parse old realisation files. So make this just be a read test
81+
* (no write direction), accordingly.
82+
*/
83+
TEST_F(RealisationTest, dependent_realisations_from_json)
84+
{
85+
readJsonTest("with-dependent-realisations", simple);
86+
}
9687

9788
} // namespace nix

0 commit comments

Comments
 (0)