-
Notifications
You must be signed in to change notification settings - Fork 69
Does lorri work with nix flakes? #460
Comments
I don't think lorri supports flakes atm, but you can use flake-compat to create a (import (fetchTarball https://github.com/edolstra/flake-compat/archive/master.tar.gz) {
src = ./.;
}).shellNix.default |
Flakes are not a stable feature at the moment, they are not even mentioned in the nix manual. We could start adding support for them, but afaik the format changes every few weeks at the moment, I don’t see the big selling point of interacting with experimental features. |
I think it would be a good time to start thinking about flakes for lorri − even without implementing it now − as the fact that it and the new cli are both experimental atm means that it's possible to upstream some lorri-specific logic into Nix itself (which will be much more painful once it gets stable, if only because lorri will have to be backwards compatible with the Nix-with-flakes-but-without-the-changes-that-make-it-easier-to-implement). I'm not super-familiar with the internals of lorri, but my understanding of how lorri works is that it does essentially three things on the Nix side:
On the Nix side,
If the above is true, it means that supporting flakes in lorri would be reasonably simple, provided we make a couple of changes to Nix before it reaches a stable version. At a very high level, Lorri would essentially look like: LORRI_ROOT=~/.cache/lorri/roots/foobar
# Dump the environment for the derivation, adding a gc root at $LORRI_ROOT and saving the log into nix-exec.log
LORRI_ENV=$(nix print-dev-env --add-root $LORRI_ROOT --log-format json 2> nix-exec.log)
# Get the list of the files read by Nix during the evaluation from the log
READ_FILES=$(cat nix-exec.log | jq 'some magic to extract all the read files from the log')
# Rebuild everything if one of these change
inotifywait --event modify $READ_FILES
exec "$0" "$@" @Profpatsch do I over-simplify stuff or does that look like a reasonable plan? |
As I read it, this proposal misses the mark. Lorri does a real That said, the core of the suggestion seems good. If the I'm personally increasingly interested in Flakes, and I'd love to be able to use them with Lorri. Much as the caching provided there is valuable, the operations being cached aren't free and backgrounding them is its own benefit. |
Does it? My understanding is that it instantiates
I can't say about the broad roadmap, but unless there's a hidden tradeoff that I can't see, the logging bit at least is definitely something that can be added. |
@regnat do you have a good and/or complete description of the semantics of As you mentioned, the lorri |
Not much more than Nix's help message itself (or skimming through the source code) $ nix print-dev-env --help
[...]
Summary: print shell code that can be sourced by bash to reproduce the build environment of a derivation.
[...]
Examples:
To apply the build environment of GNU hello to the current shell:
$ . <(nix print-dev-env nixpkgs#hello)
[...]
Do you mean the logging of Something that |
If you run a flake enabled nix by default, the following { system ? builtins.currentSystem }:
(builtins.getFlake (toString ./.)).devShell.${system} |
If @FlorianFranzen's approach works, would it be possible to just do that as a temporary measure while a more principled approach to flakes is set up? Like, if there's a flake.nix but no shell.nix, treat it as if shell.nix contained a compatibility shim. |
@FlorianFranzen approach seems to work for me so I've raised a PR (to the right repo) so that it's suggested if a shell.nix isn't found but a flake.nix is. |
Hello ! Any updates on the support of nix flakes ? |
Based on the instructions here and here, direnv is able to support flakes with a
use_flake()
function. However, when I tried this in a project with aflake.nix
andflake.lock
lorri complained about the lack of ashell.nix
file.Does lorri support nix flakes? If so, how can it be used? If not, is support planned?
The text was updated successfully, but these errors were encountered: