lib.fileset.fileFilter: Predicate attribute for file extension#266362
lib.fileset.fileFilter: Predicate attribute for file extension#266362infinisil merged 1 commit intoNixOS:masterfrom
lib.fileset.fileFilter: Predicate attribute for file extension#266362Conversation
lib.fileset.fileFilter: Predicate attribute for file extension
|
Very looking forward for this |
3de1bff to
c31cfee
Compare
c31cfee to
e0b1528
Compare
|
Rebased, added tests and made sure the docs are accurate. I'd say let's have this! |
e0b1528 to
1af8f12
Compare
What about lib.fileset.fileFilter (file:
file.hasExt "hs" || file.hasExt "nix"
) ./.lib.fileset.fileFilter (file:
! file.hasExt "tar.gz"
) ./. |
|
Not bad, here's another idea though: lib.fileset.fileFilter (file:
file.fullExt != "tar.gz"
) ./.and lib.fileset.fileFilter (file:
file.lastExt != "gz"
) ./.I do think there's some benefit to getting the extension value directly, e.g. you could do lib.fileset.fileFilter (file:
if file.ext == null then
true
else
{
nix = false;
c = true;
h = false;
}.${file.lastExt}
or (throw "Don't know what to do with file extension ${file.lastExt}")
) ./.Also there wouldn't be a problem to have multiple of these. Their names make them pretty obvious. |
|
But then you have to get into what full means. What if you have Is that a Determining which part of the file name is extension is up to the caller, not up to |
|
Fair enough! I guess with lib.fileset.fileFilter (file:
lib.any file.hasExt [ "hs" "nix" ]
) ./.which is pretty short |
43eadfa to
5aaac6d
Compare
roberth
left a comment
There was a problem hiding this comment.
If a tree falls, but no-one's arou
I think one corner case should be addressed in the docs, and then we're good.
lib/fileset/tests.sh
Outdated
There was a problem hiding this comment.
Does .gitignore have a .gitignore extension, or no extension at all? In ~other words, does the empty basename exist?
There was a problem hiding this comment.
This is covered with the file.hasExt "a" test, yes, gitignore is treated as an extension! Should be added to the docs though :)
There was a problem hiding this comment.
I guess we could ask whether that's the right behavior though, alternatively it could error 🤔
There was a problem hiding this comment.
I think it's fine to leave it as is, I added some docs for that: (diff)
|
Is it a file system tree? |
5aaac6d to
6816f28
Compare
roberth
left a comment
There was a problem hiding this comment.
The right extent of extension support.👌
|
OfBorg is sluggish today.
Nice. |
Only today? 😅 |
|
Successfully created backport PR for |
Now that NixOS/nixpkgs#266362 is merged
Now that NixOS/nixpkgs#266362 is merged
Description of changes
Makes it more convenient to use
lib.fileset.fileFilterto filter by file extension:Whereas previously this would've needed
I'd imagine this should be fairly popular, but we need to confirm first.
This work is sponsored by Antithesis ✨
Things done