3
0
Fork 0
forked from mirrors/nixpkgs

* Move makeOverridable out of all-packages.nix.

svn path=/nixpkgs/trunk/; revision=18469
This commit is contained in:
Eelco Dolstra 2009-11-19 17:30:21 +00:00
parent 519e7870b6
commit 81c5c44ddb
2 changed files with 25 additions and 21 deletions

View file

@ -1,11 +1,13 @@
{
let lib = import ./default.nix; in
rec {
/* `overrideDerivation drv f' takes a derivation (i.e., the result
of a call to the builtin function `derivation') and returns a new
derivation in which the attributes of the original are overriden
according to the function `f'. This function is called with the
original derivation attributes.
according to the function `f'. The function `f' is called with
the original derivation attributes.
`overrideDerivation' allows certain "ad-hoc" customisation
scenarios (e.g. in ~/.nixpkgs/config.nix). For instance, if you
@ -37,4 +39,23 @@
};
# 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: f origArgs //
{ override = newArgs:
makeOverridable f (origArgs // (if builtins.isFunction newArgs then newArgs origArgs else newArgs));
deepOverride = newArgs:
makeOverridable f ((lib.mapAttrs (deepOverride newArgs) origArgs) // newArgs);
origArgs = origArgs;
};
deepOverride = 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;
}

View file

@ -125,7 +125,7 @@ let
inherit lib config getConfig;
inherit (lib) lowPrio appendToName;
inherit (lib) lowPrio appendToName makeOverridable;
# Applying this to an attribute set will cause nix-env to look
# inside the set for derivations.
@ -157,23 +157,6 @@ let
stringsWithDeps = lib.stringsWithDeps;
deepOverride = 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;
# 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: f origArgs //
{ override = newArgs:
makeOverridable f (origArgs // (if builtins.isFunction newArgs then newArgs origArgs else newArgs));
deepOverride = newArgs:
makeOverridable f ((lib.mapAttrs (deepOverride newArgs) origArgs) // newArgs);
origArgs = origArgs;
};
### STANDARD ENVIRONMENT