Describe the bug
nix building a path: flake url with the current working directory located in the nix store produces a symlink pointing to the base storepath of the (realpath of the) current working directory rather than the output store path.
The same effect does not occur when given the directory not prefixed by path:.
Steps To Reproduce
Running:
#! /usr/bin/env bash
unset tmpdir
cleanup() {
while popd >/dev/null 2>&1; do :; done
[ -d "${tmpdir:-}" ] && rm -rf "$tmpdir"
}
trap cleanup EXIT
tmpdir="$(mktemp -td nix-path-issue-test-XXXXX)"
pushd "$tmpdir" >/dev/null
mkdir -p flake/dir/subdir
cat >flake/flake.nix <<'EOF'
{
outputs = {...}: {
foo = builtins.toFile "foo" "bar";
dir = "${./dir}";
};
}
EOF
nix build ./flake#.dir --out-link dir-in-nix-store
pushd dir-in-nix-store/subdir >/dev/null
nix build "$tmpdir"/flake#.foo --out-link "$tmpdir"/without-path
printf "without-path points to %s\n" "$(readlink "$tmpdir"/without-path)"
nix build path:"$tmpdir"/flake#.foo --out-link "$tmpdir"/with-path
printf "with-path points to %s\n" "$(readlink "$tmpdir"/with-path)"
Produces:
without-path points to /nix/store/vxjiwkjkn7x4079qvh1jkl5pn05j2aw0-foo
with-path points to /nix/store/l9pp9z5306crjh3a4rckdp36hlkvfhdj-dir
That value for with-path is "bafflingly wrong", as colemickens put it in NixOS/nixpkgs#144811
Expected behavior
with-path should point to /nix/store/vxjiwkjkn7x4079qvh1jkl5pn05j2aw0-foo
Metadata
Tested with nix 2.29.0 as well as 2.24.10.
Additional context
Checklist
Add 👍 to issues you find important.
Describe the bug
nix building apath:flake url with the current working directory located in the nix store produces a symlink pointing to the base storepath of the (realpath of the) current working directory rather than the output store path.The same effect does not occur when given the directory not prefixed by
path:.Steps To Reproduce
Running:
Produces:
That value for
with-pathis "bafflingly wrong", as colemickens put it in NixOS/nixpkgs#144811Expected behavior
with-pathshould point to/nix/store/vxjiwkjkn7x4079qvh1jkl5pn05j2aw0-fooMetadata
Tested with nix 2.29.0 as well as 2.24.10.
Additional context
Checklist
Add 👍 to issues you find important.