Include with a directory doesn't include files within or recursive directories
fzakaria opened this issue · comments
Describe the bug
From reading the description I would expect including a directory (relative to the root) would include everything within it (excluding whatever is in the excludes)
To Reproduce
I am in a repository with a bin folder with some files:
❯ tree bin | head
bin
├── api_codes
├── api_codes.js
├── btest
├── bulk-decaffeinate
├── bundler_config
I then have the following:
src = nix-filter
{
# apply clean source to remove .git
root = ./.;
include = [
"bin"
];
exclude = [
(nix-filter.matchExt "class")
(nix-filter.matchExt "jar")
];
};
buildPhase = ''
${tree}/bin/tree
'';
❯ nix-build build.nix
this derivation will be built:
/nix/store/i3jq894xcpcyh88q188nym5rvb1mxgfg-test.drv
building '/nix/store/i3jq894xcpcyh88q188nym5rvb1mxgfg-test.drv'...
unpacking sources
unpacking source archive /nix/store/1pjir24lijwsy86j6syq527yy9x51mq1-source
source root is source
patching sources
configuring
no configure script, doing nothing
building
.
`-- bin
1 directory, 0 files`
Expected behavior
I would expect to see the bin folder with all it's contents.
System information
❯ niv show
nix-filter
homepage:
url: https://github.com/numtide/nix-filter/archive/3e81a637cdf9f6e9b39aeb4d6e6394d1ad158e16.tar.gz
owner: numtide
branch: master
url_template: https://github.com/<owner>/<repo>/archive/<rev>.tar.gz
repo: nix-filter
type: tarball
sha256: 1gqbrsx9s7r3i324wi5w1il6xmfma24g8hvfgpbgyjvzpci8m30k
description: a small self-container source filtering lib
rev: 3e81a637cdf9f6e9b39aeb4d6e6394d1ad158e16
try:
include = [
(inDirectory "bin")
];
Will try.
It's a bit confusing since the src attribute when given a directory normally is recursive/
Thanks for the library btw.
Confirmed the inDirectory works but maybe worth calling out in docs.
What's the point of every giving a directory as a raw string or path then in the include list?
Seems like a user or library error.
Agreed, but it's a limitation of builtins.path
. It's only traversing directories that got "accepted". nix-filter is just a layer on top of it. See https://github.com/numtide/nix-filter#design-notes
Should it error if a raw directory is given somehow or assert?
It's surely a mistake; is it possible to check all raw paths and convert them to isDirectory as well if they are ?
No, you have to add the directory if you list all the includes explicitly.
Eg:
includes = [
./bin
./bin/my-exe
]