Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Installation as ~/.config/direnv/lib/sorri.sh #2

Open
shajra opened this issue Oct 8, 2020 · 5 comments
Open

Installation as ~/.config/direnv/lib/sorri.sh #2

shajra opened this issue Oct 8, 2020 · 5 comments

Comments

@shajra
Copy link

shajra commented Oct 8, 2020

I think I have a preference of installing a tool like sorri globally as a library. I think you're file is very close. I just need to crop out the last call to sorri_main.

So it's not like I'm blocked or anything, this is easy enough to do.

But if you think it's a good idea, I wonder if we can make it more of an official way to install sorri as a courtesy to new users.

Would you be opposed to taking out the last call to sorri_main? And then just allowing the invocation to be done explicitly in the user's .envrc file? On that note, "sorri_main" seems like a bit of an internal name. Could we just make it "sorri" instead?

I think the instructions on the README would then be:

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

Is that too bad? Any suggested alternative?

@nmattia
Copy link
Owner

nmattia commented Oct 8, 2020

Hehe yes indeed! I wrapped sorri in functions for that purpose; I haven't documented the setup yet because I want to try it out on my machine first. I had to tweak direnv a bit first.

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

That looks nice! I was really trying to keep it to one line though. I was thinking sorri could figure out if it's being loaded as an .envrc or as an stdlib function. direnv could for instance set DIRENV_STDLIB while loading the stdlib; or maybe it's doing that already @zimbatm?

Bottom line: yes yes yes!

@shajra
Copy link
Author

shajra commented Oct 9, 2020

Okay, good to know you're already on this. It sounds like we're not that far off, and it also sounds like you don't really need anything like a PR from me. So I'll just wait a little bit and see if it lands soon.

I'm also fine if Direnv can set a variable and make the invocation site more streamlined.

@zimbatm
Copy link

zimbatm commented Oct 9, 2020

source_url

I'm going to make a new release of direnv today that includes this feature: direnv/direnv#562

Basically, it allows you to source files from the Internet. Eg:

source_url "https://raw.githubusercontent.com/nmattia/sorri/bff9e44734b19d5c65534c9bfd10bdf3be90b623/sorri" "sha256-CMbjOcSXWtTqSW0jKBPWWPBMBiOvJsh2vnFJoQJ6yFM="

Right now, this doesn't seem to work with sorri as it outputs "OH NOO", but the mechanism is there and sorri just needs to be fixed/changed to support that.

.envrc vs source_env

Direnv sets DIRENV_IN_ENVRC=1 in the context of a .envrc which can be used to detect if a script is being executed inside or outside of the direnv evaluation. This environment variable is set both in the context of an .envrc evaluation, and further sources.

A way to distinguish between the .envrc and a source_env script is to test [[ ${DIRENV_DIR#-} == "$PWD" ]]

@nmattia
Copy link
Owner

nmattia commented Oct 9, 2020

Ah, that's great timing! DIRENV_IN_ENVRC would have been enough, but I love the idea of source_url. Will have a look at the doc/code.

@zimbatm
Copy link

zimbatm commented Oct 10, 2020

that feature is now available in direnv 2.23.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants