lib.fileset: Representation for empty file sets without a base path#257351
lib.fileset: Representation for empty file sets without a base path#257351roberth merged 1 commit intoNixOS:masterfrom
lib.fileset: Representation for empty file sets without a base path#257351Conversation
lib.fileset.unions [] worklib.fileset: Representation for empty file sets without a base path
|
I'm not sure about the approach here. I understand that having a value to represent |
The motivation comes from this example, which should work: toSource {
root = ./foo;
fileset = intersect ./foo ./.;
}If Extending that, this should also succeed without an error: toSource {
root = ./foo;
fileset = intersect ./foo ./bar;
}though this would give an empty result, but that's as one would expect. (this will definitely have to go into the design document) |
|
I'd rather have a working abstraction than a leaky (broken) one that is "extra readable". |
Agreed that the combination of Only then it seems inevitable to produce a special kind of value for @roberth: Fully agreed. A particularly involved implementation is still better with a well-articulated rationale. |
The base path is mostly an invisible implementation detail, users shouldn't have to know about it. The only interaction of it with the user is in this error message: This error should only be thrown when it's relevant, meaning when there could be some file outside the
Comparatively, |
34dde44 to
5141148
Compare
|
I now updated this to use Furthermore, I added a section to the design document explaining why such a value is needed and the problem with alternatives. Valentin also confirmed in a meeting that he agrees with this being needed. I think this is ready to be merged, and unless there are any complaints in the next couple days I'll merge this myself. |
5141148 to
5ab7764
Compare
`unions []` now works! Notably the new empty value without a base is not exposed in the interface. I don't know of any use case for it.
5ab7764 to
4f35f00
Compare
|
In PM's @fricklerhandwerk made the suggestion to call it |
roberth
left a comment
There was a problem hiding this comment.
One off-topic suggestion. LGTM!
| Tag to indicate this value is a file set. | ||
|
|
||
| - `_internalVersion` (constant `2`, the current version): | ||
| - `_internalVersion` (constant `3`, the current version): |
There was a problem hiding this comment.
Should this be in a file like fileset/internal/README.md?
There was a problem hiding this comment.
I view lib/fileset/README.md as the internal contributor documentation, where I think this makes sense to have. It's not part of the public interface, but you need to know about it to contribute, which can mean to change the internals
There was a problem hiding this comment.
It should link to the user docs.
Description of changes
Changes the internal fileset structure to also be able to represent empty file sets without any base path. This can then be used as the return value of
unions [].Once the
lib.fileset.intersectcombinator from the full WIP combinators is added, this will also be suitable as a return value for e.g.intersect /foo /bar.Notably the new empty singleton value is not exposed in the interface, because I don't know of any use case for it. It could be added later if a use case emerges.
This work is sponsored by Antithesis ✨
Things done