nixpkgs.lib.setFunctionArgs
#nixpkgs #trivial #functionAnnotations
(a -> b) -> AttrSets -> { __functor = any -> a -> b; __functionArg = AttrSets }
第1引数の関数に渡す予定の引数を第2引数で受け取りそれを保持しておくオブジェクトを返す関数。nixpkgs.lib.functionArgsで引数を取り出すことができる。
https://github.com/NixOS/nixpkgs/blob/nixos-22.11/lib/trivial.nix#L418-L432
code: trivial.nix
/* Add metadata about expected function arguments to a function.
The metadata should match the format given by
builtins.functionArgs, i.e. a set from expected argument to a bool
representing whether that argument has a default or not.
setFunctionArgs : (a → b) → Map String Bool → (a → b)
This function is necessary because you can't dynamically create a
function of the { a, b ? foo, ... }: format, but some facilities
like callPackage expect to be able to query expected arguments.
*/
setFunctionArgs = f: args:
{ # TODO: Should we add call-time "type" checking like built in?
__functor = self: f;
__functionArgs = args;
};