Skip to content

Commit

Permalink
lib.packagesFromDirectoryRecursive: reject unknown arguments
Browse files Browse the repository at this point in the history
see [discussion](NixOS#270537 (comment))
  • Loading branch information
nbraud committed Dec 30, 2024
1 parent 1ca4a58 commit bf5cd41
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
11 changes: 8 additions & 3 deletions lib/filesystem.nix
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,7 @@ in
newScope? :: AttrSet -> scope,
directory :: Path,
recurseIntoDirectory? :: (args -> AttrSet) -> args -> AttrSet,
...
recurseArgs? :: Any
}) -> AttrSet
```
Expand Down Expand Up @@ -349,6 +349,9 @@ in
```
:::
`recurseArgs`
: Optional argument, which can be hold data used by `recurseIntoDirectory`
# Examples
:::{.example}
## Basic use of `lib.packagesFromDirectoryRecursive`
Expand Down Expand Up @@ -421,8 +424,11 @@ in
in
{
callPackage,
newScope ? throw "lib.packagesFromDirectoryRecursive: newScope wasn't passed in args",
directory,
# recurseIntoDirectory can modify the function used when processing directory entries; see nixdoc above
# recurseIntoDirectory can modify the function used when processing directory entries
# and recurseArgs can (optionally) hold data for its use ; see nixdoc above
recurseArgs ? throw "lib.packagesFromDirectoryRecursive: recurseArgs wasn't passed in args",
recurseIntoDirectory ?
if args ? newScope then
# `processDir` is the same function as defined above
Expand All @@ -442,7 +448,6 @@ in
else
# otherwise, no modification is necessary
id,
...
}@args:
let
defaultPath = append directory "package.nix";
Expand Down
6 changes: 5 additions & 1 deletion nixos/doc/manual/release-notes/rl-2505.section.md
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,10 @@
- [`lib.types.enum`](https://nixos.org/manual/nixos/unstable/#sec-option-types-basic): Previously the `functor.payload` was the list of enum values directly. Now it is an attribute set containing the values in the `values` attribute.
- [`lib.types.separatedString`](https://nixos.org/manual/nixos/unstable/#sec-option-types-string): Previously the `functor.payload` was the seperator directly. Now it is an attribute set containing the seperator in the `sep` attribute.

- [`lib.packagesFromDirectoryRecursive`] now rejects unknown arguments, and applies [`lib.recurseIntoAttrs`] when recursing into a directory.
[`lib.packagesFromDirectoryRecursive`]: https://nixos.org/manual/nixpkgs/stable/#function-library-lib.filesystem.packagesFromDirectoryRecursive
[`lib.recurseIntoAttrs`]: https://nixos.org/manual/nixpkgs/stable/#function-library-lib.attrsets.recurseIntoAttrs

### Other notable changes {#sec-release-25.05-lib-notable-changes}

- `lib.packagesFromDirectoryRecursive` can now construct nested scopes matching the directory tree passed as input.
- [`lib.packagesFromDirectoryRecursive`] can now construct nested scopes matching the directory tree passed as input.

0 comments on commit bf5cd41

Please sign in to comment.