Nix packages for third-party projects that don't ship their own flakes
1.6 kB
56 lines
1# agentic
2
3Nix packages for third-party tools that don't ship their own flakes.
4
5## Layout
6
7```
8flake.nix # flake entrypoint: exposes packages.* and apps.*
9flake.lock
10packages/
11 vit/ # one directory per package (callPackage style)
12 default.nix
13 package-lock.json # only when we need a fixed/regenerated lock
14```
15
16Add a new package by creating `packages/<name>/default.nix` and wiring it in
17`flake.nix` via `pkgs.callPackage ./packages/<name> { }`.
18
19## Packages
20
21| Attr | Upstream | Install (non-Nix) |
22|------|----------|-------------------|
23| `vit` | [solpbc/vit](https://github.com/solpbc/vit) | `npm install -g vit` |
24
25## Usage
26
27```bash
28# build
29nix build .#vit
30
31# run without installing
32nix run .#vit -- --help
33
34# install into your profile
35nix profile install .#vit
36```
37
38## Updating `vit`
39
401. Bump `version` / `rev` in `packages/vit/default.nix`.
412. Prefetch the new source hash:
42 ```bash
43 nix-prefetch-url --unpack "https://github.com/solpbc/vit/archive/refs/tags/vX.Y.Z.tar.gz"
44 nix hash convert --hash-algo sha256 --to sri <base32>
45 ```
463. Regenerate a lockfile with resolved URLs (upstream's is often missing them):
47 ```bash
48 tmp=$(mktemp -d) && cd "$tmp"
49 curl -sL "https://github.com/solpbc/vit/archive/refs/tags/vX.Y.Z.tar.gz" | tar -xz
50 cd vit-X.Y.Z
51 rm -f package-lock.json bun.lock
52 npm install --package-lock-only --ignore-scripts
53 cp package-lock.json /path/to/this/repo/packages/vit/package-lock.json
54 ```
554. Set `npmDepsHash = lib.fakeHash;`, run `nix build .#vit`, paste the hash
56 nix prints as `got:`, rebuild.