Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add lib.fileset.optional :: Bool -> FileSet -> FileSet #266106

Open
infinisil opened this issue Nov 7, 2023 · 3 comments
Open

Add lib.fileset.optional :: Bool -> FileSet -> FileSet #266106

infinisil opened this issue Nov 7, 2023 · 3 comments
Labels
5. scope: tracked Issue (or PR) is linked back to a `5. scope: tracking` issue 6.topic: lib The Nixpkgs function library

Comments

@infinisil
Copy link
Member

OT: I would quite like to have fileset.optional : Bool -> FileSet -> FileSet such that optional false x == fileset.empty. Example:

mkDerivation(finalAttrs: {
  src = fileset.unions [
    ./src
    (fileset.optional finalAttrs.doCheck ./tests)
  ];
})

Originally posted by @roberth in #265964 (comment)

@infinisil infinisil added the 6.topic: lib The Nixpkgs function library label Nov 7, 2023
@infinisil
Copy link
Member Author

OT: I would quite like to have fileset.optional : Bool -> FileSet -> FileSet such that optional false x == fileset.empty

Is this actually required? You can already use lib.optional(s) and have the result coerced to a fileset.

Originally posted by @alyssais in #265964 (comment)

@infinisil
Copy link
Member Author

@alyssais A wrapping lib.unions is needed to convert the list returned by lib.optional[s] to a file set. Though I have also played around with the thought of implicitly coercing lists of filesets to their union, which would remove the need for that.

@infinisil infinisil changed the title Add lib.fileset.optional Add lib.fileset.optional :: Bool -> FileSet -> FileSet Nov 7, 2023
@alyssais
Copy link
Member

Though I have also played around with the thought of implicitly coercing lists of filesets to their union, which would remove the need for that.

I'd like that. I didn't even realise that individual paths are coerced, but lists aren't — that's counterintuitive to me.

@samueldr samueldr added the 5. scope: tracked Issue (or PR) is linked back to a `5. scope: tracking` issue label Apr 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
5. scope: tracked Issue (or PR) is linked back to a `5. scope: tracking` issue 6.topic: lib The Nixpkgs function library
Projects
None yet
Development

No branches or pull requests

3 participants