|
1 | | -# Derivation JSON Format |
| 1 | +{{#include derivation-v3-fixed.md}} |
2 | 2 |
|
3 | | -> **Warning** |
4 | | -> |
5 | | -> This JSON format is currently |
6 | | -> [**experimental**](@docroot@/development/experimental-features.md#xp-feature-nix-command) |
7 | | -> and subject to change. |
| 3 | +<!-- |
| 4 | +## Raw Schema |
8 | 5 |
|
9 | | -The JSON serialization of a |
10 | | -[derivations](@docroot@/glossary.md#gloss-store-derivation) |
11 | | -is a JSON object with the following fields: |
12 | | - |
13 | | -* `name`: |
14 | | - The name of the derivation. |
15 | | - This is used when calculating the store paths of the derivation's outputs. |
16 | | - |
17 | | -* `version`: |
18 | | - Must be `3`. |
19 | | - This is a guard that allows us to continue evolving this format. |
20 | | - The choice of `3` is fairly arbitrary, but corresponds to this informal version: |
21 | | - |
22 | | - - Version 0: A-Term format |
23 | | - |
24 | | - - Version 1: Original JSON format, with ugly `"r:sha256"` inherited from A-Term format. |
25 | | - |
26 | | - - Version 2: Separate `method` and `hashAlgo` fields in output specs |
27 | | - |
28 | | - - Version 3: Drop store dir from store paths, just include base name. |
29 | | - |
30 | | - Note that while this format is experimental, the maintenance of versions is best-effort, and not promised to identify every change. |
31 | | - |
32 | | -* `outputs`: |
33 | | - Information about the output paths of the derivation. |
34 | | - This is a JSON object with one member per output, where the key is the output name and the value is a JSON object with these fields: |
35 | | - |
36 | | - * `path`: |
37 | | - The output path, if it is known in advanced. |
38 | | - Otherwise, `null`. |
39 | | - |
40 | | - |
41 | | - * `method`: |
42 | | - For an output which will be [content addressed], a string representing the [method](@docroot@/store/store-object/content-address.md) of content addressing that is chosen. |
43 | | - Valid method strings are: |
44 | | - |
45 | | - - [`flat`](@docroot@/store/store-object/content-address.md#method-flat) |
46 | | - - [`nar`](@docroot@/store/store-object/content-address.md#method-nix-archive) |
47 | | - - [`text`](@docroot@/store/store-object/content-address.md#method-text) |
48 | | - - [`git`](@docroot@/store/store-object/content-address.md#method-git) |
49 | | - |
50 | | - Otherwise, `null`. |
51 | | - |
52 | | - * `hashAlgo`: |
53 | | - For an output which will be [content addressed], the name of the hash algorithm used. |
54 | | - Valid algorithm strings are: |
55 | | - |
56 | | - - `blake3` |
57 | | - - `md5` |
58 | | - - `sha1` |
59 | | - - `sha256` |
60 | | - - `sha512` |
61 | | - |
62 | | - * `hash`: |
63 | | - For fixed-output derivations, the expected content hash in base-16. |
64 | | - |
65 | | - > **Example** |
66 | | - > |
67 | | - > ```json |
68 | | - > "outputs": { |
69 | | - > "out": { |
70 | | - > "method": "nar", |
71 | | - > "hashAlgo": "sha256", |
72 | | - > "hash": "6fc80dcc62179dbc12fc0b5881275898f93444833d21b89dfe5f7fbcbb1d0d62" |
73 | | - > } |
74 | | - > } |
75 | | - > ``` |
76 | | -
|
77 | | -* `inputSrcs`: |
78 | | - A list of store paths on which this derivation depends. |
79 | | -
|
80 | | - > **Example** |
81 | | - > |
82 | | - > ```json |
83 | | - > "inputSrcs": [ |
84 | | - > "47y241wqdhac3jm5l7nv0x4975mb1975-separate-debug-info.sh", |
85 | | - > "56d0w71pjj9bdr363ym3wj1zkwyqq97j-fix-pop-var-context-error.patch" |
86 | | - > ] |
87 | | - > ``` |
88 | | -
|
89 | | -* `inputDrvs`: |
90 | | - A JSON object specifying the derivations on which this derivation depends, and what outputs of those derivations. |
91 | | -
|
92 | | - > **Example** |
93 | | - > |
94 | | - > ```json |
95 | | - > "inputDrvs": { |
96 | | - > "6lkh5yi7nlb7l6dr8fljlli5zfd9hq58-curl-7.73.0.drv": ["dev"], |
97 | | - > "fn3kgnfzl5dzym26j8g907gq3kbm8bfh-unzip-6.0.drv": ["out"] |
98 | | - > } |
99 | | - > ``` |
100 | | -
|
101 | | - specifies that this derivation depends on the `dev` output of `curl`, and the `out` output of `unzip`. |
102 | | -
|
103 | | -* `system`: |
104 | | - The system type on which this derivation is to be built |
105 | | - (e.g. `x86_64-linux`). |
106 | | -
|
107 | | -* `builder`: |
108 | | - The absolute path of the program to be executed to run the build. |
109 | | - Typically this is the `bash` shell |
110 | | - (e.g. `/nix/store/r3j288vpmczbl500w6zz89gyfa4nr0b1-bash-4.4-p23/bin/bash`). |
111 | | -
|
112 | | -* `args`: |
113 | | - The command-line arguments passed to the `builder`. |
114 | | -
|
115 | | -* `env`: |
116 | | - The environment passed to the `builder`. |
117 | | -
|
118 | | -* `structuredAttrs`: |
119 | | - [Structured Attributes](@docroot@/store/derivation/index.md#structured-attrs), only defined if the derivation contains them. |
120 | | - Structured attributes are JSON, and thus embedded as-is. |
| 6 | +[JSON Schema for Derivation v3](schema/derivation-v3.json) |
| 7 | +--> |
0 commit comments