- Notifications
You must be signed in to change notification settings - Fork16
Instant startup time for nix-shell
License
Unlicense, MIT licenses found
Licenses found
xzfc/cached-nix-shell
Folders and files
| Name | Name | Last commit message | Last commit date | |
|---|---|---|---|---|
Repository files navigation
cached-nix-shell is a caching layer fornix-shell featuring instant startup time on subsequent runs.
It supports NixOS and Linux.
Install the release version from Nixpkgs:
nix-env -iA nixpkgs.cached-nix-shell
Or, install the latest development version from GitHub:
nix-env -if https://github.com/xzfc/cached-nix-shell/tarball/master
Just replacenix-shell withcached-nix-shell in the shebang line:
#! /usr/bin/env cached-nix-shell#! nix-shell -i python3 -p pythonprint("Hello, World!")
Alternatively, callcached-nix-shell directly:
$ cached-nix-shell ./hello.py$ cached-nix-shell -p python3 --run'python --version'Or use the--wrap option for programs that callnix-shell internally.
$ cached-nix-shell --wrap stack build
$ time ./hello.py # first run; no cache usedcached-nix-shell: updating cacheHello, World!./hello.py 0.33s user 0.06s system 91% cpu 0.435 total$ time ./hello.pyHello, World!./hello.py 0.02s user 0.01s system 97% cpu 0.029 totalcached-nix-shell stores environment variables set up bynix-shell and reuses them on subsequent runs.Ittraces which files are read bynix during an evaluation, and performs a proper cache invalidation if any of the used files are changed.The cache is stored in~/.cache/cached-nix-shell/.
The following situations are covered:
builtins.readFileis usedbuiltins.readDiris usedimport ./file.nixis used- updating
/etc/nix/nix.confor~/.config/nix/nix.conf - updating nix channels
- updating
$NIX_PATHenvironment variable
The following situations aren't handled bycached-nix-shell and may lead to staled cache:
builtins.fetchurlor other network builtins are used (e.g. innixpkgs-mozilla)
https://discourse.nixos.org/t/speeding-up-nix-shell-shebang/4048
There are related projects focused on using
nix-shellfor project developing:- direnv withuse_nix
- Cached and Persistent Nix shell with direnv integration
- lorri, a
nix-shellreplacement for project development - nix-develop, universal build tool featuring cached
nd shellcommand
About
Instant startup time for nix-shell
Topics
Resources
License
Unlicense, MIT licenses found
Licenses found
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Uh oh!
There was an error while loading.Please reload this page.
Contributors7
Uh oh!
There was an error while loading.Please reload this page.