Skip to content

Commit

Permalink
* Add callPackage etc.
Browse files Browse the repository at this point in the history
svn path=/nixpkgs/trunk/; revision=22876
  • Loading branch information
edolstra committed Aug 2, 2010
1 parent 9ef0f1b commit fd268b4
Show file tree
Hide file tree
Showing 3 changed files with 96 additions and 61 deletions.
29 changes: 27 additions & 2 deletions pkgs/lib/customisation.nix
Expand Up @@ -61,6 +61,31 @@ rec {
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);

}
13 changes: 7 additions & 6 deletions pkgs/os-specific/linux/ndiswrapper/default.nix
@@ -1,4 +1,5 @@
args: with args;
{ stdenv, fetchurl, kernel, perl }:

stdenv.mkDerivation {
name = "ndiswrapper-1.53-stable";

Expand All @@ -21,19 +22,19 @@ stdenv.mkDerivation {
'';

# should we use unstable?
src = args.fetchurl {
src = fetchurl {
url = http://downloads.sourceforge.net/ndiswrapper/ndiswrapper-1.53.tar.gz;
sha256 = "00622nxa3q9n8v7qdz274d0nzz9r13lx77xi27s5bnk0mkila03q";
};

buildInputs =[kernel perl];
buildInputs = [ kernel perl ];

# this is a patch against svn head, not stable version
patches = [./prefix.patch];

meta = {
description = "Ndis driver wrapper for the Linux kernel";
homepage = http://sourceforge.net/projects/ndiswrapper;
license = "GPL";
description = "Ndis driver wrapper for the Linux kernel";
homepage = http://sourceforge.net/projects/ndiswrapper;
license = "GPL";
};
}
115 changes: 62 additions & 53 deletions pkgs/top-level/all-packages.nix
Expand Up @@ -99,6 +99,17 @@ let
pkgs = pkgsFun __overrides; # the overriden, final packages


# We use `callPackage' to be able to omit function arguments that
# can be obtained from `pkgs' or `pkgs.xorg' (i.e. `defaultScope').
# Use `newScope' for sets of packages in `pkgs' (see e.g. `gtkLibs'
# below).
callPackage = newScope {};

newScope = extra: lib.callPackageWith (defaultScope // extra);

defaultScope = pkgs // pkgs.xorg;


# The package compositions. Yes, this isn't properly indented.
pkgsFun = __overrides: with helperFunctions; helperFunctions // rec {

Expand Down Expand Up @@ -1168,33 +1179,31 @@ let
inherit stdenv fetchgit libuuid lzo zlib acl;
};

multitran = recurseIntoAttrs (let
inherit fetchurl stdenv help2man;
in rec {
multitrandata = import ../tools/text/multitran/data {
inherit fetchurl stdenv;
};
multitran = recurseIntoAttrs (let callPackage = newScope pkgs.multitran; in rec {
multitrandata = import ../tools/text/multitran/data {
inherit fetchurl stdenv;
};

libbtree = import ../tools/text/multitran/libbtree {
inherit fetchurl stdenv;
};
libbtree = import ../tools/text/multitran/libbtree {
inherit fetchurl stdenv;
};

libmtsupport = import ../tools/text/multitran/libmtsupport {
inherit fetchurl stdenv;
};
libmtsupport = import ../tools/text/multitran/libmtsupport {
inherit fetchurl stdenv;
};

libfacet = import ../tools/text/multitran/libfacet {
inherit fetchurl stdenv libmtsupport;
};
libfacet = import ../tools/text/multitran/libfacet {
inherit fetchurl stdenv libmtsupport;
};

libmtquery = import ../tools/text/multitran/libmtquery {
inherit fetchurl stdenv libmtsupport libfacet libbtree multitrandata;
};
libmtquery = import ../tools/text/multitran/libmtquery {
inherit fetchurl stdenv libmtsupport libfacet libbtree multitrandata;
};

mtutils = import ../tools/text/multitran/mtutils {
inherit fetchurl stdenv libmtsupport libfacet libbtree libmtquery help2man;
};
});
mtutils = import ../tools/text/multitran/mtutils {
inherit fetchurl stdenv libmtsupport libfacet libbtree libmtquery help2man;
};
});

muscleframework = import ../tools/security/muscleframework {
inherit fetchurl stdenv libmusclecard pkgconfig pcsclite;
Expand Down Expand Up @@ -4217,11 +4226,11 @@ let
inherit (gnome) gtk;
};

gtkLibs = recurseIntoAttrs gtkLibs220;
gtkLibs = gtkLibs220;

glib = gtkLibs.glib;

gtkLibs1x = rec {
gtkLibs1x = recurseIntoAttrs (let callPackage = newScope pkgs.gtkLibs1x; in rec {

glib = import ../development/libraries/glib/1.2.x.nix {
inherit fetchurl stdenv;
Expand All @@ -4231,9 +4240,9 @@ let
inherit fetchurl stdenv x11 glib;
};

};
});

gtkLibs216 = rec {
gtkLibs216 = recurseIntoAttrs (let callPackage = newScope pkgs.gtkLibs216; in rec {

glib = import ../development/libraries/glib/2.20.x.nix {
inherit fetchurl stdenv pkgconfig gettext perl;
Expand Down Expand Up @@ -4264,13 +4273,13 @@ let
inherit fetchurl stdenv pkgconfig gtk atk glibmm cairomm pangomm;
};

};
});

gtkLibs218 = rec {
gtkLibs218 = recurseIntoAttrs (let callPackage = newScope pkgs.gtkLibs218; in rec {

glib = import ../development/libraries/glib/2.22.x.nix {
inherit fetchurl stdenv pkgconfig gettext perl;
libiconv = if (stdenv.system == "i686-freebsd") then libiconv else null;
libiconv = if stdenv.system == "i686-freebsd" then libiconv else null;
};

glibmm = import ../development/libraries/glibmm/2.22.x.nix {
Expand Down Expand Up @@ -4298,13 +4307,13 @@ let
inherit fetchurl stdenv pkgconfig gtk atk glibmm cairomm pangomm;
};

};
});

gtkLibs220 = rec {
gtkLibs220 = recurseIntoAttrs (let callPackage = newScope pkgs.gtkLibs220; in rec {

glib = makeOverridable (import ../development/libraries/glib/2.24.x.nix) {
inherit fetchurl stdenv pkgconfig gettext perl zlib;
libiconv = if (stdenv.system == "i686-freebsd") then libiconv else null;
libiconv = if stdenv.system == "i686-freebsd" then libiconv else null;
};

glibmm = import ../development/libraries/glibmm/2.22.x.nix {
Expand Down Expand Up @@ -4332,7 +4341,7 @@ let
inherit fetchurl stdenv pkgconfig gtk atk glibmm cairomm pangomm;
};

};
});

gtkmozembedsharp = import ../development/libraries/gtkmozembed-sharp {
inherit fetchurl stdenv mono pkgconfig monoDLLFixer;
Expand Down Expand Up @@ -6603,7 +6612,7 @@ let
for a specific kernel. This function can then be called for
whatever kernel you're using. */

linuxPackagesFor = kernel: rec {
linuxPackagesFor = kernel: self: let callPackage = newScope self; in rec {

inherit kernel;

Expand All @@ -6617,6 +6626,14 @@ let
inherit fetchurl stdenv kernel;
};

aufs2 = import ../os-specific/linux/aufs2 {
inherit fetchurl stdenv kernel perl;
};

aufs2_util = import ../os-specific/linux/aufs2-util {
inherit fetchurl stdenv kernel aufs2;
};

blcr = import ../os-specific/linux/blcr/0.8.2.nix {
inherit fetchurl stdenv kernel perl makeWrapper autoconf automake;
libtool = libtool_1_5; # libtool 2 causes a fork bomb
Expand Down Expand Up @@ -6722,31 +6739,23 @@ let
inherit stdenv fetchurl lib patchelf cdrkit kernel;
inherit (xlibs) libX11 libXt libXext libXmu libXcomposite libXfixes;
};
} // (if kernel.features ? aufsBase then rec {
aufs2 = import ../os-specific/linux/aufs2 {
inherit fetchurl stdenv kernel perl;
};

aufs2_util = import ../os-specific/linux/aufs2-util {
inherit fetchurl stdenv kernel aufs2;
};
} else {});
};

