Admins will be upgrading ORNL GitLab Servers on Saturday, 16 May 2026, from 7 AM until 11 AM EST. Repositories will experience intermittent outages during this time.
See [`extends`](#function-library-lib.fixedPoints.extends) for an example use case.
There `self` is also often called `final`.
# Inputs
`f`
@@ -90,7 +89,12 @@ rec {
:::
*/
fix=f:letx=fx;inx;
fix=
f:
let
x=fx;
in
x;
/**
A variant of `fix` that records the original recursive attribute set in the
@@ -99,14 +103,20 @@ rec {
This is useful in combination with the `extends` function to
implement deep overriding.
# Inputs
`f`
: 1\. Function argument
*/
fix'=f:letx=fx//{__unfix__=f;};inx;
fix'=
f:
let
x=fx//{
__unfix__=f;
};
in
x;
/**
Return the fixpoint that `f` converges to when called iteratively, starting
@@ -117,7 +127,6 @@ rec {
0
```
# Inputs
`f`
@@ -134,13 +143,12 @@ rec {
(a -> a) -> a -> a
```
*/
converge=f:x:
converge=
f:x:
let
x'=fx;
in
ifx'==x
thenx
elseconvergefx';
ifx'==xthenxelseconvergefx';
/**
Extend a function using an overlay.
@@ -149,7 +157,6 @@ rec {
A fixed-point function is a function which is intended to be evaluated by passing the result of itself as the argument.
This is possible due to Nix's lazy evaluation.
A fixed-point function returning an attribute set has the form
```nix
@@ -257,7 +264,6 @@ rec {
```
:::
# Inputs
`overlay`
@@ -299,8 +305,7 @@ rec {
:::
*/
extends=
overlay:
f:
overlay:f:
# The result should be thought of as a function, the argument of that function is not an argument to `extends` itself
(
final:
@@ -311,63 +316,98 @@ rec {
);
/**
Compose two extending functions of the type expected by 'extends'
into one where changes made in the first are available in the
'super' of the second
Compose two overlay functions and return a single overlay function that combines them.
For more details see: [composeManyExtensions](#function-library-lib.fixedPoints.composeManyExtensions).
*/
composeExtensions=
f:g:final:prev:
let
fApplied=ffinalprev;
prev'=prev//fApplied;
in
fApplied//gfinalprev';
/**
Composes a list of [`overlays`](#chap-overlays) and returns a single overlay function that combines them.
:::{.note}
The result is produced by using the update operator `//`.
This means nested values of previous overlays are not merged recursively.
In other words, previously defined attributes are replaced, ignoring the previous value, unless referenced by the overlay; for example `final: prev: { foo = final.foo + 1; }`.
:::
# Inputs
`f`
`extensions`
: 1\. Function argument
: A list of overlay functions
:::{.note}
The order of the overlays in the list is important.
:::
`g`
: Each overlay function takes two arguments, by convention `final` and `prev`, and returns an attribute set.
- `final` is the result of the fixed-point function, with all overlays applied.
- `prev` is the result of the previous overlay function(s).