mirror of
https://github.com/NixOS/nixpkgs.git
synced 2025-06-11 12:15:34 +03:00
* Move makeOverridable out of all-packages.nix.
svn path=/nixpkgs/trunk/; revision=18469
This commit is contained in:
parent
519e7870b6
commit
81c5c44ddb
2 changed files with 25 additions and 21 deletions
|
@ -1,11 +1,13 @@
|
||||||
{
|
let lib = import ./default.nix; in
|
||||||
|
|
||||||
|
rec {
|
||||||
|
|
||||||
|
|
||||||
/* `overrideDerivation drv f' takes a derivation (i.e., the result
|
/* `overrideDerivation drv f' takes a derivation (i.e., the result
|
||||||
of a call to the builtin function `derivation') and returns a new
|
of a call to the builtin function `derivation') and returns a new
|
||||||
derivation in which the attributes of the original are overriden
|
derivation in which the attributes of the original are overriden
|
||||||
according to the function `f'. This function is called with the
|
according to the function `f'. The function `f' is called with
|
||||||
original derivation attributes.
|
the original derivation attributes.
|
||||||
|
|
||||||
`overrideDerivation' allows certain "ad-hoc" customisation
|
`overrideDerivation' allows certain "ad-hoc" customisation
|
||||||
scenarios (e.g. in ~/.nixpkgs/config.nix). For instance, if you
|
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;
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -125,7 +125,7 @@ let
|
||||||
|
|
||||||
inherit lib config getConfig;
|
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
|
# Applying this to an attribute set will cause nix-env to look
|
||||||
# inside the set for derivations.
|
# inside the set for derivations.
|
||||||
|
@ -157,23 +157,6 @@ let
|
||||||
|
|
||||||
stringsWithDeps = lib.stringsWithDeps;
|
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
|
### STANDARD ENVIRONMENT
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue