Excluding a subdirectory when using local paths

Is it possible to do something like src = ./.; while excluding a certain directory? (node_modules, specifically)
I know I could do something like srcs = [ ./package.json ./lib ... ]; but then I’d have to remember to add it to the derivation if I want to add a new folder in the future.
I also don’t quite understand what’s going on with local paths overall. Where’s the best source of information about them?

something like this should work, see builtins.filterSource in the manual.

src = builtins.filterSource
    (path: type: !(type == "directory" && baseNameOf path == "node_modules"))
    ./source-dir;
1 Like

Perfect! Thank you :slight_smile: