cached-nix-shell
cached-nix-shell copied to clipboard
Prevent nix-collect-garbage from invalidating cache
Hi everyone,
First thank you for this project. It completely removes the slowdown seen with nix-shell scripts so I'm relying on it a lot these days.
One issue I'm experiencing however is that the cache gets invalidated by nix-collect-garbage.
To avoid this I'm using nix-instantiate inside the script to pin (some of) the packages used.
A typical script looks like:
#!/usr/bin/env cached-nix-shell
#!nix-shell -i bash -p bash packageA packageB
nix-instantiate '<nixpkgs>' -A bash -A packageA -A packageB --indirect --add-root "$HOME/nix/pins/packageAB.drv"
(...)
However, this has the downside that for some packages nix-instantiate also takes some time to execute which removes some of the benefit of using cached-nix-shell.
Is there any way to pin the same packages that were used by the shell without this nix-instantiate hack?
Thanks