[Nix-dev] [PATCH] t/deepFunCleanup
Marc Weber
marco-oweber at gmx.de
Wed Oct 6 10:16:22 CEST 2010
removing deepOverride. The replacement pkgsFunDeepOverride doesn't suffer from
- maybe overriding args which are named the same way by accident
- because it forced adding , ...) to some packages
which "weakens the precision of the function interface definitios"
(quoting Eelco Dolsta)
Signed-off-by: Marc Weber <marco-oweber at gmx.de>
---
pkgs/lib/customisation.nix | 32 ++------------------------------
pkgs/lib/misc.nix | 1 -
pkgs/servers/pulseaudio/default.nix | 2 +-
pkgs/top-level/all-packages.nix | 27 ++++++++++++++++++---------
4 files changed, 21 insertions(+), 41 deletions(-)
diff --git a/pkgs/lib/customisation.nix b/pkgs/lib/customisation.nix
index f97b494..5fb730b 100644
--- a/pkgs/lib/customisation.nix
+++ b/pkgs/lib/customisation.nix
@@ -34,7 +34,7 @@ rec {
overrideDerivation = drv: f:
let
# Filter out special attributes.
- drop = ["meta" "passthru" "outPath" "drvPath" "hostDrv" "buildDrv" "type" "override" "deepOverride" "origArgs"]
+ drop = ["meta" "passthru" "outPath" "drvPath" "hostDrv" "buildDrv" "type" "override" "origArgs"]
# also drop functions such as .merge .override etc
++ lib.filter (n: isFunction (getAttr n drv)) (attrNames drv);
attrs = removeAttrs drv drop;
@@ -56,38 +56,10 @@ rec {
if builtins.isAttrs ff then (ff //
{ 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);
+ origArgs = origArgs;
})
else ff;
- 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
- x) else x;
-
-
- /* Call the package function in the file `fn' with the required
- arguments automatically. The function is called with the
- arguments `args', but any missing arguments are obtained from
- `autoArgs'. This function is intended to be partially
- parameterised, e.g.,
-
- callPackage = callPackageWith pkgs;
- pkgs = {
- libfoo = callPackage ./foo.nix { };
- libbar = callPackage ./bar.nix { };
- };
-
- If the `libbar' function expects an argument named `libfoo', it is
- automatically passed as an argument. Overrides or missing
- arguments can be supplied in `args', e.g.
-
- libbar = callPackage ./bar.nix {
- libfoo = null;
- enableX11 = true;
- };
- */
callPackageWith = autoArgs: fn: args:
let f = import fn; in
makeOverridable f ((builtins.intersectAttrs (builtins.functionArgs f) autoArgs) // args);
diff --git a/pkgs/lib/misc.nix b/pkgs/lib/misc.nix
index 91a3749..dec03f7 100644
--- a/pkgs/lib/misc.nix
+++ b/pkgs/lib/misc.nix
@@ -29,7 +29,6 @@ rec {
} ));
withStdOverrides = base // {
override = base.passthru.function;
- deepOverride = a : (base.passthru.function ((lib.mapAttrs (lib.deepOverrider a) base.passthru.args) // a));
} ;
in
withStdOverrides;
diff --git a/pkgs/servers/pulseaudio/default.nix b/pkgs/servers/pulseaudio/default.nix
index 40af620..a56afc1 100644
--- a/pkgs/servers/pulseaudio/default.nix
+++ b/pkgs/servers/pulseaudio/default.nix
@@ -1,7 +1,7 @@
{ stdenv, fetchurl, pkgconfig, gnum4, gdbm, libtool, glib, dbus, avahi
, gconf, liboil, gtk, libX11, libICE, libSM, libXtst, libXi, intltool, gettext
, libcap, alsaLib, libsamplerate, libsndfile, speex, bluez, udev
-, ...}:
+}:
stdenv.mkDerivation rec {
name = "pulseaudio-0.9.21";
diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix
index 5c45304..5bd71bb 100644
--- a/pkgs/top-level/all-packages.nix
+++ b/pkgs/top-level/all-packages.nix
@@ -116,7 +116,14 @@ let
# The package compositions. Yes, this isn't properly indented.
pkgsFun = pkgs: __overrides:
with helperFunctions;
- let defaultScope = pkgs // pkgs.xorg; in
+ let defaultScope = pkgs // pkgs.xorg;
+
+ # provide deepOverride function which overrides everything by
+ # pkgsDeepOverride before overridding with overrider.
+ # See webkit example - updated implementation of
+ # http://wiki.nixos.org/w/index.php?title=Escape_from_dependency_hell
+ deepOverride = deepOverrides: pkgsFun pkgs (deepOverrides // __overrides);
+ in
helperFunctions // rec {
# `__overrides' is a magic attribute that causes the attributes in
@@ -3856,19 +3863,21 @@ let
vxl = callPackage ../development/libraries/vxl { };
- webkit = ((builderDefsPackage ../development/libraries/webkit {
- inherit (gnome28) gtkdoc libsoup;
- inherit (gtkLibs) gtk atk pango glib;
- inherit freetype fontconfig gettext gperf curl
+ webkit =
+ let p = deepOverride {libsoup = gnome28.libsoup_2_31;};
+ in builderDefsPackage ../development/libraries/webkit {
+ inherit (p.gnome28) gtkdoc libsoup;
+ inherit (p.gtkLibs) gtk atk pango glib;
+ inherit (p) freetype fontconfig gettext gperf curl
libjpeg libtiff libpng libxml2 libxslt sqlite
icu cairo perl intltool automake libtool
pkgconfig autoconf bison libproxy enchant
python ruby;
- inherit (gst_all) gstreamer gstPluginsBase gstFfmpeg
+ inherit (p.gst_all) gstreamer gstPluginsBase gstFfmpeg
gstPluginsGood;
- flex = flex2535;
- inherit (xlibs) libXt;
- }).deepOverride {libsoup = gnome28.libsoup_2_31;});
+ flex = p.flex2535;
+ inherit (p.xlibs) libXt;
+ };
wvstreams = callPackage ../development/libraries/wvstreams { };
--
1.7.2.1
More information about the nix-dev
mailing list