Relative path support for Nix flakes

As far as I’m aware, Nix Flakes should have had support for relative paths for a while now?

For some reason, when I nix develop in my project on a new Nix installation or after I run gc, I get this:
error: cannot fetch input 'path:../js-dependencys?narHash=sha256-cayhXT6eRBgQuvfu1IKkJpqdjKkhdzRKYsUikx%2fQo%2fY=' because it uses a relative path

Strangely, this goes away once I do flake update. What could be the cause of this annoying behaviour?


This comment in the issue probably explains it?


You seem quite right, thanks for your pointer!

1 Like

The linked github comment says:

Relative paths currently rely on a source with the correct hash to be already present in the store.
This is fragile but won’t be noticed by the flake author, because creating the lockfile adds locally

I take huge issue with this, it is certainly noticed by the author of the flake. How does one solve the problem? It seems I must first build the included flake before the encompassing flake? EDIT: No, that doesn’t fix the issue.

If you build the included flake before the encompassing flake, it should work.

In the meantime I myself have resorted to workarounds of variously:

  • running nix commands in a wrapper that always passes --override-input
  • directly using import