-
Notifications
You must be signed in to change notification settings - Fork 5
Add JSON Schema for bootspec #176
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
372818a
6a00b80
0689437
f61a3ec
ca80fc4
7b01a25
615e6a4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| use flake |
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we combine this with the CUE validator that has been deployed in Nixpkgs for 2+ years now: https://github.com/NixOS/nixpkgs/blob/0d296899ff1525e7af62a6b69122a70b26050b5f/nixos/modules/system/activation/bootspec.cue CUE supports importing JSON Schema into CUE (https://cuelang.org/docs/concept/how-cue-works-with-json-schema/), so maybe we can do something to ensure the canonical CUE from Nixpkgs and the JSON Schema here are the same.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Since this is reflecting the documented syntax, I like the option of publishing this JSON schema document that can be used from CUE. If it is identified to be insufficient / not reflecting the spec as designed, we can update it. I'm not too fussed about it being precisely / perfectly matched immediately, since it is unlikely to supplant the cue document right away.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'd still rather ensure that they are the same (by comparing them), than hoping they are the same.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, fwiw I did compare them by reading the code and was satisfied they were the same.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Though perhaps not totally satisfactory. I pasted this sample: https://github.com/DeterminateSystems/bootspec/blob/9f2a933acda49fe6a146dac3050b1b9d8b20e4f9/synthesize/integration-test-cases/expected-synthesis/21.11-specialisations.json and it complains:
I think something might be missing.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ok, yeah, generally the handling of specialisations aren't right.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The thing is, the goal is not to have a functioning validator. The goal is to have a JSON spec and to generate docs with it (and have IDEs and other tools consume it). Ideally you could have a |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,87 @@ | ||
| { | ||
| "$id": "https://raw.githubusercontent.com/DeterminateSystems/bootspec/v1.0.0/schema.json", | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we host this somewhere nicer, to give this a nicer URL?
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Any suggestions?
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This probably won't work, since this schema didn't exist when we released v1.0.0, back in 2023 :) |
||
| "$schema": "https://json-schema.org/draft/2020-12/schema", | ||
| "title": "NixOS bootspec v1 schema", | ||
| "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.", | ||
| "type": "object", | ||
| "required": ["org.nixos.bootspec.v1"], | ||
| "properties": { | ||
| "org.nixos.bootspec.v1": { "$ref": "#/$defs/Bootspec" }, | ||
| "org.nixos.specialisation.v1": { | ||
| "type": "object", | ||
| "patternProperties": { | ||
| "^.*$": { | ||
| "type": "object", | ||
| "properties": { | ||
| "org.nixos.bootspec.v1": { "$ref": "#/$defs/Bootspec" } | ||
| }, | ||
| "required": ["org.nixos.bootspec.v1"], | ||
| "additionalProperties": true | ||
| } | ||
| } | ||
| } | ||
|
Comment on lines
+10
to
+22
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm pretty sure this matches what is described |
||
| }, | ||
| "patternProperties": { | ||
| "^.*$": { | ||
| "$ref": "#/$defs/Bootspec", | ||
| "description": "Testing" | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. . |
||
| } | ||
| }, | ||
| "$defs": { | ||
| "Bootspec": { | ||
lucperkins marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| "type": "object", | ||
| "required": ["init", "kernel", "kernelParams", "label", "system", "toplevel"], | ||
| "properties": { | ||
| "init": { | ||
| "type": "string", | ||
| "description": "Nix store path to the stage-2 init, executed by initrd (if present)." | ||
| }, | ||
| "kernel": { | ||
| "type": "string", | ||
| "description": "Nix store path to the kernel image." | ||
| }, | ||
| "kernelParams": { | ||
| "type": "array", | ||
| "items": { | ||
| "type": "string" | ||
| }, | ||
| "description": "Kernel command line options.", | ||
| "examples": [ | ||
| [ | ||
| "amd_iommu=on", | ||
| "amd_iommu=pt", | ||
| "iommu=pt", | ||
| "kvm.ignore_msrs=1", | ||
| "kvm.report_ignored_msrs=0", | ||
| "udev.log_priority=3", | ||
| "systemd.unified_cgroup_hierarchy=1", | ||
| "loglevel=4" | ||
| ] | ||
| ] | ||
| }, | ||
| "label": { | ||
| "type": "string", | ||
| "description": "A human-readable label for the system. It should contain the operating system, kernel version,and other user-relevant information to identify the system. This corresponds loosely to `config.system.nixos.label`.", | ||
| "examples": ["NixOS 21.11.20210810.dirty (Linux 5.15.30)"] | ||
| }, | ||
| "system": { | ||
| "type": "string", | ||
| "description": "Nix system type the bootspec is intended for.", | ||
| "examples": ["x86_64-linux", "aarch64-linux"] | ||
| }, | ||
| "toplevel": { | ||
| "type": "string", | ||
| "description": "Top-level Nix store path of the system closure." | ||
| }, | ||
| "initrd": { | ||
| "type": "string", | ||
| "description": "Nix store path to the initrd." | ||
| }, | ||
| "initrdSecrets": { | ||
| "type": "string", | ||
| "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." | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.