- Rust 89.6%
- Nix 10.4%
| src | More efficient topo sort + Djikstra-like mtime propragation algo | |
| Cargo.lock | Initial commit | |
| Cargo.toml | Initial commit | |
| flake.lock | Flakeify | |
| flake.nix | Flakeify | |
| LICENSE.md | Add LICENSE.md (GPLv3) | |
| package.nix | Add meta.mainProgram | |
| README.md | Add acknowledgements | |
nix-binary-cache-gc
Tool for garbage-collecting old derivations from Nix binary caches.
Usage
$ nix run git+https://codeberg.org/cyclopentane/nix-binary-cache-gc -- --delete-older-than 7d /path/to/binary-cache
Available units are s (seconds), m (minutes), h (hours), d (days), y (years = 365 days).
But don't we already have nix-collect-garbage?
Yes, but that's for Nix stores, and not for Nix binary caches. A Nix store is a
directory like /nix/ containing the subdirectories store, var. If you
want to share your store with someone else, the go-to solution is to use
nix-serve, which spins up an HTTP
server providing binary cache endpoints like /nix-cache-info,
/<hash>.narinfo, and so on.
However, there's another way: If you nix copy --to file///... your derivations somewhere, it will create a directory structure like this:
$ tree example_cache
example_cache
├── 7s4kcldwr4lq5ryg01yyy05zhb3vfc8d.narinfo
├── 85ab8kw0rb0h8d5s2nfp4dig24giq3mx.narinfo
├── log
├── m2047a1xwgblgkrnbxz0yilkaqfrbf2b.narinfo
├── nar
│ ├── 015k427rhdd5zl2fv6ld00nak9x028j94h0hzypry7bgcmsmxzjg.nar.xz
│ ├── 05wlgdfa54n8fgyjscnr0r8bafmmcmc94h4xqwbdxibi9f0sxaj5.nar.xz
│ ├── 0incw0bg5gx0glrkyif4wpsfscanbakpkap3j5bz1vgb1v5q8aa5.nar.xz
│ ├── 1aq2hgy8s754xal8l2f9x4szrqvnj253wdbh40laqpxqv63n759l.nar.xz
│ ├── 1jy4xxwvkv184mqm2awr7d5xihbaggrcjzxvqjiwva6i8axm11gn.nar.xz
│ ├── 1yacv71g68dhknaz3q68jjhgxapi2g824wqapf5daig2i5fzyr12.nar.xz
│ └── 1zl18aaphixms8lnm2fnl0pgz88spxlrs0svbzdp1m5v5zpvmcb7.nar.xz
├── nix-cache-info
├── nj19yxkqf0iqjqn4x6dbglsvqk5bgsbs.narinfo
├── realisations
├── rmy663w9p7xb202rcln4jjzmvivznmz8.narinfo
├── y2xxdhhjy2l5mgpm3d0rw2wxmpd61my4.narinfo
└── y4qpcibkj767szhjb58i2sidmz8m24hb.narinfo
You can then point a web server to this directory, and it'll serve the static binary cache. The advantage is that the NAR files will be compressed beforehand, which considerably speeds up the download. Unfortunately, afaik, there was no tool to properly garbage-collect these binary caches, so I wrote nix-binary-cache-gc.
Acknowledgements
Shoutout to tvix/snix for the cool crates.
License
This program is licensed under the GPLv3. See LICENSE.md for details.