@@ -15,35 +15,51 @@ lastModified=$(nix flake metadata --json "$flake1Dir" | jq -r .locked.lastModifi
1515treePath=$( nix flake prefetch --json " $flake1Dir " | jq -r .storePath)
1616builder=$( nix eval --raw " $flake1Dir #packages.$system .default._builder" )
1717
18- # Building a derivation should have tree+subpath+flake+build provenance.
19- [[ $( nix path-info --json --json-format 1 " $outPath " | jq " .\" $outPath \" .provenance" ) = $( cat << EOF
18+ # Building a derivation should have tree+subpath+flake+meta+ build provenance.
19+ [[ " $( nix path-info --json --json-format 1 " $outPath " | jq " .\" $outPath \" .provenance" ) " == " $( cat << EOF
2020{
2121 "buildHost": "test-host",
2222 "drv": "$( basename " $drvPath " ) ",
2323 "next": {
24- "flakeOutput": "packages.$system .default",
24+ "meta": {
25+ "license": [
26+ {
27+ "deprecated": true,
28+ "free": true,
29+ "fullName": "GNU Lesser General Public License v2.1",
30+ "redistributable": true,
31+ "shortName": "lgpl21",
32+ "spdxId": "LGPL-2.1",
33+ "url": "https://spdx.org/licenses/LGPL-2.1.html"
34+ }
35+ ]
36+ },
2537 "next": {
38+ "flakeOutput": "packages.$system .default",
2639 "next": {
27- "attrs": {
28- "lastModified": $lastModified ,
29- "ref": "refs/heads/master",
30- "rev": "$rev ",
31- "revCount": 1,
32- "type": "git",
33- "url": "file://$flake1Dir "
40+ "next": {
41+ "attrs": {
42+ "lastModified": $lastModified ,
43+ "ref": "refs/heads/master",
44+ "rev": "$rev ",
45+ "revCount": 1,
46+ "type": "git",
47+ "url": "file://$flake1Dir "
48+ },
49+ "type": "tree"
3450 },
35- "type": "tree"
51+ "subpath": "/flake.nix",
52+ "type": "subpath"
3653 },
37- "subpath": "/flake.nix",
38- "type": "subpath"
54+ "type": "flake"
3955 },
40- "type": "flake "
56+ "type": "meta "
4157 },
4258 "output": "out",
4359 "type": "build"
4460}
4561EOF
46- ) ]]
62+ ) " ]]
4763
4864# Flakes should have "tree" provenance.
4965[[ $( nix path-info --json --json-format 1 " $treePath " | jq " .\" $treePath \" .provenance" ) = $( cat << EOF
@@ -89,52 +105,88 @@ clearStore
89105
90106nix copy --from " file://$binaryCache " " $outPath " --no-check-sigs
91107
92- [[ $( nix path-info --json --json-format 1 " $outPath " | jq " .\" $outPath \" .provenance" ) = $( cat << EOF
108+ [[ " $( nix path-info --json --json-format 1 " $outPath " | jq " .\" $outPath \" .provenance" ) " = " $( cat << EOF
93109{
94110 "from": "file://$binaryCache ",
95111 "next": {
96112 "buildHost": "test-host",
97113 "drv": "$( basename " $drvPath " ) ",
98114 "next": {
99- "flakeOutput": "packages.$system .default",
115+ "meta": {
116+ "license": [
117+ {
118+ "deprecated": true,
119+ "free": true,
120+ "fullName": "GNU Lesser General Public License v2.1",
121+ "redistributable": true,
122+ "shortName": "lgpl21",
123+ "spdxId": "LGPL-2.1",
124+ "url": "https://spdx.org/licenses/LGPL-2.1.html"
125+ }
126+ ]
127+ },
100128 "next": {
129+ "flakeOutput": "packages.$system .default",
101130 "next": {
102- "attrs": {
103- "lastModified": $lastModified ,
104- "ref": "refs/heads/master",
105- "rev": "$rev ",
106- "revCount": 1,
107- "type": "git",
108- "url": "file://$flake1Dir "
131+ "next": {
132+ "attrs": {
133+ "lastModified": $lastModified ,
134+ "ref": "refs/heads/master",
135+ "rev": "$rev ",
136+ "revCount": 1,
137+ "type": "git",
138+ "url": "file://$flake1Dir "
139+ },
140+ "type": "tree"
109141 },
110- "type": "tree"
142+ "subpath": "/flake.nix",
143+ "type": "subpath"
111144 },
112- "subpath": "/flake.nix",
113- "type": "subpath"
145+ "type": "flake"
114146 },
115- "type": "flake "
147+ "type": "meta "
116148 },
117149 "output": "out",
118150 "type": "build"
119151 },
120152 "type": "copied"
121153}
122154EOF
123- ) ]]
155+ ) " ]]
124156
125157# Test `nix provenance show`.
126- [[ $( nix provenance show " $outPath " ) = $( cat << EOF
158+ [[ " $( nix provenance show " $outPath " ) " = $( cat << EOF
127159[1m$outPath [0m
128160← copied from [1mfile://$binaryCache [0m
129161← built from derivation [1m$drvPath [0m (output [1mout[0m) on [1mtest-host[0m
162+ ← with metadata
130163← instantiated from flake output [1mgit+file://$flake1Dir ?ref=refs/heads/master&rev=$rev #packages.$system .default[0m
131164EOF
132165) ]]
133166
134167# Check that --impure does not add provenance.
135168clearStore
136169nix build --impure --print-out-paths --no-link " $flake1Dir #packages.$system .default"
137- [[ $( nix path-info --json --json-format 1 " $drvPath " | jq " .\" $drvPath \" .provenance" ) = null ]]
170+ [[ " $( nix path-info --json --json-format 1 " $drvPath " | jq " .\" $drvPath \" .provenance" ) " = " $( cat << EOF
171+ {
172+ "meta": {
173+ "license": [
174+ {
175+ "deprecated": true,
176+ "free": true,
177+ "fullName": "GNU Lesser General Public License v2.1",
178+ "redistributable": true,
179+ "shortName": "lgpl21",
180+ "spdxId": "LGPL-2.1",
181+ "url": "https://spdx.org/licenses/LGPL-2.1.html"
182+ }
183+ ]
184+ },
185+ "next": null,
186+ "type": "meta"
187+ }
188+ EOF
189+ ) " ]]
138190
139191clearStore
140192echo foo > " $flake1Dir /somefile"
0 commit comments