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

stdlib: add direnv_leaf_dir function #1046

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

offbyone
Copy link

@offbyone offbyone commented Jan 8, 2023

The purpose here is so that .envrc files that are invoked via
source_up can make use of the location of the outermost (leaf?)
.envrc, specifically its location.

For example, I am using this in a synced folder's top level .envrc:

db_root=$(realpath --relative-to "$HOME/Dropbox" "$(direnv_leaf_dir)")
if [[ $db_root == "." ]]; then
    db_root=Dropbox
fi
direnv_layout_dir="$HOME/.local/var/direnv/$db_root"

This lets me move my .direnv directories out of the sync, because the sync
directories are platform-specific but my Dropbox gets used on different CPU
architectures and OSs.

Docs

I didn't add stdlib docs because I didn't see the direnv_layout_dir function documented there either. I'm happy to add both.

Changelog

Same as with the docs; I can add this to the changelog, just tell me how you want it formatted and I'll update the PR.

Testing

I did not see any obvious place to add tests for the stdlib functions. If there is one, I'll happily add some.

The purpose here is so that .envrc files that are invoked via
`source_up` can make use of the location of the outermost (leaf?)
.envrc, specifically its location.
@offbyone
Copy link
Author

Would someone mind reviewing this?

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

Successfully merging this pull request may close these issues.

None yet

1 participant