Skip to content

Commit eff243d

Browse files
authored
Fixes for JSON Schema (#178)
* Publish docs only on pushes to main * Rename bootspec def * Fix top-level specialisation definition * Use main branch in schema URL * Add Nix store path type to schema * Add kernel params type
1 parent 9f2a933 commit eff243d

File tree

3 files changed

+79
-55
lines changed

3 files changed

+79
-55
lines changed

.github/workflows/ci.yml

Lines changed: 2 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -68,38 +68,8 @@ jobs:
6868
- uses: DeterminateSystems/flakehub-cache-action@main
6969
- name: Validate JSON Schema
7070
run: nix develop --command jv ./schema.json
71-
72-
BuildAndPublishJsonSchemaDocs:
73-
runs-on: ubuntu-latest
74-
environment:
75-
name: github-pages
76-
url: ${{ steps.publish.outputs.page_url }}
77-
permissions:
78-
contents: read
79-
pages: write
80-
id-token: write
81-
steps:
82-
- uses: actions/checkout@v4
83-
with:
84-
fetch-depth: 0
85-
- uses: DeterminateSystems/nix-installer-action@main
86-
with:
87-
determinate: true
88-
- uses: DeterminateSystems/flakehub-cache-action@main
89-
- name: Set up GitHub Pages
90-
uses: actions/configure-pages@v5
91-
- name: Generate JSON Schema docs
92-
id: generate
93-
run: |
94-
mkdir -p dist
95-
nix develop --command generate-schema-doc --config expand_buttons=true schema.json dist/index.html
96-
- name: Upload docs
97-
uses: actions/upload-pages-artifact@v3
98-
with:
99-
path: ./dist
100-
- name: Publish docs to GitHub Pages
101-
id: publish
102-
uses: actions/deploy-pages@v4
71+
- name: Validate JSON Schema against example
72+
run: nix develop --command jv ./schema.json ./bootspec/rfc0125_spec.json
10373

10474
SynthesizeIntegration:
10575
runs-on: ubuntu-latest

.github/workflows/json-schema.yaml

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
name: Bootspec JSON Schema
2+
3+
on:
4+
push:
5+
branches: [main]
6+
7+
jobs:
8+
BuildAndPublishJsonSchemaDocs:
9+
runs-on: ubuntu-latest
10+
environment:
11+
name: github-pages
12+
url: ${{ steps.publish.outputs.page_url }}
13+
permissions:
14+
contents: read
15+
pages: write
16+
id-token: write
17+
steps:
18+
- uses: actions/checkout@v4
19+
with:
20+
fetch-depth: 0
21+
- uses: DeterminateSystems/nix-installer-action@main
22+
with:
23+
determinate: true
24+
- uses: DeterminateSystems/flakehub-cache-action@main
25+
- name: Set up GitHub Pages
26+
uses: actions/configure-pages@v5
27+
- name: Generate JSON Schema docs
28+
id: generate
29+
run: |
30+
mkdir -p dist
31+
nix develop --command generate-schema-doc --config expand_buttons=true schema.json dist/index.html
32+
- name: Upload docs
33+
uses: actions/upload-pages-artifact@v3
34+
with:
35+
path: ./dist
36+
- name: Publish docs to GitHub Pages
37+
id: publish
38+
uses: actions/deploy-pages@v4

schema.json

Lines changed: 39 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
11
{
2-
"$id": "https://raw.githubusercontent.com/DeterminateSystems/bootspec/v1.0.0/schema.json",
2+
"$id": "https://raw.githubusercontent.com/DeterminateSystems/bootspec/main/schema.json",
33
"$schema": "https://json-schema.org/draft/2020-12/schema",
44
"title": "NixOS bootspec v1 schema",
55
"description": "Bootspec is a set of memoized facts about a system's closure. The top-level object may contain arbitrary further keys (\"extensions\") whose semantics may be defined by third parties. The use of reverse-domain-name namespacing is recommended in order to avoid name collisions.",
66
"type": "object",
77
"required": ["org.nixos.bootspec.v1"],
88
"properties": {
9-
"org.nixos.bootspec.v1": { "$ref": "#/$defs/Bootspec" },
9+
"org.nixos.bootspec.v1": { "$ref": "#/$defs/BootspecV1" },
1010
"org.nixos.specialisation.v1": {
1111
"type": "object",
1212
"patternProperties": {
1313
"^.*$": {
1414
"type": "object",
1515
"properties": {
16-
"org.nixos.bootspec.v1": { "$ref": "#/$defs/Bootspec" }
16+
"org.nixos.bootspec.v1": { "$ref": "#/$defs/BootspecV1" }
1717
},
1818
"required": ["org.nixos.bootspec.v1"],
1919
"additionalProperties": true
@@ -23,39 +23,40 @@
2323
},
2424
"patternProperties": {
2525
"^.*$": {
26-
"$ref": "#/$defs/Bootspec",
27-
"description": "Testing"
26+
"description": "Additional top-level specialisations"
2827
}
2928
},
3029
"$defs": {
31-
"Bootspec": {
30+
"BootspecV1": {
3231
"type": "object",
3332
"required": ["init", "kernel", "kernelParams", "label", "system", "toplevel"],
3433
"properties": {
3534
"init": {
36-
"type": "string",
35+
"allOf": [
36+
{ "$ref": "#/$defs/NixStorePath" }
37+
],
3738
"description": "Nix store path to the stage-2 init, executed by initrd (if present)."
3839
},
3940
"kernel": {
40-
"type": "string",
41+
"allOf": [
42+
{ "$ref": "#/$defs/NixStorePath" }
43+
],
4144
"description": "Nix store path to the kernel image."
4245
},
4346
"kernelParams": {
4447
"type": "array",
45-
"items": {
46-
"type": "string"
47-
},
48-
"description": "Kernel command line options.",
48+
"items": { "$ref": "#/$defs/KernelParameter" },
49+
"description": "List of kernel parameters",
4950
"examples": [
5051
[
51-
"amd_iommu=on",
52-
"amd_iommu=pt",
53-
"iommu=pt",
54-
"kvm.ignore_msrs=1",
55-
"kvm.report_ignored_msrs=0",
56-
"udev.log_priority=3",
57-
"systemd.unified_cgroup_hierarchy=1",
58-
"loglevel=4"
52+
"amd_iommu=on",
53+
"amd_iommu=pt",
54+
"iommu=pt",
55+
"kvm.ignore_msrs=1",
56+
"kvm.report_ignored_msrs=0",
57+
"udev.log_priority=3",
58+
"systemd.unified_cgroup_hierarchy=1",
59+
"loglevel=4"
5960
]
6061
]
6162
},
@@ -70,18 +71,33 @@
7071
"examples": ["x86_64-linux", "aarch64-linux"]
7172
},
7273
"toplevel": {
73-
"type": "string",
74+
"allOf": [
75+
{ "$ref": "#/$defs/NixStorePath" }
76+
],
7477
"description": "Top-level Nix store path of the system closure."
7578
},
7679
"initrd": {
77-
"type": "string",
80+
"allOf": [
81+
{ "$ref": "#/$defs/NixStorePath" }
82+
],
7883
"description": "Nix store path to the initrd."
7984
},
8085
"initrdSecrets": {
81-
"type": "string",
86+
"allOf": [
87+
{ "$ref": "#/$defs/NixStorePath" }
88+
],
8289
"description": "Nix store path to a tool that dynamically adds secrets to initrd. Consumers of a bootspec document should copy the file referenced by the `initrd` key to a writable location, ensure that the file is writable, invoke this tool with the path to the initrd as its only argument, and use the initrd as modified by the tool for booting. This may be used to add files from outside the Nix store to the initrd. This tool is expected to run on the system whose boot specification is being set up, and may thus fail if used on a system where the expected stateful files are not in place or whose CPU does not support the instruction set of the system to be booted. If this field is present and the tool fails, no boot configuration should be generated for the system."
8390
}
8491
}
92+
},
93+
"KernelParameter": {
94+
"type": "string",
95+
"pattern": "^[a-zA-Z0-9._-]+(=[^\\s=]+)?$",
96+
"description": "A kernel parameter in the form key[=value], e.g., loglevel=4 or quiet"
97+
},
98+
"NixStorePath": {
99+
"type": "string",
100+
"description": "A valid Nix store path"
85101
}
86102
}
87103
}

0 commit comments

Comments
 (0)