-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Description
Describe the bug
Path literals in the Nix language do not support ~
characters within the path (apart from the first character). However, such characters may occur in valid paths.
Steps To Reproduce
- Open
nix repl
- Enter
./foo~
- Observe
error: syntax error, unexpected invalid token, expecting end of file
.
Expected behavior
Nix accepts path literals containing ~
characters in other positions than the beginning as legal paths.
nix-env --version
output
nix (Nix) 2.11.1
Additional context
This is about ~
in locations other than the very beginning of the literal, where in stands for $HOME
, ~/foo
is accepted by Nix 2.11.1 and resolves to the same path as $HOME/foo
.
Possible workarounds thanks to @thufschmitt and @shlevy:
./${"foo~"}
./. + "/foo~"
Possibly relevant part of the code thanks to @layus.
The issue occurs in the Bazel extension rules_nixpkgs in the context of nixopts
location expansion when expanding labels to external workspaces in the new bzlmod dependency system. In that case the workspace directory is defined by the mangled name of the external workspace which includes ~
characters, e.g. external/nixpkgs_location_expansion_test_file~override/test_file
for @nixpkgs_location_expansion_test_file//:test_file
. The above workaround would have to be performed by users of rules_nixpkgs, meaning the issue is user-facing for rules_nixpkgs.
Priorities
Add 👍 to issues you find important.