cached-nix-shell
- instant startup time for nix-shell(1)
cached-nix-shell
[options]...
cached-nix-shell
shebang-script [args]...
cached-nix-shell --wrap
cmd [args]...
cached-nix-shell
is a caching layer for nix-shell
featuring instant startup time on subsequent runs.
The design goal is to make a fast drop-in replacement for nix-shell
, including support of shebang scripts and non-interactive commands (i.e., nix-shell --run ...
).
cached-nix-shell
supports the majority of nix-shell
options,
see the corresponding man page for the list.
Additionally, the following new options are unique for cached-nix-shell
:
--exec
cmd [args]... (not in shebang)Command and arguments to be executed.
It is similar to --run
except that the command is executed directly rather than as shell command.
It should be slightly faster and more convenient to pass arguments.
--wrap
cmd [args]... (not in shebang, should be the first arg)Run the command substituting every invocation of nix-shell
with cached-nix-shell
.
This is done by adding our symlink named nix-shell
to the $PATH
.
IN_CACHED_NIX_SHELL
1
.The cache is stored in $XDG_CACHE_HOME/cached-nix-shell
,
defaults to ~/.cache/cached-nix-shell
.
It is necessary to pass --keep
var even without --pure
if the variable var is used inside a nix expression or a hook.
Note that updating the value of var would invalidate the cache.
When --expr
or --packages
option is given,
the cache is evaluated inside a separate empty directory,
preventing access to relative paths from within nix expressions.
Contrariwise, when a path to a shebang script or nix file is given,
the cache is evaluated in the directory containing that script or file.
This allows multiple cached-nix-shell
invocations
from different directories to reuse the same cache entry.
Accessing network resources (e.g. via builtins.fetchurl
) is not considered in cache invalidation logic.
Consequently, tarball-ttl
option (see nix-conf
(5)) is not respected.
Only exported environment variables are preserved,
but not global shell variables and functions set by setup.sh
.
Shell hooks are executed only once, during a cache evaluation.
https://github.com/xzfc/cached-nix-shell
Please report bugs and feature requests in the issue tracker.
nix-shell(1)