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 ofnix-shell
withcached-nix-shell
. This is done by adding our symlink namednix-shell
to the$PATH
.
IN_CACHED_NIX_SHELL
: Is set to1
.
The cache is stored in $XDG_CACHE_HOME/cached-nix-shell
,
defaults to ~/.cache/cached-nix-shell
.
-
Ambient environment variables: 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. -
Relative paths: 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 multiplecached-nix-shell
invocations from different directories to reuse the same cache entry. -
Network access: Accessing network resources (e.g. via
builtins.fetchurl
) is not considered in cache invalidation logic. Consequently,tarball-ttl
option (seenix-conf
(5)) is not respected. -
Bash variables and functions: Only exported environment variables are preserved, but not global shell variables and functions set by
setup.sh
. -
Shell hooks: 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)