You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: .claude/skills/add-package/SKILL.md
+20-5Lines changed: 20 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -62,11 +62,26 @@ Where `mkPrebuilt` and `mkFromSource` are defined as `let` bindings in the same
62
62
1.`mkdir packages/$0`
63
63
2. Create `data.json` with `_meta` (default version, releases URL) and the version entry
64
64
3. Create `default.nix` following the chosen pattern
65
-
4. Compute hashes:
66
-
- Prebuilt: `nix-prefetch-url --type sha256 --unpack <url>` then `nix hash convert --hash-algo sha256 --to sri <hash>`
67
-
-**Important**: `nix-prefetch-url` hashes often differ from what nix uses at build time. Set the hash, attempt a build, and use the correct hash from the error if it mismatches.
68
-
- Source (Go): set `vendorHash` to `""`, build, use hash from error
69
-
- Source (Rust): set `cargoHash` to `""`, build, use hash from error
65
+
4. Compute hashes — match the prefetch tool to the Nix fetcher:
66
+
67
+
**`fetchurl`** (prebuilt binaries — .tar.gz, .zip, single files):
68
+
`fetchurl` hashes the raw downloaded file. The builder's `unpackPhase` extracts it later.
69
+
```bash
70
+
nix-prefetch-url --type sha256 <url>
71
+
nix hash convert --hash-algo sha256 --to sri <hash>
72
+
```
73
+
Do NOT use `--unpack` — that hashes the extracted content, which is wrong for `fetchurl`.
74
+
75
+
**`fetchFromGitHub`** (source builds from GitHub):
76
+
`fetchFromGitHub` internally uses `fetchzip`, which unpacks and strips the top-level directory. The hash is of the unpacked content.
nix hash convert --hash-algo sha256 --to sri <hash>
60
62
```
61
63
64
+
`fetchurl` downloads the file as-is; the builder's `unpackPhase` extracts it. `fetchFromGitHub` unpacks and strips the top-level directory before hashing. Using the wrong prefetch mode produces a hash mismatch at build time.
0 commit comments