Closed dbarrosop closed 2 years ago
/cc @ilkecan
It smells like a string interpolation forcing a path to get added to the store.
Also builtins.readDir
on /nix/store
is likely pretty slow.
Currently there isn't any Nix builtin to determine if a path is a directory or not. Before #27 _pathIsDirectory
was defined as:
# Returns true if the path exists and is a directory, throws an error otherwise
_pathIsDirectory = p: builtins.pathExists p && builtins.isAttrs (builtins.readDir p);
We were calling _pathIsDirectory
with paths that were suppose to be a directory so defining it as a partial function like this was somewhat OK.
But to implement #27, I needed a total version of _pathIsDirectory
so I had the idea of using builtins.readDir
on the parent of the path, because it also returns the type of the children.
But I didn't think/test about this specific case of root = ./.;
with flakes. Accessing the parent directory of a flake (/nix/store/
[^1]) is not allowed which this assertion do:
https://github.com/numtide/nix-filter/blob/825abbb40ed6b1e5e5fce95e2c21a1f5881ecf61/default.nix#L20
[^1]: because flake evaluations happens on files after they are copied to the Nix store
fixed in #31. Thanks!
Describe the bug
Since #27 this seems to break with flakes. If you add a check like
And then try to run
nix flake check
it breaks with:To Reproduce
See above.
Expected behavior
It should work
System information
Using 825abbb40ed6b1e5e5fce95e2c21a1f5881ecf61, if you revert to the previous commit it works fine.
Additional context
N/A