From 314e8e49ecbfd4136463eff782190035d1b07365 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Tue, 28 Jul 2015 21:23:24 +0200 Subject: [PATCH] Remove deepOverride MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit It's unused, and also a bad idea: because it recursively recomputes every function argument and there is no sharing, you can get an exponential (?) blowup in evaluation time. For example, evaluating ‘linuxPackages.kernel’ takes 0.09s and ~13 MiB, but evaluating ‘linuxPackages.kernel.deepOverride {}’ takes 3.6s and ~305 MiB. --- lib/customisation.nix | 12 ------------ lib/deprecated.nix | 1 - 2 files changed, 13 deletions(-) diff --git a/lib/customisation.nix b/lib/customisation.nix index 91a25055df29..b3c73c39be41 100644 --- a/lib/customisation.nix +++ b/lib/customisation.nix @@ -49,10 +49,6 @@ rec { else { })); - # usage: (you can use override multiple times) - # let d = makeOverridable stdenv.mkDerivation { name = ..; buildInputs; } - # noBuildInputs = d.override { buildInputs = []; } - # additionalBuildInputs = d.override ( args : args // { buildInputs = args.buildInputs ++ [ additional ]; } ) makeOverridable = f: origArgs: let ff = f origArgs; @@ -60,24 +56,16 @@ rec { in if builtins.isAttrs ff then (ff // { override = newArgs: makeOverridable f (overrideWith newArgs); - deepOverride = newArgs: - makeOverridable f (lib.overrideExisting (lib.mapAttrs (deepOverrider newArgs) origArgs) newArgs); overrideDerivation = fdrv: makeOverridable (args: overrideDerivation (f args) fdrv) origArgs; }) else if builtins.isFunction ff then { override = newArgs: makeOverridable f (overrideWith newArgs); __functor = self: ff; - deepOverride = throw "deepOverride not yet supported for functors"; overrideDerivation = throw "overrideDerivation not yet supported for functors"; } else ff; - deepOverrider = newArgs: name: x: if builtins.isAttrs x then ( - if x ? deepOverride then (x.deepOverride newArgs) else - if x ? override then (x.override newArgs) else - x) else x; - /* Call the package function in the file `fn' with the required arguments automatically. The function is called with the diff --git a/lib/deprecated.nix b/lib/deprecated.nix index 54c253f2c34b..3646f9e032a1 100644 --- a/lib/deprecated.nix +++ b/lib/deprecated.nix @@ -29,7 +29,6 @@ rec { } )); withStdOverrides = base // { override = base.passthru.function; - deepOverride = a : (base.passthru.function ((lib.mapAttrs (lib.deepOverrider a) base.passthru.args) // a)); } ; in withStdOverrides;