make template overrides chainable

This commit is contained in:
Valentin Gagarin 2024-11-13 15:24:41 +01:00
parent c11da792d7
commit 9c2b543e47

15
lib.nix
View file

@ -1,7 +1,20 @@
{ lib }: { lib }:
rec { rec {
template = g: f: x: template = g: f: x:
(g (f x)) // { override = o: g (lib.recursiveUpdate (f x) o); }; let
base = f x;
result = g base;
in
result // {
override = new:
let
base' = lib.recursiveUpdate base new;
result' = g base';
in
result' // {
override = new: (template g (x': base') x).override new;
};
};
/** /**
Recursively replace occurrences of `from` with `to` within `string` Recursively replace occurrences of `from` with `to` within `string`