mirror of
https://github.com/NixOS/nix.git
synced 2025-11-08 19:46:02 +01:00
Merge pull request #14427 from obsidiansystems/drv-output-better-schema
Better JSON schema for derivation outputs
This commit is contained in:
commit
f63bb5b338
2 changed files with 162 additions and 27 deletions
|
|
@ -68,7 +68,7 @@ properties:
|
||||||
> }
|
> }
|
||||||
> ```
|
> ```
|
||||||
additionalProperties:
|
additionalProperties:
|
||||||
"$ref": "#/$defs/output"
|
"$ref": "#/$defs/output/overall"
|
||||||
|
|
||||||
inputSrcs:
|
inputSrcs:
|
||||||
type: array
|
type: array
|
||||||
|
|
@ -154,28 +154,116 @@ properties:
|
||||||
|
|
||||||
"$defs":
|
"$defs":
|
||||||
output:
|
output:
|
||||||
type: object
|
overall:
|
||||||
properties:
|
title: Derivation Output
|
||||||
path:
|
description: |
|
||||||
$ref: "store-path-v1.yaml"
|
A single output of a derivation, with different variants for different output types.
|
||||||
title: Output path
|
oneOf:
|
||||||
description: |
|
- "$ref": "#/$defs/output/inputAddressed"
|
||||||
The output path, if known in advance.
|
- "$ref": "#/$defs/output/caFixed"
|
||||||
|
- "$ref": "#/$defs/output/caFloating"
|
||||||
|
- "$ref": "#/$defs/output/deferred"
|
||||||
|
- "$ref": "#/$defs/output/impure"
|
||||||
|
|
||||||
method:
|
inputAddressed:
|
||||||
"$ref": "./content-address-v1.yaml#/$defs/method"
|
title: Input-Addressed Output
|
||||||
description: |
|
description: |
|
||||||
For an output which will be [content addressed](@docroot@/store/derivation/outputs/content-address.md), a string representing the [method](@docroot@/store/store-object/content-address.md) of content addressing that is chosen.
|
The traditional non-fixed-output derivation type.
|
||||||
See the linked original definition for further details.
|
The output path is determined from the derivation itself.
|
||||||
hashAlgo:
|
|
||||||
title: Hash algorithm
|
|
||||||
"$ref": "./hash-v1.yaml#/$defs/algorithm"
|
|
||||||
|
|
||||||
hash:
|
See [Input-addressing derivation outputs](@docroot@/store/derivation/outputs/input-address.md) for more details.
|
||||||
type: string
|
type: object
|
||||||
title: Expected hash value
|
required:
|
||||||
description: |
|
- path
|
||||||
For fixed-output derivations, the expected content hash in base-16.
|
properties:
|
||||||
|
path:
|
||||||
|
$ref: "store-path-v1.yaml"
|
||||||
|
title: Output path
|
||||||
|
description: |
|
||||||
|
The output path determined from the derivation itself.
|
||||||
|
additionalProperties: false
|
||||||
|
|
||||||
|
caFixed:
|
||||||
|
title: Fixed Content-Addressed Output
|
||||||
|
description: |
|
||||||
|
The output is content-addressed, and the content-address is fixed in advance.
|
||||||
|
|
||||||
|
See [Fixed-output content-addressing](@docroot@/store/derivation/outputs/content-address.md#fixed) for more details.
|
||||||
|
type: object
|
||||||
|
required:
|
||||||
|
- method
|
||||||
|
- hashAlgo
|
||||||
|
- hash
|
||||||
|
properties:
|
||||||
|
method:
|
||||||
|
"$ref": "./content-address-v1.yaml#/$defs/method"
|
||||||
|
description: |
|
||||||
|
Method of content addressing used for this output.
|
||||||
|
hashAlgo:
|
||||||
|
title: Hash algorithm
|
||||||
|
"$ref": "./hash-v1.yaml#/$defs/algorithm"
|
||||||
|
hash:
|
||||||
|
type: string
|
||||||
|
title: Expected hash value
|
||||||
|
description: |
|
||||||
|
The expected content hash in base-16.
|
||||||
|
additionalProperties: false
|
||||||
|
|
||||||
|
caFloating:
|
||||||
|
title: Floating Content-Addressed Output
|
||||||
|
description: |
|
||||||
|
Floating-output derivations, whose outputs are content
|
||||||
|
addressed, but not fixed, and so the output paths are dynamically calculated from
|
||||||
|
whatever the output ends up being.
|
||||||
|
|
||||||
|
See [Floating Content-Addressing](@docroot@/store/derivation/outputs/content-address.md#floating) for more details.
|
||||||
|
type: object
|
||||||
|
required:
|
||||||
|
- method
|
||||||
|
- hashAlgo
|
||||||
|
properties:
|
||||||
|
method:
|
||||||
|
"$ref": "./content-address-v1.yaml#/$defs/method"
|
||||||
|
description: |
|
||||||
|
Method of content addressing used for this output.
|
||||||
|
hashAlgo:
|
||||||
|
title: Hash algorithm
|
||||||
|
"$ref": "./hash-v1.yaml#/$defs/algorithm"
|
||||||
|
description: |
|
||||||
|
What hash algorithm to use for the given method of content-addressing.
|
||||||
|
additionalProperties: false
|
||||||
|
|
||||||
|
deferred:
|
||||||
|
title: Deferred Output
|
||||||
|
description: |
|
||||||
|
Input-addressed output which depends on a (CA) derivation whose outputs (and thus their content-address
|
||||||
|
are not yet known.
|
||||||
|
type: object
|
||||||
|
properties: {}
|
||||||
|
additionalProperties: false
|
||||||
|
|
||||||
|
impure:
|
||||||
|
title: Impure Output
|
||||||
|
description: |
|
||||||
|
Impure output which is just like a floating content-addressed output, but this derivation runs without sandboxing.
|
||||||
|
As such, we don't record it in the build trace, under the assumption that if we need it again, we should rebuild it, as it might produce something different.
|
||||||
|
required:
|
||||||
|
- impure
|
||||||
|
- method
|
||||||
|
- hashAlgo
|
||||||
|
properties:
|
||||||
|
impure:
|
||||||
|
const: true
|
||||||
|
method:
|
||||||
|
"$ref": "./content-address-v1.yaml#/$defs/method"
|
||||||
|
description: |
|
||||||
|
How the file system objects will be serialized for hashing.
|
||||||
|
hashAlgo:
|
||||||
|
title: Hash algorithm
|
||||||
|
"$ref": "./hash-v1.yaml#/$defs/algorithm"
|
||||||
|
description: |
|
||||||
|
How the serialization will be hashed.
|
||||||
|
additionalProperties: false
|
||||||
|
|
||||||
outputName:
|
outputName:
|
||||||
type: string
|
type: string
|
||||||
|
|
|
||||||
|
|
@ -45,6 +45,20 @@ schemas = [
|
||||||
'simple.json',
|
'simple.json',
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
'stem' : 'deriving-path',
|
||||||
|
'schema' : schema_dir / 'deriving-path-v1.yaml',
|
||||||
|
'files' : [
|
||||||
|
'single_opaque.json',
|
||||||
|
'single_built.json',
|
||||||
|
'single_built_built.json',
|
||||||
|
],
|
||||||
|
},
|
||||||
|
]
|
||||||
|
|
||||||
|
# Derivation and Derivation output
|
||||||
|
schemas += [
|
||||||
|
# Match overall
|
||||||
{
|
{
|
||||||
'stem' : 'derivation',
|
'stem' : 'derivation',
|
||||||
'schema' : schema_dir / 'derivation-v3.yaml',
|
'schema' : schema_dir / 'derivation-v3.yaml',
|
||||||
|
|
@ -55,7 +69,7 @@ schemas = [
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
'stem' : 'derivation',
|
'stem' : 'derivation',
|
||||||
'schema' : schema_dir / 'derivation-v3.yaml#/$defs/output',
|
'schema' : schema_dir / 'derivation-v3.yaml#/$defs/output/overall',
|
||||||
'files' : [
|
'files' : [
|
||||||
'output-caFixedFlat.json',
|
'output-caFixedFlat.json',
|
||||||
'output-caFixedNAR.json',
|
'output-caFixedNAR.json',
|
||||||
|
|
@ -66,15 +80,48 @@ schemas = [
|
||||||
'output-inputAddressed.json',
|
'output-inputAddressed.json',
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
|
# Match exact variant
|
||||||
{
|
{
|
||||||
'stem' : 'deriving-path',
|
'stem' : 'derivation',
|
||||||
'schema' : schema_dir / 'deriving-path-v1.yaml',
|
'schema' : schema_dir / 'derivation-v3.yaml#/$defs/output/inputAddressed',
|
||||||
'files' : [
|
'files' : [
|
||||||
'single_opaque.json',
|
'output-inputAddressed.json',
|
||||||
'single_built.json',
|
|
||||||
'single_built_built.json',
|
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
'stem' : 'derivation',
|
||||||
|
'schema' : schema_dir / 'derivation-v3.yaml#/$defs/output/caFixed',
|
||||||
|
'files' : [
|
||||||
|
'output-caFixedFlat.json',
|
||||||
|
'output-caFixedNAR.json',
|
||||||
|
'output-caFixedText.json',
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
'stem' : 'derivation',
|
||||||
|
'schema' : schema_dir / 'derivation-v3.yaml#/$defs/output/caFloating',
|
||||||
|
'files' : [
|
||||||
|
'output-caFloating.json',
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
'stem' : 'derivation',
|
||||||
|
'schema' : schema_dir / 'derivation-v3.yaml#/$defs/output/deferred',
|
||||||
|
'files' : [
|
||||||
|
'output-deferred.json',
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
'stem' : 'derivation',
|
||||||
|
'schema' : schema_dir / 'derivation-v3.yaml#/$defs/output/impure',
|
||||||
|
'files' : [
|
||||||
|
'output-impure.json',
|
||||||
|
],
|
||||||
|
},
|
||||||
|
]
|
||||||
|
|
||||||
|
# Store object info
|
||||||
|
schemas += [
|
||||||
# Match overall
|
# Match overall
|
||||||
{
|
{
|
||||||
'stem' : 'store-object-info',
|
'stem' : 'store-object-info',
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue