Noogλe :: 2024

search input

Function of the day

  • Create a file set with the same files as a lib.sources-based value. This does not import any of the files into the store.

    This can be used to gradually migrate from lib.sources-based filtering to lib.fileset.

    A file set can be turned back into a source using toSource.

    File sets cannot represent empty directories. Turning the result of this function back into a source using toSource will therefore not preserve empty directories.



    1. Function argument


    fromSource :: SourceLike -> FileSet


    fromSource usage example

    # There's no cleanSource-like function for file sets yet,
    # but we can just convert cleanSource to a file set and use it that way
    toSource {
      root = ./.;
      fileset = fromSource (lib.sources.cleanSource ./.);
    # Keeping a previous sourceByRegex (which could be migrated to `lib.fileset.unions`),
    # but removing a subdirectory using file set functions
      (fromSource (lib.sources.sourceByRegex ./. [
        # This regex includes everything in ./doc
    # Use cleanSource, but limit it to only include ./Makefile and files under ./src
      (fromSource (lib.sources.cleanSource ./.))
      (unions [