mirror of
https://github.com/NixOS/nixpkgs.git
synced 2025-06-09 19:13:26 +03:00
lib.packagesFromDirectoryRecursive: reject unknown arguments
see [discussion](https://github.com/NixOS/nixpkgs/pull/270537#discussion_r1862458435)
This commit is contained in:
parent
6cc285d613
commit
93d76b7344
2 changed files with 14 additions and 24 deletions
|
@ -311,7 +311,7 @@ in
|
|||
newScope? :: AttrSet -> scope,
|
||||
directory :: Path,
|
||||
recurseIntoDirectory? :: (args -> AttrSet) -> args -> AttrSet,
|
||||
...
|
||||
recurseArgs? :: Any
|
||||
}) -> AttrSet
|
||||
```
|
||||
|
||||
|
@ -349,6 +349,9 @@ in
|
|||
```
|
||||
:::
|
||||
|
||||
`recurseArgs`
|
||||
: Optional argument, which can be hold data used by `recurseIntoDirectory`
|
||||
|
||||
# Examples
|
||||
:::{.example}
|
||||
## Basic use of `lib.packagesFromDirectoryRecursive`
|
||||
|
@ -438,28 +441,12 @@ 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 ?
|
||||
if args ? newScope then
|
||||
# `processDir` is the same function as defined above
|
||||
# `args` are the arguments passed to (this recursive call of) `packagesFromDirectoryRecursive`
|
||||
processDir: { newScope, ... }@args:
|
||||
# Create a new scope and mark it `recurseForDerivations`.
|
||||
# This lets the packages refer to each other.
|
||||
# See:
|
||||
# [lib.makeScope](https://nixos.org/manual/nixpkgs/unstable/#function-library-lib.customisation.makeScope) and
|
||||
# [lib.recurseIntoAttrs](https://nixos.org/manual/nixpkgs/unstable/#function-library-lib.customisation.makeScope)
|
||||
recurseIntoAttrs (makeScope newScope (self:
|
||||
# generate the attrset representing the directory, using the new scope's `callPackage` and `newScope`
|
||||
processDir (args // {
|
||||
inherit (self) callPackage newScope;
|
||||
})
|
||||
))
|
||||
else
|
||||
# otherwise, no modification is necessary
|
||||
id,
|
||||
...
|
||||
# recurseIntoDirectory can modify the function used when processing directory entries
|
||||
# and recurseArgs can (optionally) hold data for its use ; see function documentation
|
||||
recurseArgs ? throw "lib.packagesFromDirectoryRecursive: recurseArgs wasn't passed in args",
|
||||
recurseIntoDirectory ? defaultRecurse,
|
||||
}@args:
|
||||
let
|
||||
defaultPath = append directory "package.nix";
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue