Noogλe
search input
Function of the day
Convert to an extending function (overlay).
toExtension
is thetoFunction
for extending functions (a.k.a. extensions or overlays). It converts a non-function or a single-argument function to an extending function, while returning a two-argument function as-is.That is, it takes a value of the shape
x
,prev: x
, orfinal: prev: x
, and returnsfinal: prev: x
, assumingx
is not a function.This function takes care of the input to
stdenv.mkDerivation
'soverrideAttrs
function. It bridges the gap between<pkg>.overrideAttrs
before and after the overlay-style support.Inputs
f
- The function or value to convert to an extending function.
Type
toExtension :: b' -> Any -> Any -> b' or toExtension :: (a -> b') -> Any -> a -> b' or toExtension :: (a -> a -> b) -> a -> a -> b where b' = ! Callable Set a = b = b' = AttrSet & ! Callable to make toExtension return an extending function.
Examples
lib.fixedPoints.toExtension
usage examplefix (final: { a = 0; c = final.a; }) => { a = 0; c = 0; }; fix (extends (toExtension { a = 1; b = 2; }) (final: { a = 0; c = final.a; })) => { a = 1; b = 2; c = 1; }; fix (extends (toExtension (prev: { a = 1; b = prev.a; })) (final: { a = 0; c = final.a; })) => { a = 1; b = 0; c = 1; }; fix (extends (toExtension (final: prev: { a = 1; b = prev.a; c = final.a + 1 })) (final: { a = 0; c = final.a; })) => { a = 1; b = 0; c = 2; };