# Build the kernel modules for the some of the kernels.
linuxPackages_2_6_25 = recurseIntoAttrs (linuxPackagesFor linux_2_6_25);
linuxPackages_2_6_27 = recurseIntoAttrs (linuxPackagesFor linux_2_6_27);
linuxPackages_2_6_28 = recurseIntoAttrs (linuxPackagesFor linux_2_6_28);
linuxPackages_2_6_29 = recurseIntoAttrs (linuxPackagesFor linux_2_6_29);
linuxPackages_2_6_31 = recurseIntoAttrs (linuxPackagesFor linux_2_6_31);
linuxPackages_2_6_32 = recurseIntoAttrs (linuxPackagesFor linux_2_6_32);
linuxPackages_2_6_25 = recurseIntoAttrs (linuxPackagesFor linux_2_6_25 pkgs.linuxPackages_2_6_25);
linuxPackages_2_6_27 = recurseIntoAttrs (linuxPackagesFor linux_2_6_27 pkgs.linuxPackages_2_6_27);
linuxPackages_2_6_28 = recurseIntoAttrs (linuxPackagesFor linux_2_6_28 pkgs.linuxPackages_2_6_28);
linuxPackages_2_6_29 = recurseIntoAttrs (linuxPackagesFor linux_2_6_29 pkgs.linuxPackages_2_6_29);
linuxPackages_2_6_31 = recurseIntoAttrs (linuxPackagesFor linux_2_6_31 pkgs.linuxPackages_2_6_31);
linuxPackages_2_6_32 = recurseIntoAttrs (linuxPackagesFor linux_2_6_32 pkgs.linuxPackages_2_6_32);
linuxPackages_2_6_32_systemtap =
recurseIntoAttrs (linuxPackagesFor linux_2_6_32_systemtap);
linuxPackages_2_6_33 = recurseIntoAttrs (linuxPackagesFor linux_2_6_33);
linuxPackages_2_6_34 = recurseIntoAttrs (linuxPackagesFor linux_2_6_34);
recurseIntoAttrs (linuxPackagesFor linux_2_6_32_systemtap pkgs.linuxPackages_2_6_32_systemtap);
linuxPackages_2_6_33 = recurseIntoAttrs (linuxPackagesFor linux_2_6_33 pkgs.linuxPackages_2_6_33);
linuxPackages_2_6_34 = recurseIntoAttrs (linuxPackagesFor linux_2_6_34 pkgs.linuxPackages_2_6_34);

# The current default kernel / kernel modules.
linux = linux_2_6_32;
linuxPackages = linuxPackagesFor linux;
linuxPackages = linuxPackages_2_6_32;

keyutils = import ../os-specific/linux/keyutils {
inherit fetchurl stdenv;
Expand Down

1 comment on commit fd268b4

@nixos-discourse
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This commit has been mentioned on NixOS Discourse. There might be relevant details there:

https://discourse.nixos.org/t/where-is-callpackage-defined-exactly-part-2/12524/2

Please sign in to comment.