Functions for working with paths/sources?

There’s a few things I’d like to be able to do that I don’t see any functions for.

  1. Decompose a path into parts. All I see is baseNameOf.
  2. Create a nix derivation from a list of paths
  3. Something that combines the functionality of lib.filesystem.listFilesRecursive and builtins.filterSource (I believe this could be done pretty easily with 2.)

In general the tools for working with paths and sources seem rather limited.

I’ll number my questions so people can respond to them individually.

  1. Am I just not looking in the right place for these?
  2. Is there a third party paths library out there somewhere I can use?
  3. Does the fact that I want these things signal I’m writing bad nix?
  4. Is there a particular reason these functions don’t exist?
1 Like

Well, where did you look? There is some stuff to operate on paths in /lib/sources.nix and in /lib/strings.nix if you handle paths as strings. There is also this nice builtin readDir to handle a whole directory.

We don’t know what you want to write. Maybe you can describe more of your use case or show some draft code?

PS: I just saw you’re new - welcome to the forum! Hope we can help you get going.