Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions doc/manual/rl-next/json-format-changes.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,17 @@ The store path info JSON format has been updated from version 1 to version 2:
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": "base64", "hash": "EMIJ+giQ..."}}`
- 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": "base64", "hash": "FePFYIlM..."}`
- 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.

Expand All @@ -48,8 +49,8 @@ The derivation JSON format has been updated from version 3 to version 4:
- **Consistent content addresses**:

Floating content-addressed outputs now use structured JSON format.
This is the same format as `ca` in in store path info (after the new version).
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 it's `show` and `add` sub-commands.
**Affected command**: `nix derivation`, namely its `show` and `add` sub-commands.
18 changes: 3 additions & 15 deletions doc/manual/source/protocols/json/hash.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,28 +2,16 @@

## Examples

### SHA-256 with Base64 encoding

```json
{{#include schema/hash-v1/sha256-base64.json}}
```

### SHA-256 with Base16 (hexadecimal) encoding
### SHA-256

```json
{{#include schema/hash-v1/sha256-base16.json}}
```

### SHA-256 with Nix32 encoding

```json
{{#include schema/hash-v1/sha256-nix32.json}}
```

### BLAKE3 with Base64 encoding
### BLAKE3

```json
{{#include schema/hash-v1/blake3-base64.json}}
{{#include schema/hash-v1/blake3-base16.json}}
```

