Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Instant startup time for nix-shell

License

Unlicense, MIT licenses found

Licenses found

Unlicense
UNLICENSE
MIT
LICENSE.MIT
NotificationsYou must be signed in to change notification settings

xzfc/cached-nix-shell

Repository files navigation

Build StatusLicenseNixpkgs unstable packageMan page

cached-nix-shell is a caching layer fornix-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 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

Performance

$ 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 total

Caching and cache invalidation

cached-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.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 bycached-nix-shell and may lead to staled cache:

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

Related

About

Instant startup time for nix-shell

Topics

Resources

License

Unlicense, MIT licenses found

Licenses found

Unlicense
UNLICENSE
MIT
LICENSE.MIT

Stars

Watchers

Forks

Contributors7


[8]ページ先頭

©2009-2025 Movatter.jp