Feature Request: Allow nix-shell caching to be used independently of file watching
duog opened this issue · comments
Hi,
thanks for this project, I'm finding it very useful.
I'm not entirely comfortable having lorri do builds in the background, I'd rather control when the builds happen. But I very much want to leverage your intelligent, correct shell caching behaviour.
I'd like to be able to do:
$ lorri shell
and have it be cache the result to ./.lorri/env
or similar, in the same way the direnv use_nix
functions do, but with your cache invalidation logic.
Similarly, I'd like to be able to use something like:
#! /usr/bin/env lorri
#! lorri shell -i bash ...
...
in scripts to get fast shells. I don't have a lot of insight into how the shebang gadget should look, I hope it's clear.
This seems like it might be a relatively straightforward extension to lorri. With your approval and guidance I'd be happy to take a stab at it.
I'm not entirely comfortable having lorri do builds in the background, I'd rather control when the builds happen. But I very much want to leverage your intelligent, correct shell caching behaviour.
We added lorri watch --once
in a recent commit on master, which should do what you want.
It’s not a top-level command because it’s not intended to be the primary use-case using lorri without the watchers, see the discussion in #123 (comment)
in scripts to get fast shells. I don't have a lot of insight into how the shebang gadget should look, I hope it's clear.
Shebang is a thing we thought about. The naive version can’t get any faster than nix-shell, because instantiation has to be done and that takes between a few hundred milliseconds and minutes, depending on the project.
However, it is certainly possible to do some workarounds, depending on what you want the semantics of your shebang to be.
e.g. if you want the “just give me any version, I don’t care” version, you can take a look at this: https://github.com/Profpatsch/dotfiles/blob/68230427d8b8e03422c4b668b29cb2f5f7a8feae/scripts/scripts/nix-cache-binary#L1
Another version of shebang behaviour would be “run the last successful build, but query the lorri daemon to build a new one in the background”. I don’t know how useful that is in practice. It might certainly lead to strange behaviors (because it’s hard to know what exactly you are running).
There’s lorri shell
now, which essentially does what you requested.
There’s
lorri shell
now, which essentially does what you requested.
However, it seems like it doesn't support shebangs out of the box, no? That would be an amazing feature if lorri
could be used as a drop-in replacement for nix-shell
shebang.