-
-
Notifications
You must be signed in to change notification settings - Fork 14.4k
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
lib.sourceSubdirs: init #234297
lib.sourceSubdirs: init #234297
Conversation
The name is borrowed from the lib.strings function, in the spirit of Rust's std::path library reusing names from std::string methods, but for more path-appropriate behaviour.
This is really useful for using Nix in monorepo layouts, where you might have a component build that needs access to multiple subdirectories of the repository. Compared to settings "srcs", it's more convenient, because it preserves the relative structure (including parent directories), and it avoids unnecessary rebuilds compared to not filtering for subdirectories.
Could you take a look at the file set combinators in #222981 (the best start is here and the reference it links to starting here)? That functionality is very widely applicable and composable. In particular it would be equivalent to with lib.fileset;
unions [
./one/directory
./another/directory
] Or if you want to also import it into the store: with lib.fileset;
importToStore {
entryPoint = ./.;
fileset = unions [
./one/directory
./another/directory
];
} It would be great to get feedback if this works for your use case. Or if you're seeing a problem with this interface. |
I was hoping you'd chime in with a better way! I tried it, but it doesn't look like it works:
My |
@alyssais Thanks for the feedback! On one hand, the However you also made be realize that it is very much possible to convert Could you give the same code another try with the updated PR? |
lib.fileset.toSource {
root = ./.;
fileset = lib.fileset.unions [
./host/rootfs
./scripts
];
} |
@infinisil sorry I never got round to retesting, but I still don't think it works for what I want to do — unless I'm mistaken there's still no way to use filesets with the result of |
Now opened #261732 for this, I should be able to polish that soon |
Description of changes
Things done
This is really useful for using Nix in monorepo layouts, where you
might have a component build that needs access to multiple
subdirectories of the repository. Compared to settings "srcs", it's
more convenient, because it preserves the relative
structure (including parent directories), and it avoids unnecessary
rebuilds compared to not filtering for subdirectories.
sandbox = true
set innix.conf
? (See Nix manual)nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD"
. Note: all changes have to be committed, also see nixpkgs-review usage./result/bin/
)