Skip to content

Commit b9d9f66

Browse files
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. HaeNoe <[email protected]>
1 parent cf7084a commit b9d9f66

31 files changed

+581
-181
lines changed

src/libexpr/primops.cc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1569,6 +1569,9 @@ static void derivationStrictInternal(EvalState & state, std::string_view drvName
15691569
drv.structuredAttrs = std::move(*jsonObject);
15701570
}
15711571

1572+
drv.options =
1573+
DerivationOptions::fromStructuredAttrs(drv.env, drv.structuredAttrs ? &*drv.structuredAttrs : nullptr);
1574+
15721575
/* Everything in the context of the strings in the derivation
15731576
attributes should be added as dependencies of the resulting
15741577
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
@@ -15,6 +15,30 @@
1515
"inputDrvs": {},
1616
"inputSrcs": [],
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
"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
@@ -11,6 +11,22 @@
1111
"inputDrvs": {},
1212
"inputSrcs": [],
1313
"name": "advanced-attributes-structured-attrs-defaults",
14+
"options": {
15+
"additionalSandboxProfile": "",
16+
"allowLocalNetworking": false,
17+
"allowSubstitutes": true,
18+
"exportReferencesGraph": {},
19+
"impureEnvVars": [],
20+
"impureHostDeps": [],
21+
"noChroot": false,
22+
"outputChecks": {
23+
"perOutput": {}
24+
},
25+
"passAsFile": [],
26+
"preferLocalBuild": false,
27+
"requiredSystemFeatures": [],
28+
"unsafeDiscardReferences": {}
29+
},
1430
"outputs": {
1531
"dev": {
1632
"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
@@ -29,6 +29,72 @@
2929
"/nix/store/qnml92yh97a6fbrs2m5qg5cqlc8vni58-bar.drv"
3030
],
3131
"name": "advanced-attributes-structured-attrs",
32+
"options": {
33+
"additionalSandboxProfile": "sandcastle",
34+
"allowLocalNetworking": true,
35+
"allowSubstitutes": false,
36+
"exportReferencesGraph": {
37+
"refs1": [
38+
"/164j69y6zir9z0339n8pjigg3rckinlr77bxsavzizdaaljb7nh9"
39+
],
40+
"refs2": [
41+
"/nix/store/qnml92yh97a6fbrs2m5qg5cqlc8vni58-bar.drv"
42+
]
43+
},
44+
"impureEnvVars": [
45+
"UNICORN"
46+
],
47+
"impureHostDeps": [
48+
"/usr/bin/ditto"
49+
],
50+
"noChroot": true,
51+
"outputChecks": {
52+
"perOutput": {
53+
"bin": {
54+
"allowedReferences": null,
55+
"allowedRequisites": null,
56+
"disallowedReferences": [
57+
"/0nyw57wm2iicnm9rglvjmbci3ikmcp823czdqdzdcgsnnwqps71g"
58+
],
59+
"disallowedRequisites": [
60+
"/07f301yqyz8c6wf6bbbavb2q39j4n8kmcly1s09xadyhgy6x2wr8"
61+
],
62+
"ignoreSelfRefs": false,
63+
"maxClosureSize": null,
64+
"maxSize": null
65+
},
66+
"dev": {
67+
"allowedReferences": null,
68+
"allowedRequisites": null,
69+
"disallowedReferences": [],
70+
"disallowedRequisites": [],
71+
"ignoreSelfRefs": false,
72+
"maxClosureSize": 5909,
73+
"maxSize": 789
74+
},
75+
"out": {
76+
"allowedReferences": [
77+
"/164j69y6zir9z0339n8pjigg3rckinlr77bxsavzizdaaljb7nh9"
78+
],
79+
"allowedRequisites": [
80+
"/0nr45p69vn6izw9446wsh9bng9nndhvn19kpsm4n96a5mycw0s4z"
81+
],
82+
"disallowedReferences": [],
83+
"disallowedRequisites": [],
84+
"ignoreSelfRefs": false,
85+
"maxClosureSize": null,
86+
"maxSize": null
87+
}
88+
}
89+
},
90+
"passAsFile": [],
91+
"preferLocalBuild": true,
92+
"requiredSystemFeatures": [
93+
"rainbow",
94+
"uid-range"
95+
],
96+
"unsafeDiscardReferences": {}
97+
},
3298
"outputs": {
3399
"bin": {
34100
"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
@@ -45,6 +45,52 @@
4545
"/nix/store/qnml92yh97a6fbrs2m5qg5cqlc8vni58-bar.drv"
4646
],
4747
"name": "advanced-attributes",
48+
"options": {
49+
"additionalSandboxProfile": "sandcastle",
50+
"allowLocalNetworking": true,
51+
"allowSubstitutes": false,
52+
"exportReferencesGraph": {
53+
"refs1": [
54+
"/164j69y6zir9z0339n8pjigg3rckinlr77bxsavzizdaaljb7nh9"
55+
],
56+
"refs2": [
57+
"/nix/store/qnml92yh97a6fbrs2m5qg5cqlc8vni58-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+
"/164j69y6zir9z0339n8pjigg3rckinlr77bxsavzizdaaljb7nh9"
71+
],
72+
"allowedRequisites": [
73+
"/0nr45p69vn6izw9446wsh9bng9nndhvn19kpsm4n96a5mycw0s4z"
74+
],
75+
"disallowedReferences": [
76+
"/0nyw57wm2iicnm9rglvjmbci3ikmcp823czdqdzdcgsnnwqps71g"
77+
],
78+
"disallowedRequisites": [
79+
"/07f301yqyz8c6wf6bbbavb2q39j4n8kmcly1s09xadyhgy6x2wr8"
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
"hashAlgo": "sha256",

src/libstore-tests/data/derivation/dynDerivationDeps.json

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,30 @@
3333
"/nix/store/c015dhfh5l0lp6wxyvdn7bmwhbbr6hr9-dep1"
3434
],
3535
"name": "dyn-dep-derivation",
36+
"options": {
37+
"additionalSandboxProfile": "",
38+
"allowLocalNetworking": false,
39+
"allowSubstitutes": true,
40+
"exportReferencesGraph": {},
41+
"impureEnvVars": [],
42+
"impureHostDeps": [],
43+
"noChroot": false,
44+
"outputChecks": {
45+
"forAllOutputs": {
46+
"allowedReferences": null,
47+
"allowedRequisites": null,
48+
"disallowedReferences": [],
49+
"disallowedRequisites": [],
50+
"ignoreSelfRefs": true,
51+
"maxClosureSize": null,
52+
"maxSize": null
53+
}
54+
},
55+
"passAsFile": [],
56+
"preferLocalBuild": false,
57+
"requiredSystemFeatures": [],
58+
"unsafeDiscardReferences": {}
59+
},
3660
"outputs": {},
3761
"system": "wasm-sel4"
3862
}

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

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,30 @@
1313
"inputDrvs": {},
1414
"inputSrcs": [],
1515
"name": "advanced-attributes-defaults",
16+
"options": {
17+
"additionalSandboxProfile": "",
18+
"allowLocalNetworking": false,
19+
"allowSubstitutes": true,
20+
"exportReferencesGraph": {},
21+
"impureEnvVars": [],
22+
"impureHostDeps": [],
23+
"noChroot": false,
24+
"outputChecks": {
25+
"forAllOutputs": {
26+
"allowedReferences": null,
27+
"allowedRequisites": null,
28+
"disallowedReferences": [],
29+
"disallowedRequisites": [],
30+
"ignoreSelfRefs": true,
31+
"maxClosureSize": null,
32+
"maxSize": null
33+
}
34+
},
35+
"passAsFile": [],
36+
"preferLocalBuild": false,
37+
"requiredSystemFeatures": [],
38+
"unsafeDiscardReferences": {}
39+
},
1640
"outputs": {
1741
"out": {
1842
"path": "/nix/store/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
@@ -11,6 +11,22 @@
1111
"inputDrvs": {},
1212
"inputSrcs": [],
1313
"name": "advanced-attributes-structured-attrs-defaults",
14+
"options": {
15+
"additionalSandboxProfile": "",
16+
"allowLocalNetworking": false,
17+
"allowSubstitutes": true,
18+
"exportReferencesGraph": {},
19+
"impureEnvVars": [],
20+
"impureHostDeps": [],
21+
"noChroot": false,
22+
"outputChecks": {
23+
"perOutput": {}
24+
},
25+
"passAsFile": [],
26+
"preferLocalBuild": false,
27+
"requiredSystemFeatures": [],
28+
"unsafeDiscardReferences": {}
29+
},
1430
"outputs": {
1531
"dev": {
1632
"path": "/nix/store/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
@@ -29,6 +29,72 @@
2929
"/nix/store/vj2i49jm2868j2fmqvxm70vlzmzvgv14-bar.drv"
3030
],
3131
"name": "advanced-attributes-structured-attrs",
32+
"options": {
33+
"additionalSandboxProfile": "sandcastle",
34+
"allowLocalNetworking": true,
35+
"allowSubstitutes": false,
36+
"exportReferencesGraph": {
37+
"refs1": [
38+
"/nix/store/p0hax2lzvjpfc2gwkk62xdglz0fcqfzn-foo"
39+
],
40+
"refs2": [
41+
"/nix/store/vj2i49jm2868j2fmqvxm70vlzmzvgv14-bar.drv"
42+
]
43+
},
44+
"impureEnvVars": [
45+
"UNICORN"
46+
],
47+
"impureHostDeps": [
48+
"/usr/bin/ditto"
49+
],
50+
"noChroot": true,
51+
"outputChecks": {
52+
"perOutput": {
53+
"bin": {
54+
"allowedReferences": null,
55+
"allowedRequisites": null,
56+
"disallowedReferences": [
57+
"/nix/store/r5cff30838majxk5mp3ip2diffi8vpaj-bar"
58+
],
59+
"disallowedRequisites": [
60+
"/nix/store/9b61w26b4avv870dw0ymb6rw4r1hzpws-bar-dev"
61+
],
62+
"ignoreSelfRefs": false,
63+
"maxClosureSize": null,
64+
"maxSize": null
65+
},
66+
"dev": {
67+
"allowedReferences": null,
68+
"allowedRequisites": null,
69+
"disallowedReferences": [],
70+
"disallowedRequisites": [],
71+
"ignoreSelfRefs": false,
72+
"maxClosureSize": 5909,
73+
"maxSize": 789
74+
},
75+
"out": {
76+
"allowedReferences": [
77+
"/nix/store/p0hax2lzvjpfc2gwkk62xdglz0fcqfzn-foo"
78+
],
79+
"allowedRequisites": [
80+
"/nix/store/z0rjzy29v9k5qa4nqpykrbzirj7sd43v-foo-dev"
81+
],
82+
"disallowedReferences": [],
83+
"disallowedRequisites": [],
84+
"ignoreSelfRefs": false,
85+
"maxClosureSize": null,
86+
"maxSize": null
87+
}
88+
}
89+
},
90+
"passAsFile": [],
91+
"preferLocalBuild": true,
92+
"requiredSystemFeatures": [
93+
"rainbow",
94+
"uid-range"
95+
],
96+
"unsafeDiscardReferences": {}
97+
},
3298
"outputs": {
3399
"bin": {
34100
"path": "/nix/store/33qms3h55wlaspzba3brlzlrm8m2239g-advanced-attributes-structured-attrs-bin"

0 commit comments

Comments
 (0)