CACHED-NIX-SHELL(1)
π NAME π
okay bestie, welcome to cached-nix-shell(1) from the General Commands Manual β itβs literally instant startup time for nix-shell(1). no cap, thatβs the whole serve π
β¨
πΈ SYNOPSIS πΈ
the three moods are:
cached-nix-shell [options]...
cached-nix-shell shebang-script [args]...
cached-nix-shell --wrap cmd [args]...
π¦ DESCRIPTION π¦
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 ...). itβs giving βsame energy, way fasterβ ππ
β¨ OPTIONS β¨
cached-nix-shell supports the majority of nix-shell options, see the corresponding man page for the list. yes bestie, the classics are still there π«Ά
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--runexcept that the command is executed directly rather than as shell command. It should be slightly faster and more convenient to pass arguments. lowkey iconic β‘--wrap cmd [args]... (not in shebang, should be the first arg)β Run the command substituting every invocation ofnix-shellwithcached-nix-shell. This is done by adding our symlink namednix-shellto the$PATH. main character move fr fr π
π ENVIRONMENT VARIABLES π
IN_CACHED_NIX_SHELLβ Is set to1. thatβs it, thatβs the variable π
π FILES π
The cache is stored in $XDG_CACHE_HOME/cached-nix-shell, defaults to ~/.cache/cached-nix-shell. cozy little cache home π β¨
π LIMITATIONS π
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. so yes, keep the var, bestie π
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 multiple cached-nix-shell invocations from different directories to reuse the same cache entry. nuanced, but make sense π§
Network access
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. not the cache noticing the network, ngl π
Bash variables and functions
Only exported environment variables are preserved, but not global shell variables and functions set by setup.sh. exported only, periodt π«Ά
Shell hooks
Shell hooks are executed only once, during a cache evaluation. one time only, like a special guest appearance β¨
π HOMEPAGE π
https://github.com/xzfc/cached-nix-shell
Please report bugs and feature requests in the issue tracker. the issue tracker is the place, bestie π«‘π
π₯ SEE ALSO π₯
thatβs the whole iconic page from cached-nix-shell 0.1.6, dated January 1980 β mwah, slay, bye ππ
π
π¦ where this page comes from
- nixos 26.05: cached-nix-shell 0.1.6
- nixpkgs unstable: cached-nix-shell 0.1.6
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms