Open Atry opened 2 years ago
The behavior could be surprising sometimes:
nix-repl> pkgs = import <nixpkgs> {}
nix-repl> pkgs.bash.outPath + /bin/bash
"/nix/store/s7r5cnjj4zy41g2nql3vf2ivr09wfm5p-bash-5.1-p16/nix/store/4jd7mslcg2c1w95z29crzkvrglf0qf7a-bash"
nix-repl> pkgs.bash + /bin/bash
"/nix/store/s7r5cnjj4zy41g2nql3vf2ivr09wfm5p-bash-5.1-p16/bin/bash"
Also path interpolation behavior is inconsistent, too
nix-repl> :lf git+https://github.com/NixOS/nixos-homepage.git
Added 14 variables.
nix-repl> /${inputs.nixpkgs}
error: a string that refers to a store path cannot be appended to a path
at «string»:1:1:
1| /${inputs.nixpkgs}
| ^
nix-repl> /${<nixpkgs>}
/nix/var/nix/profiles/per-user/root/channels/nixpkgs
Your inputs.nixpkgs.outPath + /pkgs/build-support/mkshell/default.nix
example doesn't make sense to me because it's appending an absolute path to another absolute path. Which is not a thing any language worth its salt would allow.
The second example inputs.nixpkgs + /pkgs/build-support/mkshell/default.nix
seemed inconsistent to me at first glace, until I realize inputs.nixpkgs
is not a path. But prepending a string to an absolute path, is also something a sane language should error on.
Describe the bug
When a path is appended, sometimes the path is converted to a nix store string while sometimes it is converted to the string of the original path. The behavior is inconsistent and confusing.
Steps To Reproduce
Expected behavior
All the following expression should return the same value
inputs.nixpkgs.outPath + /pkgs/build-support/mkshell/default.nix
inputs.nixpkgs + /pkgs/build-support/mkshell/default.nix
inputs.nixpkgs + /pkgs/build-support + /mkshell/default.nix
nix-env --version
outputnix-env (Nix) 2.8.0