mirror of
https://github.com/NixOS/nix.git
synced 2025-12-09 02:21:02 +01:00
Fix #14532. As discussed on the call today: 1. We'll stick with `format = "base16"` and `hash = "<hash>"`, not do `base16 = "<hash>"`, in order to be forward compatible with supporting more versioning formats. The motivation we discussed for someday *possibly* doing this is making it easier to write very slap-dash lang2nix tools that create (not consume) derivations with dynamic derivations. 2. We will remove support for non-base16 (and make that the default, not base64) in `Hash`, so this is strictly forward contingency, *not* yet something we support. (And also not something we have concrete plans to start supporting.)
56 lines
1.8 KiB
Markdown
56 lines
1.8 KiB
Markdown
---
|
|
synopsis: "JSON format changes for store path info and derivations"
|
|
prs: []
|
|
issues: []
|
|
---
|
|
|
|
JSON formats for store path info and derivations have been updated with new versions and structured fields.
|
|
|
|
## Store Path Info JSON (Version 2)
|
|
|
|
The store path info JSON format has been updated from version 1 to version 2:
|
|
|
|
- **Added `version` field**:
|
|
|
|
All store path info JSON now includes `"version": 2`.
|
|
|
|
- **Structured `ca` field**:
|
|
|
|
Content address is now a structured JSON object instead of a string:
|
|
|
|
- Old: `"ca": "fixed:r:sha256:1abc..."`
|
|
- New: `"ca": {"method": "nar", "hash": {"algorithm": "sha256", "format": "base16", "hash": "10c209fa..."}}`
|
|
- Still `null` values for input-addressed store objects
|
|
|
|
- **Structured hash fields**:
|
|
|
|
Hash values (`narHash` and `downloadHash`) are now structured JSON objects instead of strings:
|
|
|
|
- Old: `"narHash": "sha256:FePFYIlMuycIXPZbWi7LGEiMmZSX9FMbaQenWBzm1Sc="`
|
|
- New: `"narHash": {"algorithm": "sha256", "format": "base16", "hash": "15e3c5608946..."}`
|
|
- Same structure applies to `downloadHash` in NAR info contexts
|
|
- The `format` field is always `"base16"` (hexadecimal)
|
|
|
|
Nix currently only produces, and doesn't consume this format.
|
|
|
|
**Affected command**: `nix path-info --json`
|
|
|
|
## Derivation JSON (Version 4)
|
|
|
|
The derivation JSON format has been updated from version 3 to version 4:
|
|
|
|
- **Restructured inputs**:
|
|
|
|
Inputs are now nested under an `inputs` object:
|
|
|
|
- Old: `"inputSrcs": [...], "inputDrvs": {...}`
|
|
- New: `"inputs": {"srcs": [...], "drvs": {...}}`
|
|
|
|
- **Consistent content addresses**:
|
|
|
|
Floating content-addressed outputs now use structured JSON format.
|
|
This is the same format as `ca` in store path info (after the new version).
|
|
|
|
Version 3 and earlier formats are *not* accepted when reading.
|
|
|
|
**Affected command**: `nix derivation`, namely its `show` and `add` sub-commands.
|