From aadb898a0be398db5db13653c7aaacc0ae9f84d9 Mon Sep 17 00:00:00 2001 From: Michael Raskin <7c6f434c@mail.ru> Date: Thu, 8 Jul 2010 15:31:59 +0000 Subject: [PATCH] Implementing a fix allowing deepOverride without changing dependency-tree-leaf packages svn path=/nixpkgs/trunk/; revision=22533 --- pkgs/development/libraries/zlib/default.nix | 2 +- pkgs/lib/attrsets.nix | 5 +++++ pkgs/lib/customisation.nix | 3 +-- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/pkgs/development/libraries/zlib/default.nix b/pkgs/development/libraries/zlib/default.nix index 94a425aaf1d4..95c891e9bc7a 100644 --- a/pkgs/development/libraries/zlib/default.nix +++ b/pkgs/development/libraries/zlib/default.nix @@ -1,4 +1,4 @@ -{stdenv, fetchurl, static ? false, ...}: +{stdenv, fetchurl, static ? false}: stdenv.mkDerivation { name = "zlib-1.2.3"; diff --git a/pkgs/lib/attrsets.nix b/pkgs/lib/attrsets.nix index c19033682919..f39b46db6213 100644 --- a/pkgs/lib/attrsets.nix +++ b/pkgs/lib/attrsets.nix @@ -270,4 +270,9 @@ rec { else eqStrict pat val ) [pattern attrs])); + # override only the attributes that are already present in the old set + # useful for deep-overriding + overrideExisting = old: new: + old // listToAttrs (map (attr: nameValuePair attr (attrByPath [attr] (getAttr attr old) new)) (attrNames old)); + } diff --git a/pkgs/lib/customisation.nix b/pkgs/lib/customisation.nix index 177856e4d0ef..41af26edae70 100644 --- a/pkgs/lib/customisation.nix +++ b/pkgs/lib/customisation.nix @@ -53,11 +53,10 @@ rec { { override = newArgs: makeOverridable f (origArgs // (if builtins.isFunction newArgs then newArgs origArgs else newArgs)); deepOverride = newArgs: - makeOverridable f ((lib.mapAttrs (deepOverrider newArgs) origArgs) // newArgs); + makeOverridable f (lib.overrideExisting (lib.mapAttrs (deepOverrider newArgs) origArgs) newArgs); origArgs = origArgs; }; - 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