Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 28 additions & 9 deletions lib/customisation.nix
Original file line number Diff line number Diff line change
Expand Up @@ -763,11 +763,26 @@ rec {
# Inputs

`extendMkDerivation`-specific configurations
: `constructDrv`: Base build helper, the `mkDerivation`-like build helper to extend.
: `excludeDrvArgNames`: Argument names not to pass from the input fixed-point arguments to `constructDrv`. Note: It doesn't apply to the updating arguments returned by `extendDrvArgs`.
: `extendDrvArgs` : An extension (overlay) of the argument set, like the one taken by [overrideAttrs](#sec-pkg-overrideAttrs) but applied before passing to `constructDrv`.
: `inheritFunctionArgs`: Whether to inherit `__functionArgs` from the base build helper (default to `true`).
: `transformDrv`: Function to apply to the result derivation (default to `lib.id`).
: `constructDrv` (required)
: Base build helper, the `mkDerivation`-like build helper to extend.

`excludeDrvArgNames` (default to `[ ]`)
: Argument names not to pass from the input fixed-point arguments to `constructDrv`.
It doesn't apply to the updating arguments returned by `extendDrvArgs`.

`excludeFunctionArgNames` (default to `[ ]`)
: `__functionArgs` attribute names to remove from the result build helper.
`excludeFunctionArgNames` is useful for argument deprecation while avoiding ellipses.

`extendDrvArgs` (required)
: An extension (overlay) of the argument set, like the one taken by [overrideAttrs](#sec-pkg-overrideAttrs) but applied before passing to `constructDrv`.

`inheritFunctionArgs` (default to `true`)
: Whether to inherit `__functionArgs` from the base build helper.
Set `inheritFunctionArgs` to `false` when `extendDrvArgs`'s `args` set pattern does not contain an ellipsis.

`transformDrv` (default to `lib.id`)
: Function to apply to the result derivation.

# Type

Expand All @@ -776,6 +791,7 @@ rec {
{
constructDrv :: ((FixedPointArgs | AttrSet) -> a)
excludeDrvArgNames :: [ String ],
excludeFunctionArgNames :: [ String ]
extendDrvArgs :: (AttrSet -> AttrSet -> AttrSet)
inheritFunctionArgs :: Bool,
transformDrv :: a -> a,
Expand Down Expand Up @@ -836,6 +852,7 @@ rec {
{
constructDrv,
excludeDrvArgNames ? [ ],
excludeFunctionArgNames ? [ ],
extendDrvArgs,
inheritFunctionArgs ? true,
transformDrv ? id,
Expand All @@ -850,10 +867,12 @@ rec {
)
# Add __functionArgs
(
# Inherit the __functionArgs from the base build helper
optionalAttrs inheritFunctionArgs (removeAttrs (functionArgs constructDrv) excludeDrvArgNames)
# Recover the __functionArgs from the derived build helper
// functionArgs (extendDrvArgs { })
removeAttrs (
# Inherit the __functionArgs from the base build helper
optionalAttrs inheritFunctionArgs (removeAttrs (functionArgs constructDrv) excludeDrvArgNames)
# Recover the __functionArgs from the derived build helper
// functionArgs (extendDrvArgs { })
) excludeFunctionArgNames
Comment on lines +870 to +875
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The semantics here, as I understand them:

  1. If inheritFunctionArgs is set to true (the default)
    a. Whatever the arguments are to constructDrv will be used
    b. Except for those listed in excludeDrvArgNames, which will be excluded.
  2. The arguments for the derived build helper will override that.
    So if constructDrv had an argument without a default, but the derived build helper had a default, the result would have a default.
  3. Finally, no matter where it came from, if an argument is mentioned in the excludeFunctionArgNames list, it will be removed from the function arguments list.

I like those semantics.

)
// {
inherit
Expand Down
Loading