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

Allowing custom configuration to $HOME/.config/direnv/direnvrc #484

Closed
vendion opened this issue Apr 11, 2024 · 4 comments
Closed

Allowing custom configuration to $HOME/.config/direnv/direnvrc #484

vendion opened this issue Apr 11, 2024 · 4 comments

Comments

@vendion
Copy link

vendion commented Apr 11, 2024

I am wanting to setup a few recipes/layouts that are in the direnv wiki such as per project postgres data and daemonize, it seems that putting this in $HOME/.config/direnv/direnvrc makes sense, but it semes that file already gets created and sources in data needed for nix-direnv from the nix store.

Failing that I tried to add the custom functions to my projects .envrc file, but it doesn't seems to work as I can't call the functions. Even if I could I would have to copy these snippits to all .envrc files rather than being able to just define it once.

@bbenne10
Copy link
Contributor

  1. functions and aliases are unsupported as "exportables" by direnv - they're not shell portable and may contain arbitrary shell code (which can't be automatically translated with out massive effort), so...no - you can't do that (and it isn't our fault). I don't know how one is expected to use daemonize in particular in a "raw" direnv use case, but you may also explore shellHook to get that working (The postgres snippet is clever and should probably work fine).
  2. We don't put anything in ~/.config/direnv/direnvrc. That's (probably) home-manager's fault. Use programs.direnv.direnvrcExtra on NixOS or programs.direnv.stdlib if using home-manager to put extra things into that file.

@bbenne10
Copy link
Contributor

Upon re-reading the daemonize code, I suspect the expectation is that this function is to be called inside your .envrc. Direnv does not support using these functions "interactively" (after the direnv run has completed). You'd need to make the daemonize function available to your direnv shell (either in .envrc or ~/.config/direnv/direnvrc) and then call daemonize foo_groobler in your .envrc.

That being said: I don't think that's a good idea - you can very easily end up with abandoned processes from old projects hanging around after you cd away. If you want this, maybe look at devenv?

@vendion
Copy link
Author

vendion commented Apr 11, 2024 via email

@bbenne10
Copy link
Contributor

shellHook is not for long running processes. You will run into issues there. I expected the daemonize call to work, but I'm disinclined to chase down why it doesn't. Again: Have a look at devenv. This workflow is what it is designed for. You're reinventing the wheel (and frankly doing so poorly and with less consideration than what Domen has put into devenv).

(OR use sqlite for development and maria for deployment, but that's harder and I know it's difficult to switch once you have the approach solidified)

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

2 participants