NixOS / nix

Nix, the purely functional package manager
https://nixos.org/
GNU Lesser General Public License v2.1
12.94k stars 1.53k forks source link

Circular flake import error when not circular #4811

Open andir opened 3 years ago

andir commented 3 years ago

Describe the bug

When I have a directory structure that has at least two directories with the same name nested in it where each of the folders contains a flake.nix:

  /flake.nix
  /a/flake.nix
  /a/a/flake.nix

When given a minimal flake.nix for each of them (except for the last one in a/a) like this:

{
  inputs.a.url = "path:./a";
  outputs = { a, self }: {};
}

The nix flake metadata command in the root fails like this:

error: found circular import of flake 'path:./a'

       … while updating the flake input 'a/b'

       … while updating the flake input 'a'

       … while updating the lock file of flake 'path:/home/andi/.../a?narHash=....'

It is complaining about a circular import which isn't one. It appears as if the circular dependency detection is working based on the input string and not on some normalized absolute path.

Expected behavior

I would except to be able to nest flakes in a few directories to keep implementation details for packages in sub-flakes where they are being maintained.

nix-env --version output

nix-env (Nix) 2.4pre20210326_dd77f71

Additional context

There was an issue about circular dependencies that claims that they are now supported but apparently they are not supported anymore?

stale[bot] commented 3 years ago

I marked this as stale due to inactivity. → More info

fricklerhandwerk commented 1 year ago

Triaged in Nix team meeting:

nixos-discourse commented 1 year ago

This issue has been mentioned on NixOS Discourse. There might be relevant details there:

https://discourse.nixos.org/t/2023-10-27-nix-team-meeting-minutes-98/34695/1