Skip to content

Commit 949a9fa

Browse files
committed
JSON for Hash now has to be Base16
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.)
1 parent 68a5110 commit 949a9fa

File tree

22 files changed

+82
-99
lines changed

22 files changed

+82
-99
lines changed

doc/manual/source/protocols/json/hash.md

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,28 +2,16 @@
22

33
## Examples
44

5-
### SHA-256 with Base64 encoding
6-
7-
```json
8-
{{#include schema/hash-v1/sha256-base64.json}}
9-
```
10-
11-
### SHA-256 with Base16 (hexadecimal) encoding
5+
### SHA-256
126

137
```json
148
{{#include schema/hash-v1/sha256-base16.json}}
159
```
1610

17-
### SHA-256 with Nix32 encoding
18-
19-
```json
20-
{{#include schema/hash-v1/sha256-nix32.json}}
21-
```
22-
23-
### BLAKE3 with Base64 encoding
11+
### BLAKE3
2412

2513
```json
26-
{{#include schema/hash-v1/blake3-base64.json}}
14+
{{#include schema/hash-v1/blake3-base16.json}}
2715
```
2816

2917
<!-- need to convert YAML to JSON first

doc/manual/source/protocols/json/schema/hash-v1.yaml

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,18 +12,14 @@ properties:
1212
format:
1313
type: string
1414
enum:
15-
- base64
16-
- nix32
1715
- base16
18-
- sri
1916
title: Hash format
2017
description: |
2118
The encoding format of the hash value.
2219
23-
- `base64` uses standard Base64 encoding [RFC 4648, section 4](https://datatracker.ietf.org/doc/html/rfc4648#section-4)
24-
- `nix32` is Nix-specific base-32 encoding
25-
- `base16` is lowercase hexadecimal
26-
- `sri` is the [Subresource Integrity format](https://developer.mozilla.org/en-US/docs/Web/Security/Subresource_Integrity).
20+
`base16` (lowercase hexadecimal) is the only format that is currently supported for JSON serialization.
21+
This field exists primarily to reduce ambiguity about what the hash means.
22+
It would also help us support other formats in the future, but there are no concrete plans to do so at this.
2723
hash:
2824
type: string
2925
title: Hash

src/json-schema-checks/meson.build

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,8 @@ schemas = [
2424
'stem' : 'hash',
2525
'schema' : schema_dir / 'hash-v1.yaml',
2626
'files' : [
27-
'sha256-base64.json',
2827
'sha256-base16.json',
29-
'sha256-nix32.json',
30-
'blake3-base64.json',
28+
'blake3-base16.json',
3129
],
3230
},
3331
{
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
{
22
"hash": {
33
"algorithm": "sha256",
4-
"format": "base64",
5-
"hash": "9vLqj0XYoFfJVmoz+ZR02i5camYE1zYSFlDicwxvsKM="
4+
"format": "base16",
5+
"hash": "f6f2ea8f45d8a057c9566a33f99474da2e5c6a6604d736121650e2730c6fb0a3"
66
},
77
"method": "nar"
88
}
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
{
22
"hash": {
33
"algorithm": "sha256",
4-
"format": "base64",
5-
"hash": "8OTC92xYkW7CWPJGhRvqCR0U1CR6L8PhhpRGGxgW4Ts="
4+
"format": "base16",
5+
"hash": "f0e4c2f76c58916ec258f246851bea091d14d4247a2fc3e18694461b1816e13b"
66
},
77
"method": "text"
88
}
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
{
22
"hash": {
33
"algorithm": "sha256",
4-
"format": "base64",
5-
"hash": "iUUXyRY8iW7DGirb0zwGgf1fRbLA7wimTJKgP7l/OQ8="
4+
"format": "base16",
5+
"hash": "894517c9163c896ec31a2adbd33c0681fd5f45b2c0ef08a64c92a03fb97f390f"
66
},
77
"method": "flat"
88
}
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
{
22
"hash": {
33
"algorithm": "sha256",
4-
"format": "base64",
5-
"hash": "iUUXyRY8iW7DGirb0zwGgf1fRbLA7wimTJKgP7l/OQ8="
4+
"format": "base16",
5+
"hash": "894517c9163c896ec31a2adbd33c0681fd5f45b2c0ef08a64c92a03fb97f390f"
66
},
77
"method": "nar"
88
}
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
{
22
"hash": {
33
"algorithm": "sha256",
4-
"format": "base64",
5-
"hash": "iUUXyRY8iW7DGirb0zwGgf1fRbLA7wimTJKgP7l/OQ8="
4+
"format": "base16",
5+
"hash": "894517c9163c896ec31a2adbd33c0681fd5f45b2c0ef08a64c92a03fb97f390f"
66
},
77
"method": "text"
88
}

src/libstore-tests/data/nar-info/impure.json

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,23 +2,23 @@
22
"ca": {
33
"hash": {
44
"algorithm": "sha256",
5-
"format": "base64",
6-
"hash": "EMIJ+giQ/gLIWoxmPKjno3zHZrxbGymgzGGyZvZBIdM="
5+
"format": "base16",
6+
"hash": "10c209fa0890fe02c85a8c663ca8e7a37cc766bc5b1b29a0cc61b266f64121d3"
77
},
88
"method": "nar"
99
},
1010
"compression": "xz",
1111
"deriver": "/nix/store/g1w7hy3qg1w7hy3qg1w7hy3qg1w7hy3q-bar.drv",
1212
"downloadHash": {
1313
"algorithm": "sha256",
14-
"format": "base64",
15-
"hash": "FePFYIlMuycIXPZbWi7LGEiMmZSX9FMbaQenWBzm1Sc="
14+
"format": "base16",
15+
"hash": "15e3c560894cbb27085cf65b5a2ecb18488c999497f4531b6907a7581ce6d527"
1616
},
1717
"downloadSize": 4029176,
1818
"narHash": {
1919
"algorithm": "sha256",
20-
"format": "base64",
21-
"hash": "FePFYIlMuycIXPZbWi7LGEiMmZSX9FMbaQenWBzm1Sc="
20+
"format": "base16",
21+
"hash": "15e3c560894cbb27085cf65b5a2ecb18488c999497f4531b6907a7581ce6d527"
2222
},
2323
"narSize": 34878,
2424
"references": [

src/libstore-tests/data/nar-info/pure.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,15 @@
22
"ca": {
33
"hash": {
44
"algorithm": "sha256",
5-
"format": "base64",
6-
"hash": "EMIJ+giQ/gLIWoxmPKjno3zHZrxbGymgzGGyZvZBIdM="
5+
"format": "base16",
6+
"hash": "10c209fa0890fe02c85a8c663ca8e7a37cc766bc5b1b29a0cc61b266f64121d3"
77
},
88
"method": "nar"
99
},
1010
"narHash": {
1111
"algorithm": "sha256",
12-
"format": "base64",
13-
"hash": "FePFYIlMuycIXPZbWi7LGEiMmZSX9FMbaQenWBzm1Sc="
12+
"format": "base16",
13+
"hash": "15e3c560894cbb27085cf65b5a2ecb18488c999497f4531b6907a7581ce6d527"
1414
},
1515
"narSize": 34878,
1616
"references": [

0 commit comments

Comments
 (0)