Skip to content

Commit a9fdd53

Browse files
Ericson2314haenoejonored
committed
Store DerivationOption instead Derivation, put in JSON format
This opens the door to derivations that *directly* specify their options, rather than "stealing" environment variables to do so. The A-Term derivation format used on disk didn't change --- we cannot do that for existing derivations, so those derivations will continue to not support separate options. But having a more flexible JSON format opens the door to extending the on-disk format in others, like directly using JSON, using CBOR, etc. Co-authored-by: HaeNoe <[email protected]> Co-authored-by: Jonathan Gibbons <[email protected]>
1 parent 00d2bf9 commit a9fdd53

28 files changed

+514
-104
lines changed

src/libexpr/primops.cc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1605,6 +1605,8 @@ static void derivationStrictInternal(EvalState & state, std::string_view drvName
16051605
drv.structuredAttrs = std::move(*jsonObject);
16061606
}
16071607

1608+
drv.options = derivationOptionsFromStructuredAttrs(*state.store, drv.inputDrvs, drv.env, drv.structuredAttrs);
1609+
16081610
/* Everything in the context of the strings in the derivation
16091611
attributes should be added as dependencies of the resulting
16101612
derivation. */

src/libstore-tests/data/derivation/ca/advanced-attributes-defaults.json

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,30 @@
1717
"srcs": []
1818
},
1919
"name": "advanced-attributes-defaults",
20+
"options": {
21+
"additionalSandboxProfile": "",
22+
"allowLocalNetworking": false,
23+
"allowSubstitutes": true,
24+
"exportReferencesGraph": {},
25+
"impureEnvVars": [],
26+
"impureHostDeps": [],
27+
"noChroot": false,
28+
"outputChecks": {
29+
"forAllOutputs": {
30+
"allowedReferences": null,
31+
"allowedRequisites": null,
32+
"disallowedReferences": [],
33+
"disallowedRequisites": [],
34+
"ignoreSelfRefs": true,
35+
"maxClosureSize": null,
36+
"maxSize": null
37+
}
38+
},
39+
"passAsFile": [],
40+
"preferLocalBuild": false,
41+
"requiredSystemFeatures": [],
42+
"unsafeDiscardReferences": {}
43+
},
2044
"outputs": {
2145
"out": {
2246
"hashAlgo": "sha256",

src/libstore-tests/data/derivation/ca/advanced-attributes-structured-attrs-defaults.json

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,22 @@
1313
"srcs": []
1414
},
1515
"name": "advanced-attributes-structured-attrs-defaults",
16+
"options": {
17+
"additionalSandboxProfile": "",
18+
"allowLocalNetworking": false,
19+
"allowSubstitutes": true,
20+
"exportReferencesGraph": {},
21+
"impureEnvVars": [],
22+
"impureHostDeps": [],
23+
"noChroot": false,
24+
"outputChecks": {
25+
"perOutput": {}
26+
},
27+
"passAsFile": [],
28+
"preferLocalBuild": false,
29+
"requiredSystemFeatures": [],
30+
"unsafeDiscardReferences": {}
31+
},
1632
"outputs": {
1733
"dev": {
1834
"hashAlgo": "sha256",

src/libstore-tests/data/derivation/ca/advanced-attributes-structured-attrs.json

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,72 @@
3131
]
3232
},
3333
"name": "advanced-attributes-structured-attrs",
34+
"options": {
35+
"additionalSandboxProfile": "sandcastle",
36+
"allowLocalNetworking": true,
37+
"allowSubstitutes": false,
38+
"exportReferencesGraph": {
39+
"refs1": [
40+
"/164j69y6zir9z0339n8pjigg3rckinlr77bxsavzizdaaljb7nh9"
41+
],
42+
"refs2": [
43+
"/nix/store/qnml92yh97a6fbrs2m5qg5cqlc8vni58-bar.drv"
44+
]
45+
},
46+
"impureEnvVars": [
47+
"UNICORN"
48+
],
49+
"impureHostDeps": [
50+
"/usr/bin/ditto"
51+
],
52+
"noChroot": true,
53+
"outputChecks": {
54+
"perOutput": {
55+
"bin": {
56+
"allowedReferences": null,
57+
"allowedRequisites": null,
58+
"disallowedReferences": [
59+
"/0nyw57wm2iicnm9rglvjmbci3ikmcp823czdqdzdcgsnnwqps71g"
60+
],
61+
"disallowedRequisites": [
62+
"/07f301yqyz8c6wf6bbbavb2q39j4n8kmcly1s09xadyhgy6x2wr8"
63+
],
64+
"ignoreSelfRefs": false,
65+
"maxClosureSize": null,
66+
"maxSize": null
67+
},
68+
"dev": {
69+
"allowedReferences": null,
70+
"allowedRequisites": null,
71+
"disallowedReferences": [],
72+
"disallowedRequisites": [],
73+
"ignoreSelfRefs": false,
74+
"maxClosureSize": 5909,
75+
"maxSize": 789
76+
},
77+
"out": {
78+
"allowedReferences": [
79+
"/164j69y6zir9z0339n8pjigg3rckinlr77bxsavzizdaaljb7nh9"
80+
],
81+
"allowedRequisites": [
82+
"/0nr45p69vn6izw9446wsh9bng9nndhvn19kpsm4n96a5mycw0s4z"
83+
],
84+
"disallowedReferences": [],
85+
"disallowedRequisites": [],
86+
"ignoreSelfRefs": false,
87+
"maxClosureSize": null,
88+
"maxSize": null
89+
}
90+
}
91+
},
92+
"passAsFile": [],
93+
"preferLocalBuild": true,
94+
"requiredSystemFeatures": [
95+
"rainbow",
96+
"uid-range"
97+
],
98+
"unsafeDiscardReferences": {}
99+
},
34100
"outputs": {
35101
"bin": {
36102
"hashAlgo": "sha256",

src/libstore-tests/data/derivation/ca/advanced-attributes.json

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,52 @@
4747
]
4848
},
4949
"name": "advanced-attributes",
50+
"options": {
51+
"additionalSandboxProfile": "sandcastle",
52+
"allowLocalNetworking": true,
53+
"allowSubstitutes": false,
54+
"exportReferencesGraph": {
55+
"refs1": [
56+
"/164j69y6zir9z0339n8pjigg3rckinlr77bxsavzizdaaljb7nh9"
57+
],
58+
"refs2": [
59+
"/nix/store/qnml92yh97a6fbrs2m5qg5cqlc8vni58-bar.drv"
60+
]
61+
},
62+
"impureEnvVars": [
63+
"UNICORN"
64+
],
65+
"impureHostDeps": [
66+
"/usr/bin/ditto"
67+
],
68+
"noChroot": true,
69+
"outputChecks": {
70+
"forAllOutputs": {
71+
"allowedReferences": [
72+
"/164j69y6zir9z0339n8pjigg3rckinlr77bxsavzizdaaljb7nh9"
73+
],
74+
"allowedRequisites": [
75+
"/0nr45p69vn6izw9446wsh9bng9nndhvn19kpsm4n96a5mycw0s4z"
76+
],
77+
"disallowedReferences": [
78+
"/0nyw57wm2iicnm9rglvjmbci3ikmcp823czdqdzdcgsnnwqps71g"
79+
],
80+
"disallowedRequisites": [
81+
"/07f301yqyz8c6wf6bbbavb2q39j4n8kmcly1s09xadyhgy6x2wr8"
82+
],
83+
"ignoreSelfRefs": true,
84+
"maxClosureSize": null,
85+
"maxSize": null
86+
}
87+
},
88+
"passAsFile": [],
89+
"preferLocalBuild": true,
90+
"requiredSystemFeatures": [
91+
"rainbow",
92+
"uid-range"
93+
],
94+
"unsafeDiscardReferences": {}
95+
},
5096
"outputs": {
5197
"out": {
5298
"hashAlgo": "sha256",

src/libstore-tests/data/derivation/dyn-dep-derivation.json

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,30 @@
3535
]
3636
},
3737
"name": "dyn-dep-derivation",
38+
"options": {
39+
"additionalSandboxProfile": "",
40+
"allowLocalNetworking": false,
41+
"allowSubstitutes": true,
42+
"exportReferencesGraph": {},
43+
"impureEnvVars": [],
44+
"impureHostDeps": [],
45+
"noChroot": false,
46+
"outputChecks": {
47+
"forAllOutputs": {
48+
"allowedReferences": null,
49+
"allowedRequisites": null,
50+
"disallowedReferences": [],
51+
"disallowedRequisites": [],
52+
"ignoreSelfRefs": true,
53+
"maxClosureSize": null,
54+
"maxSize": null
55+
}
56+
},
57+
"passAsFile": [],
58+
"preferLocalBuild": false,
59+
"requiredSystemFeatures": [],
60+
"unsafeDiscardReferences": {}
61+
},
3862
"outputs": {},
3963
"system": "wasm-sel4",
4064
"version": 4

src/libstore-tests/data/derivation/ia/advanced-attributes-defaults.json

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,30 @@
1515
"srcs": []
1616
},
1717
"name": "advanced-attributes-defaults",
18+
"options": {
19+
"additionalSandboxProfile": "",
20+
"allowLocalNetworking": false,
21+
"allowSubstitutes": true,
22+
"exportReferencesGraph": {},
23+
"impureEnvVars": [],
24+
"impureHostDeps": [],
25+
"noChroot": false,
26+
"outputChecks": {
27+
"forAllOutputs": {
28+
"allowedReferences": null,
29+
"allowedRequisites": null,
30+
"disallowedReferences": [],
31+
"disallowedRequisites": [],
32+
"ignoreSelfRefs": true,
33+
"maxClosureSize": null,
34+
"maxSize": null
35+
}
36+
},
37+
"passAsFile": [],
38+
"preferLocalBuild": false,
39+
"requiredSystemFeatures": [],
40+
"unsafeDiscardReferences": {}
41+
},
1842
"outputs": {
1943
"out": {
2044
"path": "1qsc7svv43m4dw2prh6mvyf7cai5czji-advanced-attributes-defaults"

src/libstore-tests/data/derivation/ia/advanced-attributes-structured-attrs-defaults.json

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,22 @@
1313
"srcs": []
1414
},
1515
"name": "advanced-attributes-structured-attrs-defaults",
16+
"options": {
17+
"additionalSandboxProfile": "",
18+
"allowLocalNetworking": false,
19+
"allowSubstitutes": true,
20+
"exportReferencesGraph": {},
21+
"impureEnvVars": [],
22+
"impureHostDeps": [],
23+
"noChroot": false,
24+
"outputChecks": {
25+
"perOutput": {}
26+
},
27+
"passAsFile": [],
28+
"preferLocalBuild": false,
29+
"requiredSystemFeatures": [],
30+
"unsafeDiscardReferences": {}
31+
},
1632
"outputs": {
1733
"dev": {
1834
"path": "8bazivnbipbyi569623skw5zm91z6kc2-advanced-attributes-structured-attrs-defaults-dev"

src/libstore-tests/data/derivation/ia/advanced-attributes-structured-attrs.json

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,72 @@
3131
]
3232
},
3333
"name": "advanced-attributes-structured-attrs",
34+
"options": {
35+
"additionalSandboxProfile": "sandcastle",
36+
"allowLocalNetworking": true,
37+
"allowSubstitutes": false,
38+
"exportReferencesGraph": {
39+
"refs1": [
40+
"/nix/store/p0hax2lzvjpfc2gwkk62xdglz0fcqfzn-foo"
41+
],
42+
"refs2": [
43+
"/nix/store/vj2i49jm2868j2fmqvxm70vlzmzvgv14-bar.drv"
44+
]
45+
},
46+
"impureEnvVars": [
47+
"UNICORN"
48+
],
49+
"impureHostDeps": [
50+
"/usr/bin/ditto"
51+
],
52+
"noChroot": true,
53+
"outputChecks": {
54+
"perOutput": {
55+
"bin": {
56+
"allowedReferences": null,
57+
"allowedRequisites": null,
58+
"disallowedReferences": [
59+
"/nix/store/r5cff30838majxk5mp3ip2diffi8vpaj-bar"
60+
],
61+
"disallowedRequisites": [
62+
"/nix/store/9b61w26b4avv870dw0ymb6rw4r1hzpws-bar-dev"
63+
],
64+
"ignoreSelfRefs": false,
65+
"maxClosureSize": null,
66+
"maxSize": null
67+
},
68+
"dev": {
69+
"allowedReferences": null,
70+
"allowedRequisites": null,
71+
"disallowedReferences": [],
72+
"disallowedRequisites": [],
73+
"ignoreSelfRefs": false,
74+
"maxClosureSize": 5909,
75+
"maxSize": 789
76+
},
77+
"out": {
78+
"allowedReferences": [
79+
"/nix/store/p0hax2lzvjpfc2gwkk62xdglz0fcqfzn-foo"
80+
],
81+
"allowedRequisites": [
82+
"/nix/store/z0rjzy29v9k5qa4nqpykrbzirj7sd43v-foo-dev"
83+
],
84+
"disallowedReferences": [],
85+
"disallowedRequisites": [],
86+
"ignoreSelfRefs": false,
87+
"maxClosureSize": null,
88+
"maxSize": null
89+
}
90+
}
91+
},
92+
"passAsFile": [],
93+
"preferLocalBuild": true,
94+
"requiredSystemFeatures": [
95+
"rainbow",
96+
"uid-range"
97+
],
98+
"unsafeDiscardReferences": {}
99+
},
34100
"outputs": {
35101
"bin": {
36102
"path": "cnpasdljgkhnwaf78cf3qygcp4qbki1c-advanced-attributes-structured-attrs-bin"

src/libstore-tests/data/derivation/ia/advanced-attributes.json

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,52 @@
4545
]
4646
},
4747
"name": "advanced-attributes",
48+
"options": {
49+
"additionalSandboxProfile": "sandcastle",
50+
"allowLocalNetworking": true,
51+
"allowSubstitutes": false,
52+
"exportReferencesGraph": {
53+
"refs1": [
54+
"/nix/store/p0hax2lzvjpfc2gwkk62xdglz0fcqfzn-foo"
55+
],
56+
"refs2": [
57+
"/nix/store/vj2i49jm2868j2fmqvxm70vlzmzvgv14-bar.drv"
58+
]
59+
},
60+
"impureEnvVars": [
61+
"UNICORN"
62+
],
63+
"impureHostDeps": [
64+
"/usr/bin/ditto"
65+
],
66+
"noChroot": true,
67+
"outputChecks": {
68+
"forAllOutputs": {
69+
"allowedReferences": [
70+
"/nix/store/p0hax2lzvjpfc2gwkk62xdglz0fcqfzn-foo"
71+
],
72+
"allowedRequisites": [
73+
"/nix/store/z0rjzy29v9k5qa4nqpykrbzirj7sd43v-foo-dev"
74+
],
75+
"disallowedReferences": [
76+
"/nix/store/r5cff30838majxk5mp3ip2diffi8vpaj-bar"
77+
],
78+
"disallowedRequisites": [
79+
"/nix/store/9b61w26b4avv870dw0ymb6rw4r1hzpws-bar-dev"
80+
],
81+
"ignoreSelfRefs": true,
82+
"maxClosureSize": null,
83+
"maxSize": null
84+
}
85+
},
86+
"passAsFile": [],
87+
"preferLocalBuild": true,
88+
"requiredSystemFeatures": [
89+
"rainbow",
90+
"uid-range"
91+
],
92+
"unsafeDiscardReferences": {}
93+
},
4894
"outputs": {
4995
"out": {
5096
"path": "ymqmybkq5j4nd1xplw6ccdpbjnfi017v-advanced-attributes"

0 commit comments

Comments
 (0)