All Projects → xzfc → Cached Nix Shell

xzfc / Cached Nix Shell

Licence: other
Instant startup time for nix-shell

Programming Languages

rust
11053 projects

Labels

Projects that are alternatives of or similar to Cached Nix Shell

B
Collection of configuration stuff.
Stars: ✭ 80 (-22.33%)
Mutual labels:  nix
Upcast
Abandonware
Stars: ✭ 91 (-11.65%)
Mutual labels:  nix
Hydra Tutorial
Sample configuration files for setting up your own Hydra continuous integration server.
Stars: ✭ 95 (-7.77%)
Mutual labels:  nix
Cachix Action
Build software only once and put it in a global cache
Stars: ✭ 85 (-17.48%)
Mutual labels:  nix
Rules nixpkgs
Rules for importing Nixpkgs packages into Bazel.
Stars: ✭ 88 (-14.56%)
Mutual labels:  nix
Pre Commit Hooks.nix
Seamless integration of https://pre-commit.com git hooks with Nix.
Stars: ✭ 92 (-10.68%)
Mutual labels:  nix
Terranix
terranix is a terraform.json generator with a nix-like feeling
Stars: ✭ 77 (-25.24%)
Mutual labels:  nix
Nix Linter
Linter for the Nix expression language
Stars: ✭ 100 (-2.91%)
Mutual labels:  nix
Bauer
An Emacs+Nix IDE
Stars: ✭ 89 (-13.59%)
Mutual labels:  nix
System
My system configuration
Stars: ✭ 94 (-8.74%)
Mutual labels:  nix
Nixos Configs
My NixOS configs
Stars: ✭ 86 (-16.5%)
Mutual labels:  nix
Vuizvui
Nix(OS) expressions used by the OpenLab and its members
Stars: ✭ 87 (-15.53%)
Mutual labels:  nix
Ghc.nix
Nix (shell) expression for working on GHC
Stars: ✭ 94 (-8.74%)
Mutual labels:  nix
Dhall Nix
This repository has moved to https://github.com/dhall-lang/dhall-haskell/tree/master/dhall-nix
Stars: ✭ 82 (-20.39%)
Mutual labels:  nix
Nixcloud Webservices
This nixpkgs extension, called nixcloud-webservices, focuses on ease of deployment of web-related technologies.
Stars: ✭ 98 (-4.85%)
Mutual labels:  nix
Nix Tools
Translate Cabals Generic Package Description to a Nix expression
Stars: ✭ 78 (-24.27%)
Mutual labels:  nix
Nix Processmgmt
Experimental Nix-based process management framework
Stars: ✭ 92 (-10.68%)
Mutual labels:  nix
Nixos Config
Mirror of https://code.balsoft.ru/balsoft/nixos-config
Stars: ✭ 100 (-2.91%)
Mutual labels:  nix
Styx
Static site generator in Nix expression language.
Stars: ✭ 99 (-3.88%)
Mutual labels:  nix
Stack2nix
Generate nix expressions for Haskell projects
Stars: ✭ 93 (-9.71%)
Mutual labels:  nix

cached-nix-shell

Build Status License Nixpkgs unstable package Man page

cached-nix-shell is a caching layer for nix-shell featuring instant startup time on subsequent runs.

It supports NixOS and Linux.

Installation

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

Usage

Just replace nix-shell with cached-nix-shell in the shebang line:

#! /usr/bin/env cached-nix-shell
#! nix-shell -i python3 -p python
print("Hello, World!")

Alternatively, call cached-nix-shell directly:

$ cached-nix-shell ./hello.py
$ cached-nix-shell -p python3 --run 'python --version'

Or use the --wrap option for programs that call nix-shell internally.

$ cached-nix-shell --wrap stack build

Performance

$ time ./hello.py # first run; no cache used
cached-nix-shell: updating cache
Hello, World!
./hello.py  0.33s user 0.06s system 91% cpu 0.435 total
$ time ./hello.py
Hello, World!
./hello.py  0.02s user 0.01s system 97% cpu 0.029 total

Caching and cache invalidation

cached-nix-shell stores environment variables set up by nix-shell and reuses them on subsequent runs. It traces which files are read by nix 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.readFile is used
  • builtins.readDir is used
  • import ./file.nix is used
  • updating /etc/nix/nix.conf or ~/.config/nix/nix.conf
  • updating nix channels
  • updating $NIX_PATH environment variable

The following situations aren't handled by cached-nix-shell and may lead to staled cache:

  • builtins.fetchurl or other network builtins are used (e.g. in nixpkgs-mozilla)

Related

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].