-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Resolve //path
to flake root
#12070
Comments
I'm not entirely convinced that we need this. (Excuse my ignorance) It might be symptomatic of a lacking attrset-based structure, which doesn't scale well beyond a few function calls, because you're not benefiting from the implicit memoization that attrsets like the In my experience, relative references tend to be replaced by references not necessarily to
Lines 5 to 8 in 3f3feae
What should the behavior be for subflakes?
In my opinion, we should use content aware tools that do this kind of thing automatically. |
Implementing this as proposed would be a breaking change to the expression language, because it changes the interpretation of nix-repl> foo = { bar = true; }
nix-repl> { } //foo
{ bar = true; } It also makes the following ambiguous - either: nix-repl> { __functor = self: arg: arg + "/bar"; } //foo
//foo/bar or nix-repl> { __functor = self: arg: arg + "/bar"; } //foo
{ __functor = <...>; bar = true; } |
Thanks for your replies @roberth!
That's definitely a fair point I didn't consider very much so far. In general, my suggestion was very much tied to the one-flake structure.
Oopsie! I didn't consider this case as well. For me, that's definitely outweighing the benefits of such a shorthand. Considering the points you've made, if you wouldn't object to it, I'd close this issue then. |
No problem. I have to say I quite liked the idea at first, but it doesn't seem to be a great fit. |
Is your feature request related to a problem?
Users of flakes in repositories with somewhat-nested tree layouts often get into positions where they have to:
This is error-prone. For example, if
foo.nix
gets moved around, it's easy to add a../
too much, causing errors.Furthermore, this is very much not nice to look at.
Proposed solution
Resolve a path of form
//path
to the flake's root directory. If I have aflake.nix
in/home/me/my-project/flake.nix
, and the project layout is as follows:/home/me/my-project/foo/bar.nix
:"foo"
/home/me/my-project/some/deeply/nested/tree/package.nix
:import //foo/bar.nix
Evaluating
/home/me/my-project/some/deeply/nested/tree/package.nix
should return"foo"
.Alternative solutions
Passing
self
around should work, but having a short-hand path operation for this would be nice.Additional context
Checklist
Add 👍 to issues you find important.
The text was updated successfully, but these errors were encountered: