diff options
author | Eelco Dolstra <eelco.dolstra@logicblox.com> | 2009-11-19 17:30:21 +0000 |
---|---|---|
committer | Eelco Dolstra <eelco.dolstra@logicblox.com> | 2009-11-19 17:30:21 +0000 |
commit | 81c5c44ddb806eaec3c12088716db58e6f2e6b4f (patch) | |
tree | a37a2870b370ddc83348382940b64538125d9c74 /pkgs/lib/customisation.nix | |
parent | 519e7870b6b85262d3efc726f337bd0a4e8b8efa (diff) | |
download | nixpkgs-81c5c44ddb806eaec3c12088716db58e6f2e6b4f.tar nixpkgs-81c5c44ddb806eaec3c12088716db58e6f2e6b4f.tar.gz nixpkgs-81c5c44ddb806eaec3c12088716db58e6f2e6b4f.tar.bz2 nixpkgs-81c5c44ddb806eaec3c12088716db58e6f2e6b4f.tar.lz nixpkgs-81c5c44ddb806eaec3c12088716db58e6f2e6b4f.tar.xz nixpkgs-81c5c44ddb806eaec3c12088716db58e6f2e6b4f.tar.zst nixpkgs-81c5c44ddb806eaec3c12088716db58e6f2e6b4f.zip |
* Move makeOverridable out of all-packages.nix.
svn path=/nixpkgs/trunk/; revision=18469
Diffstat (limited to 'pkgs/lib/customisation.nix')
-rw-r--r-- | pkgs/lib/customisation.nix | 27 |
1 files changed, 24 insertions, 3 deletions
diff --git a/pkgs/lib/customisation.nix b/pkgs/lib/customisation.nix index 889ce04547f..76d019a73c2 100644 --- a/pkgs/lib/customisation.nix +++ b/pkgs/lib/customisation.nix @@ -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; + + } |