mirror of
https://github.com/NixOS/nixpkgs.git
synced 2025-06-09 19:13:26 +03:00
lib.packagesFromDirectoryRecursive: Add example use of recurseIntoDirectory
This commit is contained in:
parent
93d76b7344
commit
be6ce5f40d
1 changed files with 32 additions and 0 deletions
|
@ -394,6 +394,38 @@ in
|
|||
`a.nix` cannot directly take as inputs packages defined in a child directory, such as `b1`.
|
||||
:::
|
||||
::::
|
||||
|
||||
:::{.example}
|
||||
## Mark with `recurseIntoAttrs` when recursing into a directory
|
||||
```nix
|
||||
packagesFromDirectoryRecursive {
|
||||
inherit (pkgs) callPackage;
|
||||
directory = ./my-packages;
|
||||
|
||||
recurseIntoDirectory = processDir: args: lib.recurseIntoAttrs (processDir args);
|
||||
}
|
||||
```
|
||||
:::
|
||||
|
||||
:::{.example}
|
||||
## Express custom recursion behaviour with `recurseIntoDirectory`
|
||||
For instance, only mark attrsets produced by `packagesFromDirectoryRecursive` with `recurseForDerivations`
|
||||
if they (transitively) contain derivations.
|
||||
|
||||
```nix
|
||||
packagesFromDirectoryRecursive {
|
||||
inherit (pkgs) callPackage;
|
||||
directory = ./my-packages;
|
||||
|
||||
recurseIntoDirectory = processDir: args: let
|
||||
result = processDir args;
|
||||
in result // {
|
||||
recurseForDerivations =
|
||||
lib.any (child: lib.isDerivation child || child.recurseForDerivations or false) result;
|
||||
};
|
||||
}
|
||||
```
|
||||
:::
|
||||
*/
|
||||
packagesFromDirectoryRecursive =
|
||||
let
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue