import-tree icon indicating copy to clipboard operation
import-tree copied to clipboard

`import-tree` return incorrect file list for directory contain `default.nix`

Open phhai-hcmut opened this issue 9 months ago • 1 comments

When I call import-tree on directory contain default.nix, it incorrectly return each files in the directory instead of directory itself.

Example file structure:

modules/
  subdir/
    default.nix
    a.nix
    b.nix

Expected behaviour

I expect following code

{lib, config, ...} {
  imports = [ (import-tree ./modules) ];
}

Is similar to

{lib, config, ...} {
  imports = [
    {
      imports = [ ./modules/subdir ];
    }
  ];
}

Actual behaviour

import-tree returns each files in the directory.

{lib, config, ...} {
  imports = [
    {
      imports = [
        ./modules/subdir/default.nix
        ./modules/subdir/a.nix
        ./modules/subdir/b.nix
      ];
    }
  ];
}

phhai-hcmut avatar Feb 20 '26 07:02 phhai-hcmut

This is not a bug. This is the expected documented behaviour. Any nix file is included. If you want to skip some file, read the docs on how to use filter.

vic avatar Feb 20 '26 07:02 vic