From 6a07020e3c1734ff6f069a8f4ff33e6a2a0aefae Mon Sep 17 00:00:00 2001 From: Eman Resu <78693624+quatquatt@users.noreply.github.com> Date: Mon, 27 Apr 2026 12:02:43 -0400 Subject: [PATCH] lib.overrideDerivation: rewrite to not be utterly ridiculous Why are we running a `flip` on arguments we can control? Why are we using `or` on one line only to use a full if/else on the next line? Why are we merging with {}, and why have we been doing it for three years? THese are the questions I ask myself. --- lib/customisation.nix | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/lib/customisation.nix b/lib/customisation.nix index b2fa2cdebf33..4fbbfec41dff 100644 --- a/lib/customisation.nix +++ b/lib/customisation.nix @@ -20,7 +20,6 @@ let take length filterAttrs - flip head pipe isDerivation @@ -98,19 +97,18 @@ rec { */ overrideDerivation = drv: f: - let - newDrv = derivation (drv.drvAttrs // (f drv)); - in - flip (extendDerivation (seq drv.drvPath true)) newDrv ( + (extendDerivation (seq drv.drvPath true)) ( { meta = drv.meta or { }; - passthru = if drv ? passthru then drv.passthru else { }; + passthru = drv.passthru or { }; } // (drv.passthru or { }) - // optionalAttrs (drv ? __spliced) { - __spliced = { } // (mapAttrs (_: sDrv: overrideDerivation sDrv f) drv.__spliced); + // { + ${if drv ? __spliced then "__spliced" else null} = mapAttrs ( + _: sDrv: overrideDerivation sDrv f + ) drv.__spliced; } - ); + ) (derivation (drv.drvAttrs // (f drv))); /** `makeOverridable` takes a function from attribute set to attribute set and