Skip to content
Your project's nix-env
Branch: master
Clone or download
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.github
direnv direnv: fix fish init Mar 28, 2019
example Typo ? Apr 4, 2019
nix bogus nixpkgs: echo -n -> printf Apr 3, 2019
src shell: drop threads instead of joining, otherwise exit waits forever Apr 9, 2019
.envrc .envrc: Add lorri to PATH as soon as it’s built Apr 4, 2019
.gitignore .gitignore: add /.cargo and comment a bit Apr 4, 2019
.travis.yml travis-ci: init Apr 3, 2019
.travis.yml.nix travis-ci: init Apr 3, 2019
Cargo.lock Cargo.toml: add proptest Mar 26, 2019
Cargo.toml
LICENSE lorri: make open source Mar 21, 2019
README.md README: Document how to fix unexpected reevaluations Apr 10, 2019
build.rs lorri: make open source Mar 21, 2019
default.nix nix/nixpkgs.nix: default `enableMozillaOverlay` to `false`. Mar 29, 2019
release.nix
shell.nix shell.nix: Set RUST_SRC_PATH Apr 10, 2019

README.md

lorri

https://github.com/target/lorri

built with nix

lorri is a nix-shell replacement for project development. lorri is based around fast direnv integration for robust CLI and editor integration.

The project is about experimenting with and improving the developer's experience with Nix. A particular focus is managing your project's external dependencies, editor integration, and quick feedback.

lorri supports Linux and macOS.

Tutorial

You can find the lorri tutorial in the ./example directory. After following this tutorial, you will have a working setup of lorri, direnv, and working basic editor integration into Emacs.

Support & Questions

Please use the issue tracker for any problems or bugs you encounter. We are on #lorri on freenode (Webchat), though we might not be responsive at all times.

How To Help

All development on lorri happens on the Github repository, in the open. You can propose a change in an issue, then create a pull request after some discussion. Some issues are marked with the “good first issue” label, those are a good place to start. Just remember to leave a comment when you start working on something.

Install

Install direnv

You will need direnv v2.19.2 or later.

On NixOS, we have a simple service for installing and enabling the needed direnv version at ./direnv/nixos.nix. Download this file and add imports = [ ./direnv.nix ]; to your system's configuration.nix.

For Nix on Linux or macOS, you can install the needed version of direnv with:

$ curl -o direnv.nix -L https://github.com/target/lorri/raw/master/direnv/nix.nix
$ nix-env -if ./direnv.nix

then enable it according to direnv's setup instructions.

Installing lorri

Install with nix-env:

$ git clone -b rolling-release https://github.com/target/lorri.git
$ cd lorri
$ nix-env -if .

Usage

Create a file named .envrc in your project's root with the contents:

eval "$(lorri direnv)"

Then, run lorri watch. The first time you run lorri watch on a project, wait for it to print Completed before continuing. Leave this terminal open.

In a new terminal:

  1. enter the project directory
  2. run direnv allow
  3. watch as direnv loads the environment

The lorri watch process will continue monitoring and evaluating the Nix expressions, and direnv will automatically reload the environment as it changes. If you close lorri watch, direnv will still load the cached environment when you enter the directory, but the environment will not reload.

Debugging

Set these environment variables when debugging:

RUST_LOG=lorri=debug RUST_BACKTRACE=1 lorri watch

lorri reevaluates more than expected

lorri sometimes recursively watches a directory that the user did not expect. This can happen for a number of reasons:

  1. When using a local checkout instead of a channel for nixpkgs, lorri watches that directory recursively, and will trigger on any file change.
  2. When specifying src via a path, (like the much-used src = ./.;) lorri watches that path recursively (see https://github.com/target/lorri/issues/6 for details). To get around this, use a builtins.filterSource-based function to filter src, e.g., use nix-gitignore: src = pkgs.nix-gitignore.gitignoreSource [] ./., or one of the functions in nixpkgs/lib/sources.nix
  3. When using a construct like import ./. to import a default.nix file, lorri watches the current directory recursively. To get around it, use import ./default.nix.

Upgrading

Upgrading lorri is easy with the lorri self-upgrade command.

By default, the upgrade command will upgrade from the rolling-release branch.

Other upgrade options are available, including upgrading from a local clone. See lorri self-upgrade --help for more details.

Evaluator + watch design

The evaluator should eagerly reevaluate the Nix expressions as soon as anything material to their output changes. This takes place in a few stages.

Initial evaluation

builder::run() instantiates (and builds) the Nix expression with nix-build -vv. The evaluator prints each imported Nix file, and each copied source file. builder::run() parses the log and notes each of these paths out as an "input" path.

Each input path is the absolute path which Nix examined.

Each input path is then passed to PathReduction which examines each path referenced, and reduces it to a minimum set of paths with the following rules:

  1. Discard any store paths which isn't a symlink to outside the store: they are immutable.
  2. Replace any store path which is a symlink to outside the store to the destination of the symlink.
  3. Replace a reference to a Nix Channel with the updateable symlink root of the channel. Concretely, replace the path /nix/var/nix/profiles/per-user/root/channels/nixos/default.nix with /nix/var/nix/profiles/per-user/root/ to watch for the channels symlink to change.

Initial testing collapses over 2,000 paths to just five.

Loop

Each identified path is watched for changes with inotify (Linux) or fsevent (macOS). If the watched path is a directory, all of its sub-directories are also watched for changes.

Each new batch of change notifications triggers a fresh evaluation. Newly discovered paths are added to the watch list.

Garbage Collection Roots

lorri creates an indirect garbage collection root for each .drv in $XDG_CACHE_HOME/lorri (~/.cache/lorri/ by default) each time it evaluates your project.

License & Copyright

Copyright 2019 Target License: Apache 2.0 (see LICENSE file)


ASCII Art
################################################################
################################################################
################################################################
################################################################
################################################################
################################################################
#################( )############################################
################################################################
################################################################
################################################################
################################################################
################################################################
################################################################
################################################################
################################################################
################################################################
################################################################
################################################################
################################################################
################################################################
################################################################
################################################################
################################################################

(Nix as observed by LORRI on 2015-07-13)

You can’t perform that action at this time.