Skip to content

lib.fileset.fileFilter should allow filtering by file subpath/components #269504

@infinisil

Description

@infinisil

Issue description

Currently the predicate of lib.fileset.fileFilter only gets name, type (and soon hasExt).

There's no way to filter by the subpath/components of the file, something like this:

lib.fileset.fileFilter (file:
  lib.lists.hasSuffix [ "foo" "bar" ] file.components
) ./.

(hasSuffix currently also doesn't exist)

Some ideas:

  • file.components :: [ String ]: File components, always at least one element for the file's name
  • file.subpath :: String: The file's subpath
  • file.dirComponents :: [ String ]: Directory components, can be empty for files in the root level
  • file.dirSubpath :: String: Directory subpath, can be ./. for files in the root level

This feature request is the motivation behind #267384.

This issue is sponsored by Antithesis

Metadata

Metadata

Assignees

No one assigned

    Labels

    2.status: stalehttps://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md
    No fields configured for issues without a type.

    Projects

    Status

    No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions