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

Diversion from nix with splices in paths #44

Closed
oppiliappan opened this issue Oct 28, 2021 · 3 comments · Fixed by #52
Closed

Diversion from nix with splices in paths #44

oppiliappan opened this issue Oct 28, 2021 · 3 comments · Fixed by #52
Assignees
Labels
bug Something isn't working
Milestone

Comments

@oppiliappan
Copy link
Contributor

Describe the bug

Splicing/antiquoting in paths results in a syntax error, whereas Nix permits templated paths.

Code Snippet to reproduce

let
  x = "abc";
in
  ./${x}

Expected behavior

The nix file is valid and should successfully evaluate to something like /home/np/abc.

@oppiliappan oppiliappan added the bug Something isn't working label Oct 28, 2021
@Ma27 Ma27 added this to the 0.10.0 milestone Oct 28, 2021
@Ma27
Copy link
Member

Ma27 commented Oct 28, 2021

Yup, that's a relatively new feature from the (not-yet released) Nix 2.4 :)

May take a few weeks until I have time for this, so if you want to file a patch, feel free :)

@oppiliappan
Copy link
Contributor Author

Yup, that's a relatively new feature from the (not-yet released) Nix 2.4 :)

Ah I see, that makes sense.

so if you want to file a patch, feel free :)

I can try 😅

@Ma27 Ma27 self-assigned this Nov 8, 2021
@Ma27
Copy link
Member

Ma27 commented Nov 9, 2021

FYI I'm actively working on this now.

Ma27 added a commit that referenced this issue Nov 10, 2021
Since Nix 2.4 it's possible to perform string interpolations within
paths:

    nix-repl> let a = "rnix"; in /home/ma27/Projects/${a}-parser
    /home/ma27/Projects/rnix-parser

Please note that the following expressions are not supported (by both
Nix and this patch):

* `NIX_PATH` imports, i.e. `<nixpkgs/${foo}>`
* Interpolations before the first slash, i.e. `foo${bar}/baz`.

The newly introduced token `NODE_PATH_WITH_INTERPOL` is only used for
these interpolated paths. Literal paths are still `TOKEN_PATH` inside
`NODE_LITERAL` for backwards compatibility.

Closes #44
@Ma27 Ma27 closed this as completed in #52 Nov 23, 2021
Ma27 added a commit that referenced this issue Dec 2, 2021
While working on #44 I had to split up the internal token-update
behavior a bit as we have to decide which node to use (and also which
behavior - depending on whether we have a "literal" path or a path with
an interpolation).

Unfortunately I wasn't careful enough with checking where trivia tokens
(i.e. `\n`, ` ` etc.) were placed.

This lead to situations such as

    TOKEN_WHITESPACE(" ") 37..38
    TOKEN_WHITESPACE(" ") 38..39
    NODE_LITERAL 39..44 {
      TOKEN_PATH("./bar") 39..44

where the second white-space should've been after the path `./bar`.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants