Skip to content

Commit

Permalink
lib.packagesFromDirectoryRecursive: Add example use of `recurseIntoDi…
Browse files Browse the repository at this point in the history
…rectory`
  • Loading branch information
nbraud committed Dec 30, 2024
1 parent bf5cd41 commit 0fe9ad2
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions lib/filesystem.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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 = with lib;
any (child: isDerivation child || child.recurseForDerivations or false) result;
};
}
```
:::
*/
packagesFromDirectoryRecursive =
let
Expand Down

0 comments on commit 0fe9ad2

Please sign in to comment.