mirror of
https://github.com/NixOS/nix.git
synced 2025-11-08 19:46:02 +01:00
Merge pull request #14405 from obsidiansystems/json-schema-store-path
Create JSON Schema for Store Paths
This commit is contained in:
commit
f1d4fab1e5
11 changed files with 97 additions and 3 deletions
|
|
@ -36,6 +36,7 @@ mkMesonDerivation (finalAttrs: {
|
||||||
# For example JSON
|
# For example JSON
|
||||||
../../src/libutil-tests/data/hash
|
../../src/libutil-tests/data/hash
|
||||||
../../src/libstore-tests/data/content-address
|
../../src/libstore-tests/data/content-address
|
||||||
|
../../src/libstore-tests/data/store-path
|
||||||
../../src/libstore-tests/data/derived-path
|
../../src/libstore-tests/data/derived-path
|
||||||
# Too many different types of files to filter for now
|
# Too many different types of files to filter for now
|
||||||
../../doc/manual
|
../../doc/manual
|
||||||
|
|
|
||||||
|
|
@ -119,6 +119,7 @@
|
||||||
- [JSON Formats](protocols/json/index.md)
|
- [JSON Formats](protocols/json/index.md)
|
||||||
- [Hash](protocols/json/hash.md)
|
- [Hash](protocols/json/hash.md)
|
||||||
- [Content Address](protocols/json/content-address.md)
|
- [Content Address](protocols/json/content-address.md)
|
||||||
|
- [Store Path](protocols/json/store-path.md)
|
||||||
- [Store Object Info](protocols/json/store-object-info.md)
|
- [Store Object Info](protocols/json/store-object-info.md)
|
||||||
- [Derivation](protocols/json/derivation.md)
|
- [Derivation](protocols/json/derivation.md)
|
||||||
- [Deriving Path](protocols/json/deriving-path.md)
|
- [Deriving Path](protocols/json/deriving-path.md)
|
||||||
|
|
|
||||||
|
|
@ -11,6 +11,7 @@ json_schema_config = files('json-schema-for-humans-config.yaml')
|
||||||
schemas = [
|
schemas = [
|
||||||
'hash-v1',
|
'hash-v1',
|
||||||
'content-address-v1',
|
'content-address-v1',
|
||||||
|
'store-path-v1',
|
||||||
'derivation-v3',
|
'derivation-v3',
|
||||||
'deriving-path-v1',
|
'deriving-path-v1',
|
||||||
]
|
]
|
||||||
|
|
|
||||||
|
|
@ -85,7 +85,7 @@ properties:
|
||||||
> ]
|
> ]
|
||||||
> ```
|
> ```
|
||||||
items:
|
items:
|
||||||
type: string
|
$ref: "store-path-v1.yaml"
|
||||||
|
|
||||||
inputDrvs:
|
inputDrvs:
|
||||||
type: object
|
type: object
|
||||||
|
|
@ -103,6 +103,15 @@ properties:
|
||||||
> ```
|
> ```
|
||||||
>
|
>
|
||||||
> specifies that this derivation depends on the `dev` output of `curl`, and the `out` output of `unzip`.
|
> specifies that this derivation depends on the `dev` output of `curl`, and the `out` output of `unzip`.
|
||||||
|
patternProperties:
|
||||||
|
"^[0123456789abcdfghijklmnpqrsvwxyz]{32}-.+\\.drv$":
|
||||||
|
title: Store Path
|
||||||
|
description: |
|
||||||
|
A store path to a derivation, mapped to the outputs of that derivation.
|
||||||
|
oneOf:
|
||||||
|
- "$ref": "#/$defs/outputNames"
|
||||||
|
- "$ref": "#/$defs/dynamicOutputs"
|
||||||
|
additionalProperties: false
|
||||||
|
|
||||||
system:
|
system:
|
||||||
type: string
|
type: string
|
||||||
|
|
@ -148,7 +157,7 @@ properties:
|
||||||
type: object
|
type: object
|
||||||
properties:
|
properties:
|
||||||
path:
|
path:
|
||||||
type: string
|
$ref: "store-path-v1.yaml"
|
||||||
title: Output path
|
title: Output path
|
||||||
description: |
|
description: |
|
||||||
The output path, if known in advance.
|
The output path, if known in advance.
|
||||||
|
|
@ -167,3 +176,28 @@ properties:
|
||||||
title: Expected hash value
|
title: Expected hash value
|
||||||
description: |
|
description: |
|
||||||
For fixed-output derivations, the expected content hash in base-16.
|
For fixed-output derivations, the expected content hash in base-16.
|
||||||
|
|
||||||
|
outputName:
|
||||||
|
type: string
|
||||||
|
title: Output name
|
||||||
|
description: Name of the derivation output to depend on
|
||||||
|
|
||||||
|
outputNames:
|
||||||
|
type: array
|
||||||
|
title: Output Names
|
||||||
|
description: Set of names of derivation outputs to depend on
|
||||||
|
items:
|
||||||
|
"$ref": "#/$defs/outputName"
|
||||||
|
|
||||||
|
dynamicOutputs:
|
||||||
|
type: object
|
||||||
|
title: Dynamic Outputs
|
||||||
|
description: |
|
||||||
|
**Experimental feature**: [`dynamic-derivations`](@docroot@/development/experimental-features.md#xp-feature-dynamic-derivations)
|
||||||
|
|
||||||
|
This recursive data type allows for depending on outputs of outputs.
|
||||||
|
properties:
|
||||||
|
outputs:
|
||||||
|
"$ref": "#/$defs/outputNames"
|
||||||
|
dynamicOutputs:
|
||||||
|
"$ref": "#/$defs/dynamicOutputs"
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,7 @@ oneOf:
|
||||||
- title: Constant
|
- title: Constant
|
||||||
description: |
|
description: |
|
||||||
See [Constant](@docroot@/store/derivation/index.md#deriving-path-constant) deriving path.
|
See [Constant](@docroot@/store/derivation/index.md#deriving-path-constant) deriving path.
|
||||||
type: string
|
$ref: "store-path-v1.yaml"
|
||||||
- title: Output
|
- title: Output
|
||||||
description: |
|
description: |
|
||||||
See [Output](@docroot@/store/derivation/index.md#deriving-path-output) deriving path.
|
See [Output](@docroot@/store/derivation/index.md#deriving-path-output) deriving path.
|
||||||
|
|
|
||||||
1
doc/manual/source/protocols/json/schema/store-path-v1
Symbolic link
1
doc/manual/source/protocols/json/schema/store-path-v1
Symbolic link
|
|
@ -0,0 +1 @@
|
||||||
|
../../../../../../src/libstore-tests/data/store-path
|
||||||
32
doc/manual/source/protocols/json/schema/store-path-v1.yaml
Normal file
32
doc/manual/source/protocols/json/schema/store-path-v1.yaml
Normal file
|
|
@ -0,0 +1,32 @@
|
||||||
|
"$schema": "http://json-schema.org/draft-07/schema"
|
||||||
|
"$id": "https://nix.dev/manual/nix/latest/protocols/json/schema/store-path-v1.json"
|
||||||
|
title: Store Path
|
||||||
|
description: |
|
||||||
|
A [store path](@docroot@/store/store-path.md) identifying a store object.
|
||||||
|
|
||||||
|
This schema describes the JSON representation of store paths as used in various Nix JSON APIs.
|
||||||
|
|
||||||
|
> **Warning**
|
||||||
|
>
|
||||||
|
> This JSON format is currently
|
||||||
|
> [**experimental**](@docroot@/development/experimental-features.md#xp-feature-nix-command)
|
||||||
|
> and subject to change.
|
||||||
|
|
||||||
|
## Format
|
||||||
|
|
||||||
|
Store paths in JSON are represented as strings containing just the hash and name portion, without the store directory prefix.
|
||||||
|
|
||||||
|
For example: `"g1w7hy3qg1w7hy3qg1w7hy3qg1w7hy3q-foo.drv"`
|
||||||
|
|
||||||
|
(If the store dir is `/nix/store`, then this corresponds to the path `/nix/store/g1w7hy3qg1w7hy3qg1w7hy3qg1w7hy3q-foo.drv`.)
|
||||||
|
|
||||||
|
## Structure
|
||||||
|
|
||||||
|
The format follows this pattern: `${digest}-${name}`
|
||||||
|
|
||||||
|
- **hash**: Digest rendered in a custom variant of [Base32](https://en.wikipedia.org/wiki/Base32) (20 arbitrary bytes become 32 ASCII characters)
|
||||||
|
- **name**: The package name and optional version/suffix information
|
||||||
|
|
||||||
|
type: string
|
||||||
|
pattern: "^[0123456789abcdfghijklmnpqrsvwxyz]{32}-.+$"
|
||||||
|
minLength: 34
|
||||||
15
doc/manual/source/protocols/json/store-path.md
Normal file
15
doc/manual/source/protocols/json/store-path.md
Normal file
|
|
@ -0,0 +1,15 @@
|
||||||
|
{{#include store-path-v1-fixed.md}}
|
||||||
|
|
||||||
|
## Examples
|
||||||
|
|
||||||
|
### Simple store path
|
||||||
|
|
||||||
|
```json
|
||||||
|
{{#include schema/store-path-v1/simple.json}}
|
||||||
|
```
|
||||||
|
|
||||||
|
<!--
|
||||||
|
## Raw Schema
|
||||||
|
|
||||||
|
[JSON Schema for Store Path v1](schema/store-path-v1.json)
|
||||||
|
-->
|
||||||
|
|
@ -38,6 +38,13 @@ schemas = [
|
||||||
'nar.json',
|
'nar.json',
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
'stem' : 'store-path',
|
||||||
|
'schema' : schema_dir / 'store-path-v1.yaml',
|
||||||
|
'files' : [
|
||||||
|
'simple.json',
|
||||||
|
],
|
||||||
|
},
|
||||||
{
|
{
|
||||||
'stem' : 'derivation',
|
'stem' : 'derivation',
|
||||||
'schema' : schema_dir / 'derivation-v3.yaml',
|
'schema' : schema_dir / 'derivation-v3.yaml',
|
||||||
|
|
|
||||||
|
|
@ -22,6 +22,7 @@ mkMesonDerivation (finalAttrs: {
|
||||||
../../doc/manual/source/protocols/json/schema
|
../../doc/manual/source/protocols/json/schema
|
||||||
../../src/libutil-tests/data/hash
|
../../src/libutil-tests/data/hash
|
||||||
../../src/libstore-tests/data/content-address
|
../../src/libstore-tests/data/content-address
|
||||||
|
../../src/libstore-tests/data/store-path
|
||||||
../../src/libstore-tests/data/derivation
|
../../src/libstore-tests/data/derivation
|
||||||
../../src/libstore-tests/data/derived-path
|
../../src/libstore-tests/data/derived-path
|
||||||
./.
|
./.
|
||||||
|
|
|
||||||
1
src/json-schema-checks/store-path
Symbolic link
1
src/json-schema-checks/store-path
Symbolic link
|
|
@ -0,0 +1 @@
|
||||||
|
../../src/libstore-tests/data/store-path
|
||||||
Loading…
Add table
Add a link
Reference in a new issue