make makeOverridable noop for functions like a: b: c(a, b)

svn path=/nixpkgs/trunk/; revision=23262
This commit is contained in:
Yury G. Kudryashov 2010-08-19 22:52:53 +00:00
parent e16427a899
commit 9e4202d273
1 changed files with 11 additions and 7 deletions

View File

@ -49,13 +49,17 @@ rec {
# let d = makeOverridable stdenv.mkDerivation { name = ..; buildInputs; } # let d = makeOverridable stdenv.mkDerivation { name = ..; buildInputs; }
# noBuildInputs = d.override { buildInputs = []; } # noBuildInputs = d.override { buildInputs = []; }
# additionalBuildInputs = d.override ( args : args // { buildInputs = args.buildInputs ++ [ additional ]; } ) # additionalBuildInputs = d.override ( args : args // { buildInputs = args.buildInputs ++ [ additional ]; } )
makeOverridable = f: origArgs: f origArgs // makeOverridable = f: origArgs:
{ override = newArgs: let
makeOverridable f (origArgs // (if builtins.isFunction newArgs then newArgs origArgs else newArgs)); ff = f origArgs;
deepOverride = newArgs: in
makeOverridable f (lib.overrideExisting (lib.mapAttrs (deepOverrider newArgs) origArgs) newArgs); if builtins.isAttrs ff then (ff //
#origArgs = origArgs; { override = newArgs:
}; makeOverridable f (origArgs // (if builtins.isFunction newArgs then newArgs origArgs else newArgs));
deepOverride = newArgs:
makeOverridable f (lib.overrideExisting (lib.mapAttrs (deepOverrider newArgs) origArgs) newArgs);
})
else ff;
deepOverrider = newArgs: name: x: if builtins.isAttrs x then ( deepOverrider = newArgs: name: x: if builtins.isAttrs x then (
if x ? deepOverride then (x.deepOverride newArgs) else if x ? deepOverride then (x.deepOverride newArgs) else