nix icon indicating copy to clipboard operation
nix copied to clipboard

Flake not accessible through symlink

Open jtojnar opened this issue 2 years ago • 2 comments

Describe the bug

Trying to access a flake though a symlink fails with the following error:

error: path '/tmp/nixfiles' is not a flake (because it's not a directory)

Steps To Reproduce

  1. Create a symlink to a flake.
  2. Try to build a derivation through the symlink.
$ ln -s ~/Projects/nixfiles/ /tmp/nixfiles
$ nix build /tmp/nixfiles#hello
error: path '/tmp/nixfiles' is not a flake (because it's not a directory)

Expected behavior

It should resolve the symlink and work with the target directory

nix-env --version output

nix (Nix) 2.14.1

Priorities

Add :+1: to issues you find important.

jtojnar avatar Mar 08 '23 22:03 jtojnar

In case someone might find it helpful, I use "$(readlink -f /path/to/flake)" as a workaround.

In my case system.autoUpgrade.flake = "$(readlink -f /etc/nixos)"; works, whereas system.autoUpgrade.flake = "/etc/nixos"; does not.

0xDubdub avatar May 04 '24 06:05 0xDubdub

Hmmm. I was hoping this would work with darwin-rebuild switch --flake $(readlink -f ~/.config/nix)#personal, but that doesn't seem to be the case. Any other workarounds? I've tried:

  • darwin-rebuild switch --flake ~/.config/nix#personal (default)
  • cd ~/.config/nix && darwin-rebuild switch --flake .#personal (also as a subshell)

Search engines aren't being as helpful as I'd hoped, but I really want to keep my flakes in my dotfiles that I manage using stow. Would definitely appreciate any thoughts.

robwilkerson avatar Oct 15 '24 17:10 robwilkerson