<!-- need to convert YAML to JSON first
Expand Down
10 changes: 3 additions & 7 deletions doc/manual/source/protocols/json/schema/hash-v1.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,14 @@ properties:
format:
type: string
enum:
- base64
- nix32
- base16
- sri
title: Hash format
description: |
The encoding format of the hash value.
- `base64` uses standard Base64 encoding [RFC 4648, section 4](https://datatracker.ietf.org/doc/html/rfc4648#section-4)
- `nix32` is Nix-specific base-32 encoding
- `base16` is lowercase hexadecimal
- `sri` is the [Subresource Integrity format](https://developer.mozilla.org/en-US/docs/Web/Security/Subresource_Integrity).
`base16` (lowercase hexadecimal) is the only format that is currently supported for JSON serialization.
This field exists primarily to reduce ambiguity about what the hash means.
It would also help us support other formats in the future, but there are no concrete plans to do so at this.
hash:
type: string
title: Hash
Expand Down
4 changes: 1 addition & 3 deletions src/json-schema-checks/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,8 @@ schemas = [
'stem' : 'hash',
'schema' : schema_dir / 'hash-v1.yaml',
'files' : [
'sha256-base64.json',
'sha256-base16.json',
'sha256-nix32.json',
'blake3-base64.json',
'blake3-base16.json',
],
},
{
Expand Down
12 changes: 6 additions & 6 deletions src/libstore-tests/data/common-protocol/content-address.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,24 @@
{
"hash": {
"algorithm": "sha256",
"format": "base64",
"hash": "+Xc9Ll6mcPltwaewrk/BAQ56Y3G5T//wzhKUc0zrYu0="
"format": "base16",
"hash": "f9773d2e5ea670f96dc1a7b0ae4fc1010e7a6371b94ffff0ce1294734ceb62ed"
},
"method": "text"
},
{
"hash": {
"algorithm": "sha1",
"format": "base64",
"hash": "gGemBoenViNZM3hiwqns/Fgzqwo="
"format": "base16",
"hash": "8067a60687a7562359337862c2a9ecfc5833ab0a"
},
"method": "flat"
},
{
"hash": {
"algorithm": "sha256",
"format": "base64",
"hash": "EMIJ+giQ/gLIWoxmPKjno3zHZrxbGymgzGGyZvZBIdM="
"format": "base16",
"hash": "10c209fa0890fe02c85a8c663ca8e7a37cc766bc5b1b29a0cc61b266f64121d3"
},
"method": "nar"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
{
"hash": {
"algorithm": "sha1",
"format": "base64",
"hash": "gGemBoenViNZM3hiwqns/Fgzqwo="
"format": "base16",
"hash": "8067a60687a7562359337862c2a9ecfc5833ab0a"
},
"method": "flat"
}
Expand Down
4 changes: 2 additions & 2 deletions src/libstore-tests/data/content-address/nar.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"hash": {
"algorithm": "sha256",
"format": "base64",
"hash": "9vLqj0XYoFfJVmoz+ZR02i5camYE1zYSFlDicwxvsKM="
"format": "base16",
"hash": "f6f2ea8f45d8a057c9566a33f99474da2e5c6a6604d736121650e2730c6fb0a3"
},
"method": "nar"
}
4 changes: 2 additions & 2 deletions src/libstore-tests/data/content-address/text.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"hash": {
"algorithm": "sha256",
"format": "base64",
"hash": "8OTC92xYkW7CWPJGhRvqCR0U1CR6L8PhhpRGGxgW4Ts="
"format": "base16",
"hash": "f0e4c2f76c58916ec258f246851bea091d14d4247a2fc3e18694461b1816e13b"
},
"method": "text"
}
4 changes: 2 additions & 2 deletions src/libstore-tests/data/derivation/output-caFixedFlat.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"hash": {
"algorithm": "sha256",
"format": "base64",
"hash": "iUUXyRY8iW7DGirb0zwGgf1fRbLA7wimTJKgP7l/OQ8="
"format": "base16",
"hash": "894517c9163c896ec31a2adbd33c0681fd5f45b2c0ef08a64c92a03fb97f390f"
},
"method": "flat"
}
4 changes: 2 additions & 2 deletions src/libstore-tests/data/derivation/output-caFixedNAR.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"hash": {
"algorithm": "sha256",
"format": "base64",
"hash": "iUUXyRY8iW7DGirb0zwGgf1fRbLA7wimTJKgP7l/OQ8="
"format": "base16",
"hash": "894517c9163c896ec31a2adbd33c0681fd5f45b2c0ef08a64c92a03fb97f390f"
},
"method": "nar"
}
4 changes: 2 additions & 2 deletions src/libstore-tests/data/derivation/output-caFixedText.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"hash": {
"algorithm": "sha256",
"format": "base64",
"hash": "iUUXyRY8iW7DGirb0zwGgf1fRbLA7wimTJKgP7l/OQ8="
"format": "base16",
"hash": "894517c9163c896ec31a2adbd33c0681fd5f45b2c0ef08a64c92a03fb97f390f"
},
"method": "text"
}
8 changes: 4 additions & 4 deletions src/libstore-tests/data/dummy-store/one-flat-file.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,16 @@
"ca": {
"hash": {
"algorithm": "sha256",
"format": "base64",
"hash": "f1eduuSIYC1BofXA1tycF79Ai2NSMJQtUErx5DxLYSU="
"format": "base16",
"hash": "7f579dbae488602d41a1f5c0d6dc9c17bf408b635230942d504af1e43c4b6125"
},
"method": "nar"
},
"deriver": null,
"narHash": {
"algorithm": "sha256",
"format": "base64",
"hash": "f1eduuSIYC1BofXA1tycF79Ai2NSMJQtUErx5DxLYSU="
"format": "base16",
"hash": "7f579dbae488602d41a1f5c0d6dc9c17bf408b635230942d504af1e43c4b6125"
},
"narSize": 120,
"references": [],
Expand Down
12 changes: 6 additions & 6 deletions src/libstore-tests/data/nar-info/impure.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,23 @@
"ca": {
"hash": {
"algorithm": "sha256",
"format": "base64",
"hash": "EMIJ+giQ/gLIWoxmPKjno3zHZrxbGymgzGGyZvZBIdM="
"format": "base16",
"hash": "10c209fa0890fe02c85a8c663ca8e7a37cc766bc5b1b29a0cc61b266f64121d3"
},
"method": "nar"
},
"compression": "xz",
"deriver": "/nix/store/g1w7hy3qg1w7hy3qg1w7hy3qg1w7hy3q-bar.drv",
"downloadHash": {
"algorithm": "sha256",
"format": "base64",
"hash": "FePFYIlMuycIXPZbWi7LGEiMmZSX9FMbaQenWBzm1Sc="
"format": "base16",
"hash": "15e3c560894cbb27085cf65b5a2ecb18488c999497f4531b6907a7581ce6d527"
},
"downloadSize": 4029176,
"narHash": {
"algorithm": "sha256",
"format": "base64",
"hash": "FePFYIlMuycIXPZbWi7LGEiMmZSX9FMbaQenWBzm1Sc="
"format": "base16",
"hash": "15e3c560894cbb27085cf65b5a2ecb18488c999497f4531b6907a7581ce6d527"
},
"narSize": 34878,
"references": [
Expand Down
8 changes: 4 additions & 4 deletions src/libstore-tests/data/nar-info/pure.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@
"ca": {
"hash": {
"algorithm": "sha256",
"format": "base64",
"hash": "EMIJ+giQ/gLIWoxmPKjno3zHZrxbGymgzGGyZvZBIdM="
"format": "base16",
"hash": "10c209fa0890fe02c85a8c663ca8e7a37cc766bc5b1b29a0cc61b266f64121d3"
},
"method": "nar"
},
"narHash": {
"algorithm": "sha256",
"format": "base64",
"hash": "FePFYIlMuycIXPZbWi7LGEiMmZSX9FMbaQenWBzm1Sc="
"format": "base16",
"hash": "15e3c560894cbb27085cf65b5a2ecb18488c999497f4531b6907a7581ce6d527"
},
"narSize": 34878,
"references": [
Expand Down
4 changes: 2 additions & 2 deletions src/libstore-tests/data/path-info/empty_impure.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
"deriver": null,
"narHash": {
"algorithm": "sha256",
"format": "base64",
"hash": "FePFYIlMuycIXPZbWi7LGEiMmZSX9FMbaQenWBzm1Sc="
"format": "base16",
"hash": "15e3c560894cbb27085cf65b5a2ecb18488c999497f4531b6907a7581ce6d527"
},
"narSize": 0,
"references": [],
Expand Down
4 changes: 2 additions & 2 deletions src/libstore-tests/data/path-info/empty_pure.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
"ca": null,
"narHash": {
"algorithm": "sha256",
"format": "base64",
"hash": "FePFYIlMuycIXPZbWi7LGEiMmZSX9FMbaQenWBzm1Sc="
"format": "base16",
"hash": "15e3c560894cbb27085cf65b5a2ecb18488c999497f4531b6907a7581ce6d527"
},
"narSize": 0,
"references": [],
Expand Down
8 changes: 4 additions & 4 deletions src/libstore-tests/data/path-info/impure.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@
"ca": {
"hash": {
"algorithm": "sha256",
"format": "base64",
"hash": "EMIJ+giQ/gLIWoxmPKjno3zHZrxbGymgzGGyZvZBIdM="
"format": "base16",
"hash": "10c209fa0890fe02c85a8c663ca8e7a37cc766bc5b1b29a0cc61b266f64121d3"
},
"method": "nar"
},
"deriver": "/nix/store/g1w7hy3qg1w7hy3qg1w7hy3qg1w7hy3q-bar.drv",
"narHash": {
"algorithm": "sha256",
"format": "base64",
"hash": "FePFYIlMuycIXPZbWi7LGEiMmZSX9FMbaQenWBzm1Sc="
"format": "base16",
"hash": "15e3c560894cbb27085cf65b5a2ecb18488c999497f4531b6907a7581ce6d527"
},
"narSize": 34878,
"references": [
Expand Down
8 changes: 4 additions & 4 deletions src/libstore-tests/data/path-info/pure.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@
"ca": {
"hash": {
"algorithm": "sha256",
"format": "base64",
"hash": "EMIJ+giQ/gLIWoxmPKjno3zHZrxbGymgzGGyZvZBIdM="
"format": "base16",
"hash": "10c209fa0890fe02c85a8c663ca8e7a37cc766bc5b1b29a0cc61b266f64121d3"
},
"method": "nar"
},
"narHash": {
"algorithm": "sha256",
"format": "base64",
"hash": "FePFYIlMuycIXPZbWi7LGEiMmZSX9FMbaQenWBzm1Sc="
"format": "base16",
"hash": "15e3c560894cbb27085cf65b5a2ecb18488c999497f4531b6907a7581ce6d527"
},
"narSize": 34878,
"references": [
Expand Down
12 changes: 6 additions & 6 deletions src/libstore-tests/data/serve-protocol/content-address.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,24 @@
{
"hash": {
"algorithm": "sha256",
"format": "base64",
"hash": "+Xc9Ll6mcPltwaewrk/BAQ56Y3G5T//wzhKUc0zrYu0="
"format": "base16",
"hash": "f9773d2e5ea670f96dc1a7b0ae4fc1010e7a6371b94ffff0ce1294734ceb62ed"
},
"method": "text"
},
{
"hash": {
"algorithm": "sha1",
"format": "base64",
"hash": "gGemBoenViNZM3hiwqns/Fgzqwo="
"format": "base16",
"hash": "8067a60687a7562359337862c2a9ecfc5833ab0a"
},
"method": "flat"
},
{
"hash": {
"algorithm": "sha256",
"format": "base64",
"hash": "EMIJ+giQ/gLIWoxmPKjno3zHZrxbGymgzGGyZvZBIdM="
"format": "base16",
"hash": "10c209fa0890fe02c85a8c663ca8e7a37cc766bc5b1b29a0cc61b266f64121d3"
},
"method": "nar"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
{
"hash": {
"algorithm": "sha1",
"format": "base64",
"hash": "gGemBoenViNZM3hiwqns/Fgzqwo="
"format": "base16",
"hash": "8067a60687a7562359337862c2a9ecfc5833ab0a"
},
"method": "flat"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
"deriver": null,
"narHash": {
"algorithm": "sha256",
"format": "base64",
"hash": "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA="
"format": "base16",
"hash": "0000000000000000000000000000000000000000000000000000000000000000"
},
"narSize": 34878,
"references": [],
Expand All @@ -19,8 +19,8 @@
"deriver": "g1w7hy3qg1w7hy3qg1w7hy3qg1w7hy3q-bar.drv",
"narHash": {
"algorithm": "sha256",
"format": "base64",
"hash": "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA="
"format": "base16",
"hash": "0000000000000000000000000000000000000000000000000000000000000000"
},
"narSize": 34878,
"references": [
Expand Down
Loading
Loading