Code Monkey home page Code Monkey logo

sorri's Introduction

SORRI

Just Add Water direnv support for the nix-shell.

Install

Add sorri to your project:

$ curl https://raw.githubusercontent.com/nmattia/sorri/master/sorri --create-dirs --output nix/sorri

Update your .envrc to use sorri:

$ echo ". nix/sorri $(basename $PWD)" > .envrc

You're all set!

The sorri helper

The sorri helper bootstraps projects for you. Install it with:

nix-env -if https://github.com/nmattia/sorri/tarball/master

... and from then on use:

$ sorri init

inside your project.

How It Works

This is a simple, lightweight implementation of Tweag's lorri

sorri reuses lorri's tricks for figuring out the files to track for changes, but uses direnv's own mechanism for actually tracking those files. sorri uses a local cache at '~/.cache/sorri//v/'. Each entry is a directory containing two files:

  ~/.cache/sorri/niv/v1/
  └── 0716a121e4f986f9f8cf11f7c579d332
      ├── link -> /nix/store/jfzkisfgmv3qgpzz3i8nai12y1cry77v-nix-shell
      └── manifest

link is the result of a previous evaluation. manifest is used to find that result of a previous evaluation. The directory name (0716a121e4f986f9f8cf11f7c579d332 above) is the hash of the manifest.

link is a symlink to a shell script that sets a shell's variables.

  cat ~/.cache/sorri/niv/v1/0716a121e4f986f9f8cf11f7c579d332/link
  declare -x AR_x86_64_apple_darwin="/nix/store/amsm28x2hnsgp8c0nm4glkjc2gw2l9kw-cctools-binutils-darwin-927.0.2/bin/ar"
  declare -x BZ2_LIB_DIR="/nix/store/7yikqcm4v4b57xv3cqknhdnf0p1aakxp-bzip2-1.0.6.0.1/lib"
  declare -x BZ2_STATIC="1"
  declare -x CARGO_BUILD_TARGET="x86_64-apple-darwin"
  declare -x CARGO_TARGET_WASM32_UNKNOWN_UNKNOWN_LINKER="/nix/store/swiic36rl7njy6bfll5z0afl42c9q4s5-lld-9.0.1/bin/lld"

manifest is a list of files used for an evaluation alongside their checksums:

  $ cat ~/.cache/sorri/niv/v1/0716a121e4f986f9f8cf11f7c579d332/manifest
  /Users/nicolas/niv/shell.nix:029451f2a9bee59f4ce002bdbdf20554
  /Users/nicolas/niv/nix/default.nix:7ff8c9138044fc7e31f1d4ed2bf1c0ba
  /Users/nicolas/niv/nix/overlays/buf/default.nix:c4a24e0bba0178b73f0211d0f26147e6
  ...

sorri first checks the existing cache entries (sorri/niv/v1/0716..., etc); if it finds a cache entry with a manifest where all the manifest entries (nix/default.nix:7ff...) match local files, the link is loaded; if no manifest matches, a new entry is created and loaded.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.