Skip to content
This repository has been archived by the owner on Oct 15, 2022. It is now read-only.

Feature Request: Allow nix-shell caching to be used independently of file watching #167

Closed
duog opened this issue Oct 8, 2019 · 3 comments
Labels
feature request Request for new functionality more data needed Some party needs to provide more information user-facing Improvement that increases user experience
Projects

Comments

@duog
Copy link

duog commented Oct 8, 2019

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.

@Profpatsch
Copy link
Collaborator

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).

@Profpatsch Profpatsch added feature request Request for new functionality more data needed Some party needs to provide more information user-facing Improvement that increases user experience labels Oct 8, 2019
@Profpatsch Profpatsch added this to To do in lorri via automation Oct 8, 2019
@Profpatsch
Copy link
Collaborator

There’s lorri shell now, which essentially does what you requested.

lorri automation moved this from To do to Done Mar 3, 2020
@olebedev
Copy link

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.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
feature request Request for new functionality more data needed Some party needs to provide more information user-facing Improvement that increases user experience
Projects
lorri
  
Done
Development

No branches or pull requests

3 participants