nixpkgs.lib.functionArgs
#nixpkgs #trivial #functionAnnotations
any -> AttrSets
関数のデフォルト引数を返す関数。nixpkgs.lib.setFunctionArgsで作成されたものであれば、__functionArgsキーの値を返し、そうでない場合はbuiltins.functionArgsを使って結果を返す。
https://github.com/NixOS/nixpkgs/blob/nixos-22.11/lib/trivial.nix#L434-L443
code: trivial.nix
/* Extract the expected function arguments from a function.
This works both with nix-native { a, b ? foo, ... }: style
functions and functions with args set with 'setFunctionArgs'. It
has the same return type and semantics as builtins.functionArgs.
setFunctionArgs : (a → b) → Map String Bool.
*/
functionArgs = f:
if f ? __functor
then f.__functionArgs or (lib.functionArgs (f.__functor f))
else builtins.functionArgs f;