Skip to content

Commit edbe44e

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 8652b6b commit edbe44e

27 files changed

+481
-158
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: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,27 @@
1515
"inputDrvs": {},
1616
"inputSrcs": [],
1717
"name": "advanced-attributes-defaults",
18+
"options": {
19+
"additionalSandboxProfile": "",
20+
"allowLocalNetworking": false,
21+
"allowSubstitutes": true,
22+
"impureEnvVars": [],
23+
"impureHostDeps": [],
24+
"noChroot": false,
25+
"outputChecks": {
26+
"forAllOutputs": {
27+
"allowedReferences": null,
28+
"allowedRequisites": null,
29+
"disallowedReferences": [],
30+
"disallowedRequisites": [],
31+
"ignoreSelfRefs": true
32+
}
33+
},
34+
"passAsFile": [],
35+
"preferLocalBuild": false,
36+
"requiredSystemFeatures": [],
37+
"unsafeDiscardReferences": {}
38+
},
1839
"outputs": {
1940
"out": {
2041
"hashAlgo": "sha256",

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

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,21 @@
1111
"inputDrvs": {},
1212
"inputSrcs": [],
1313
"name": "advanced-attributes-structured-attrs-defaults",
14+
"options": {
15+
"additionalSandboxProfile": "",
16+
"allowLocalNetworking": false,
17+
"allowSubstitutes": true,
18+
"impureEnvVars": [],
19+
"impureHostDeps": [],
20+
"noChroot": false,
21+
"outputChecks": {
22+
"perOutput": {}
23+
},
24+
"passAsFile": [],
25+
"preferLocalBuild": false,
26+
"requiredSystemFeatures": [],
27+
"unsafeDiscardReferences": {}
28+
},
1429
"outputs": {
1530
"dev": {
1631
"hashAlgo": "sha256",

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

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,58 @@
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+
"impureEnvVars": [
37+
"UNICORN"
38+
],
39+
"impureHostDeps": [
40+
"/usr/bin/ditto"
41+
],
42+
"noChroot": true,
43+
"outputChecks": {
44+
"perOutput": {
45+
"bin": {
46+
"allowedReferences": null,
47+
"allowedRequisites": null,
48+
"disallowedReferences": [
49+
"/0nyw57wm2iicnm9rglvjmbci3ikmcp823czdqdzdcgsnnwqps71g"
50+
],
51+
"disallowedRequisites": [
52+
"/07f301yqyz8c6wf6bbbavb2q39j4n8kmcly1s09xadyhgy6x2wr8"
53+
],
54+
"ignoreSelfRefs": false
55+
},
56+
"dev": {
57+
"allowedReferences": null,
58+
"allowedRequisites": null,
59+
"disallowedReferences": [],
60+
"disallowedRequisites": [],
61+
"ignoreSelfRefs": false
62+
},
63+
"out": {
64+
"allowedReferences": [
65+
"/164j69y6zir9z0339n8pjigg3rckinlr77bxsavzizdaaljb7nh9"
66+
],
67+
"allowedRequisites": [
68+
"/0nr45p69vn6izw9446wsh9bng9nndhvn19kpsm4n96a5mycw0s4z"
69+
],
70+
"disallowedReferences": [],
71+
"disallowedRequisites": [],
72+
"ignoreSelfRefs": false
73+
}
74+
}
75+
},
76+
"passAsFile": [],
77+
"preferLocalBuild": true,
78+
"requiredSystemFeatures": [
79+
"rainbow",
80+
"uid-range"
81+
],
82+
"unsafeDiscardReferences": {}
83+
},
3284
"outputs": {
3385
"bin": {
3486
"hashAlgo": "sha256",

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

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,42 @@
4545
"/nix/store/qnml92yh97a6fbrs2m5qg5cqlc8vni58-bar.drv"
4646
],
4747
"name": "advanced-attributes",
48+
"options": {
49+
"additionalSandboxProfile": "sandcastle",
50+
"allowLocalNetworking": true,
51+
"allowSubstitutes": false,
52+
"impureEnvVars": [
53+
"UNICORN"
54+
],
55+
"impureHostDeps": [
56+
"/usr/bin/ditto"
57+
],
58+
"noChroot": true,
59+
"outputChecks": {
60+
"forAllOutputs": {
61+
"allowedReferences": [
62+
"/164j69y6zir9z0339n8pjigg3rckinlr77bxsavzizdaaljb7nh9"
63+
],
64+
"allowedRequisites": [
65+
"/0nr45p69vn6izw9446wsh9bng9nndhvn19kpsm4n96a5mycw0s4z"
66+
],
67+
"disallowedReferences": [
68+
"/0nyw57wm2iicnm9rglvjmbci3ikmcp823czdqdzdcgsnnwqps71g"
69+
],
70+
"disallowedRequisites": [
71+
"/07f301yqyz8c6wf6bbbavb2q39j4n8kmcly1s09xadyhgy6x2wr8"
72+
],
73+
"ignoreSelfRefs": true
74+
}
75+
},
76+
"passAsFile": [],
77+
"preferLocalBuild": true,
78+
"requiredSystemFeatures": [
79+
"rainbow",
80+
"uid-range"
81+
],
82+
"unsafeDiscardReferences": {}
83+
},
4884
"outputs": {
4985
"out": {
5086
"hashAlgo": "sha256",

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

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

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

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,27 @@
1313
"inputDrvs": {},
1414
"inputSrcs": [],
1515
"name": "advanced-attributes-defaults",
16+
"options": {
17+
"additionalSandboxProfile": "",
18+
"allowLocalNetworking": false,
19+
"allowSubstitutes": true,
20+
"impureEnvVars": [],
21+
"impureHostDeps": [],
22+
"noChroot": false,
23+
"outputChecks": {
24+
"forAllOutputs": {
25+
"allowedReferences": null,
26+
"allowedRequisites": null,
27+
"disallowedReferences": [],
28+
"disallowedRequisites": [],
29+
"ignoreSelfRefs": true
30+
}
31+
},
32+
"passAsFile": [],
33+
"preferLocalBuild": false,
34+
"requiredSystemFeatures": [],
35+
"unsafeDiscardReferences": {}
36+
},
1637
"outputs": {
1738
"out": {
1839
"path": "/nix/store/1qsc7svv43m4dw2prh6mvyf7cai5czji-advanced-attributes-defaults"

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

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,21 @@
1111
"inputDrvs": {},
1212
"inputSrcs": [],
1313
"name": "advanced-attributes-structured-attrs-defaults",
14+
"options": {
15+
"additionalSandboxProfile": "",
16+
"allowLocalNetworking": false,
17+
"allowSubstitutes": true,
18+
"impureEnvVars": [],
19+
"impureHostDeps": [],
20+
"noChroot": false,
21+
"outputChecks": {
22+
"perOutput": {}
23+
},
24+
"passAsFile": [],
25+
"preferLocalBuild": false,
26+
"requiredSystemFeatures": [],
27+
"unsafeDiscardReferences": {}
28+
},
1429
"outputs": {
1530
"dev": {
1631
"path": "/nix/store/8bazivnbipbyi569623skw5zm91z6kc2-advanced-attributes-structured-attrs-defaults-dev"

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

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,58 @@
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+
"impureEnvVars": [
37+
"UNICORN"
38+
],
39+
"impureHostDeps": [
40+
"/usr/bin/ditto"
41+
],
42+
"noChroot": true,
43+
"outputChecks": {
44+
"perOutput": {
45+
"bin": {
46+
"allowedReferences": null,
47+
"allowedRequisites": null,
48+
"disallowedReferences": [
49+
"/nix/store/r5cff30838majxk5mp3ip2diffi8vpaj-bar"
50+
],
51+
"disallowedRequisites": [
52+
"/nix/store/9b61w26b4avv870dw0ymb6rw4r1hzpws-bar-dev"
53+
],
54+
"ignoreSelfRefs": false
55+
},
56+
"dev": {
57+
"allowedReferences": null,
58+
"allowedRequisites": null,
59+
"disallowedReferences": [],
60+
"disallowedRequisites": [],
61+
"ignoreSelfRefs": false
62+
},
63+
"out": {
64+
"allowedReferences": [
65+
"/nix/store/p0hax2lzvjpfc2gwkk62xdglz0fcqfzn-foo"
66+
],
67+
"allowedRequisites": [
68+
"/nix/store/z0rjzy29v9k5qa4nqpykrbzirj7sd43v-foo-dev"
69+
],
70+
"disallowedReferences": [],
71+
"disallowedRequisites": [],
72+
"ignoreSelfRefs": false
73+
}
74+
}
75+
},
76+
"passAsFile": [],
77+
"preferLocalBuild": true,
78+
"requiredSystemFeatures": [
79+
"rainbow",
80+
"uid-range"
81+
],
82+
"unsafeDiscardReferences": {}
83+
},
3284
"outputs": {
3385
"bin": {
3486
"path": "/nix/store/33qms3h55wlaspzba3brlzlrm8m2239g-advanced-attributes-structured-attrs-bin"

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

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,42 @@
4343
"/nix/store/vj2i49jm2868j2fmqvxm70vlzmzvgv14-bar.drv"
4444
],
4545
"name": "advanced-attributes",
46+
"options": {
47+
"additionalSandboxProfile": "sandcastle",
48+
"allowLocalNetworking": true,
49+
"allowSubstitutes": false,
50+
"impureEnvVars": [
51+
"UNICORN"
52+
],
53+
"impureHostDeps": [
54+
"/usr/bin/ditto"
55+
],
56+
"noChroot": true,
57+
"outputChecks": {
58+
"forAllOutputs": {
59+
"allowedReferences": [
60+
"/nix/store/p0hax2lzvjpfc2gwkk62xdglz0fcqfzn-foo"
61+
],
62+
"allowedRequisites": [
63+
"/nix/store/z0rjzy29v9k5qa4nqpykrbzirj7sd43v-foo-dev"
64+
],
65+
"disallowedReferences": [
66+
"/nix/store/r5cff30838majxk5mp3ip2diffi8vpaj-bar"
67+
],
68+
"disallowedRequisites": [
69+
"/nix/store/9b61w26b4avv870dw0ymb6rw4r1hzpws-bar-dev"
70+
],
71+
"ignoreSelfRefs": true
72+
}
73+
},
74+
"passAsFile": [],
75+
"preferLocalBuild": true,
76+
"requiredSystemFeatures": [
77+
"rainbow",
78+
"uid-range"
79+
],
80+
"unsafeDiscardReferences": {}
81+
},
4682
"outputs": {
4783
"out": {
4884
"path": "/nix/store/wyhpwd748pns4k7svh48wdrc8kvjk0ra-advanced-attributes"

0 commit comments

Comments
 (0)