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

possible way to expose devshell.toml's path? #95

Open
nrdxp opened this issue Feb 16, 2021 · 4 comments · May be fixed by #127
Open

possible way to expose devshell.toml's path? #95

nrdxp opened this issue Feb 16, 2021 · 4 comments · May be fixed by #127

Comments

@nrdxp
Copy link
Contributor

nrdxp commented Feb 16, 2021

Issue

I wanted to add a feature to the git.hooks module to allow specifying a path to a hook. I got all the logic wired in and working, but the issue is that I have to specify a full path 😞

nix doesn't seem to have the ability to convert a string with a relative path to a full path, and since toml doesn't have a native notion of a path, I'm kinda stuck. builtins.toPath is depricated and doesn't really do anything.

The only work around I can think of is if we define a variable somewhere containing the current devshell.toml's path. Then I can specify a path relative to the location of the devshell.toml to the git.hook source file. I'm sure this will come in handy for similar reasons in other modules.

I guess the alternative would be to leave it as a nix only option, but setting from toml would be ideal.

Context

my devshell.toml is not at the root of the project, otherwise I probably would have thought to use DEVSHELL_ROOT

@zimbatm
Copy link
Member

zimbatm commented Feb 17, 2021

Do you want the file to be added to the /nix/store or just point to its location in the repo?

Where is that path being used?

@nrdxp
Copy link
Contributor Author

nrdxp commented Feb 17, 2021

Whatever you believe would be the best solution, if indeed we find a good solution

Here is a draft pr so you can see the implementation. #96

The directory containting the devshell.toml. The pre-commit file I would like to specify is also there. The nix specific parts are in the default.nix.

@blaggacao
Copy link
Contributor

A couple of days ago, I also had a thought on relative-to-toml file paths in the context of wanting to load per-repo devshell modules (without resorting to .nix)

@zimbatm
Copy link
Member

zimbatm commented Feb 28, 2021

The module has a _file attribute that exposes its location. Ideally, it would be possible to set the type of attribute to types.path and have it be resolved if it starts with ./. @infinisil do you know if that would be possible?

Otherwise, we will have to revert to something less ideal like a post-processing step. Or install config.resolveRoot = builtins.dirOf file when the user uses importTOML

blaggacao added a commit to blaggacao/devshell that referenced this issue Jun 21, 2021
E.g. useful for toml strings that should represent a relative
file to the toml file.

fixes: numtide#95
@blaggacao blaggacao linked a pull request Jun 21, 2021 that will close this issue
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

Successfully merging a pull request may close this issue.

3 participants