From a1e834e85ade13317ed51853b600d5df5a870d50 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra <eelco.dolstra@logicblox.com> Date: Fri, 6 Aug 2010 10:34:34 +0000 Subject: [PATCH] * Get rid of the ugly `useFromStdenv' hack in all-packages.nix. Instead, use the generic package override mechanism to use packages from earlier bootstrap phases. * Don't rely on the existence of attributes such as `stdenv.coreutils'. svn path=/nixpkgs/trunk/; revision=22991 --- .../networking/browsers/chromium/default.nix | 2 +- .../virtualization/virtualbox/default.nix | 4 +- pkgs/development/compilers/go/default.nix | 6 +- pkgs/development/compilers/path64/default.nix | 4 +- pkgs/servers/mail/postfix/default.nix | 10 +- pkgs/servers/sql/virtuoso/default.nix | 5 +- pkgs/stdenv/generic/default.nix | 3 +- pkgs/stdenv/linux/default.nix | 23 ++- pkgs/stdenv/mingw/default.nix | 2 +- pkgs/tools/networking/dhcp/default.nix | 4 +- pkgs/top-level/all-packages.nix | 138 +++++------------- 11 files changed, 73 insertions(+), 128 deletions(-) diff --git a/pkgs/applications/networking/browsers/chromium/default.nix b/pkgs/applications/networking/browsers/chromium/default.nix index dbb20dc4fd9e..bbe51bd1dada 100644 --- a/pkgs/applications/networking/browsers/chromium/default.nix +++ b/pkgs/applications/networking/browsers/chromium/default.nix @@ -55,7 +55,7 @@ stdenv.mkDerivation rec { libPath = stdenv.lib.makeLibraryPath - [ stdenv.glibc stdenv.gcc.gcc ffmpeg cairo pango glib libXrender gtk nspr nss fontconfig freetype alsaLib libX11 GConf libXext atk libXt expat zlib libjpeg bzip2 libpng libXScrnSaver dbus dbus_glib cups libgcrypt] ; + [ stdenv.gcc.libc stdenv.gcc.gcc ffmpeg cairo pango glib libXrender gtk nspr nss fontconfig freetype alsaLib libX11 GConf libXext atk libXt expat zlib libjpeg bzip2 libpng libXScrnSaver dbus dbus_glib cups libgcrypt] ; installPhase = '' ensureDir $out/bin diff --git a/pkgs/applications/virtualization/virtualbox/default.nix b/pkgs/applications/virtualization/virtualbox/default.nix index d1b4838491dc..d03e30c6603e 100644 --- a/pkgs/applications/virtualization/virtualbox/default.nix +++ b/pkgs/applications/virtualization/virtualbox/default.nix @@ -1,6 +1,6 @@ { stdenv, fetchurl, lib, iasl, dev86, libxslt, libxml2, libX11, xproto, libXext , libXcursor, qt4, libIDL, SDL, hal, libcap, zlib, libpng, glib, kernel -, python, which, alsaLib, curl +, python, which, alsaLib, curl, gawk }: stdenv.mkDerivation { @@ -72,7 +72,7 @@ stdenv.mkDerivation { sed -i -e "s|@INSTALL_PATH@|$out/virtualbox|" \ -e "s|@QT4_PATH@|${qt4}/lib|" \ -e "s|which|${which}/bin/which|" \ - -e "s|awk|${stdenv.gawk}/bin/awk|" \ + -e "s|awk|${gawk}/bin/awk|" \ $out/bin/VBox.sh chmod 755 $out/bin/VBox.sh for file in VirtualBox VBoxManage VBoxSDL diff --git a/pkgs/development/compilers/go/default.nix b/pkgs/development/compilers/go/default.nix index e62934ecbe1a..3f2c32748221 100644 --- a/pkgs/development/compilers/go/default.nix +++ b/pkgs/development/compilers/go/default.nix @@ -1,4 +1,4 @@ -{stdenv, fetchhg, bison, glibc, ed, which, bash, makeWrapper, perl, ...}: +{ stdenv, fetchhg, bison, glibc, ed, which, bash, coreutils, makeWrapper, perl }: let version = "2010-06-09"; @@ -29,8 +29,8 @@ stdenv.mkDerivation { sed -i 's,/usr/share/zoneinfo/,${glibc}/share/zoneinfo/,' src/pkg/time/zoneinfo.go sed -i 's,/bin/ed,${ed}/bin/ed,' src/cmd/6l/mkenam - sed -i -e 's,/bin/cat,${stdenv.coreutils}/bin/cat,' \ - -e 's,/bin/echo,${stdenv.coreutils}/bin/echo,' \ + sed -i -e 's,/bin/cat,${coreutils}/bin/cat,' \ + -e 's,/bin/echo,${coreutils}/bin/echo,' \ src/pkg/exec/exec_test.go # Disabling the 'os/http/net' tests (they want files not available in diff --git a/pkgs/development/compilers/path64/default.nix b/pkgs/development/compilers/path64/default.nix index f99806c7d205..9cc31537558d 100644 --- a/pkgs/development/compilers/path64/default.nix +++ b/pkgs/development/compilers/path64/default.nix @@ -13,7 +13,7 @@ stdenv.mkDerivation { patchPhase = '' sed -i s,/usr/bin/ld,$(type -P ld), src/driver/phases.c - sed -i s,/lib64/ld-linux-x86-64.so.2,${stdenv.glibc}/lib/ld-linux-x86-64.so.2, src/include/main_defs.h.in + sed -i s,/lib64/ld-linux-x86-64.so.2,${stdenv.gcc.libc}/lib/ld-linux-x86-64.so.2, src/include/main_defs.h.in ''; cmakeFlags = '' @@ -22,7 +22,7 @@ stdenv.mkDerivation { -DPATH64_ENABLE_PSCRUNTIME=OFF -DPATH64_ENABLE_PROFILING=OFF -DPATH64_ENABLE_TARGETS=x8664 -DCMAKE_BUILD_TYPE=Debug -DPATH64_ENABLE_FORTRAN=OFF - -DPSC_CRT_PATH=${stdenv.glibc}/lib + -DPSC_CRT_PATH=${stdenv.gcc.libc}/lib ''; makeFlags = "-j4"; diff --git a/pkgs/servers/mail/postfix/default.nix b/pkgs/servers/mail/postfix/default.nix index 2a39571a8ff0..acd3342775f0 100644 --- a/pkgs/servers/mail/postfix/default.nix +++ b/pkgs/servers/mail/postfix/default.nix @@ -1,6 +1,8 @@ -{stdenv, fetchurl, db4, glibc, openssl, cyrus_sasl}: +{ stdenv, fetchurl, db4, glibc, openssl, cyrus_sasl +, coreutils, findutils, gnused, gnugrep +}: -assert stdenv.isLinux && stdenv ? coreutils; +assert stdenv.isLinux; stdenv.mkDerivation { name = "postfix-2.2.11"; @@ -24,8 +26,8 @@ stdenv.mkDerivation { mkdir $out/share/postfix/conf cp conf/* $out/share/postfix/conf - sed -e 's@PATH=.*@PATH=${stdenv.coreutils}/bin:${stdenv.findutils}/bin:${stdenv.gnused}/bin:${stdenv.gnugrep}/bin:$out/sbin@' -i $out/share/postfix/conf/post-install - sed -e '2aPATH=${stdenv.coreutils}/bin:${stdenv.findutils}/bin:${stdenv.gnused}/bin:${stdenv.gnugrep}/bin:$out/sbin' -i $out/share/postfix/conf/postfix-script + sed -e 's@PATH=.*@PATH=${coreutils}/bin:${findutils}/bin:${gnused}/bin:${gnugrep}/bin:$out/sbin@' -i $out/share/postfix/conf/post-install + sed -e '2aPATH=${coreutils}/bin:${findutils}/bin:${gnused}/bin:${gnugrep}/bin:$out/sbin' -i $out/share/postfix/conf/postfix-script chmod a+x $out/share/postfix/conf/{postfix-script,post-install} ''; diff --git a/pkgs/servers/sql/virtuoso/default.nix b/pkgs/servers/sql/virtuoso/default.nix index 346b63bafe52..b302dc697142 100644 --- a/pkgs/servers/sql/virtuoso/default.nix +++ b/pkgs/servers/sql/virtuoso/default.nix @@ -1,7 +1,5 @@ { stdenv, fetchurl, libxml2, openssl, readline, gawk }: -assert stdenv ? gawk || gawk != null; - stdenv.mkDerivation rec { name = "virtuoso-opensource-6.1.1"; @@ -10,8 +8,7 @@ stdenv.mkDerivation rec { sha256 = "1sd70j9i26ml16lig9r9lmrdf5q0kybq71r6vzzzc5v5jxjz0l7w"; }; - buildInputs = [ libxml2 openssl readline ] - ++ stdenv.lib.optional (! stdenv ? gawk) gawk; + buildInputs = [ libxml2 openssl readline gawk ]; CPP="${stdenv.gcc}/bin/gcc -E"; diff --git a/pkgs/stdenv/generic/default.nix b/pkgs/stdenv/generic/default.nix index 4b988ef524a8..585bb2f7fe17 100644 --- a/pkgs/stdenv/generic/default.nix +++ b/pkgs/stdenv/generic/default.nix @@ -1,6 +1,6 @@ { system, name, preHook ? null, postHook ? null, initialPath, gcc, shell , param1 ? "", param2 ? "", param3 ? "", param4 ? "", param5 ? "" -, extraAttrs ? {} +, extraAttrs ? {}, overrides ? {} , # The `fetchurl' to use for downloading curl and its dependencies # (see all-packages.nix). @@ -118,6 +118,7 @@ let inherit fetchurlBoot; + inherit overrides; } # Propagate any extra attributes. For instance, we use this to diff --git a/pkgs/stdenv/linux/default.nix b/pkgs/stdenv/linux/default.nix index dd5647bec456..71aee5912e7f 100644 --- a/pkgs/stdenv/linux/default.nix +++ b/pkgs/stdenv/linux/default.nix @@ -73,7 +73,7 @@ rec { # This function builds the various standard environments used during # the bootstrap. stdenvBootFun = - {gcc, extraAttrs ? {}, extraPath ? [], fetchurl}: + {gcc, extraAttrs ? {}, overrides ? {}, extraPath ? [], fetchurl}: import ../generic { inherit system; @@ -89,8 +89,10 @@ rec { shell = "${bootstrapTools}/bin/sh"; initialPath = [bootstrapTools] ++ extraPath; fetchurlBoot = fetchurl; - inherit gcc; - extraAttrs = extraAttrs // {inherit fetchurl;}; + inherit gcc extraAttrs; + overrides = overrides // { + inherit fetchurl; + }; }; # Build a dummy stdenv with no GCC or working fetchurl. This is @@ -168,7 +170,7 @@ rec { coreutils = bootstrapTools; libc = stdenvLinuxGlibc; }; - extraAttrs = { + overrides = { glibc = stdenvLinuxGlibc; inherit (stdenvLinuxBoot1Pkgs) perl; }; @@ -195,7 +197,7 @@ rec { gcc = stdenvLinuxBoot2Pkgs.gcc.gcc; name = ""; }; - extraAttrs = { + overrides = { inherit (stdenvLinuxBoot1Pkgs) perl; }; inherit fetchurl; @@ -215,7 +217,7 @@ rec { # # When updating stdenvLinux, make sure that the result has no # dependency (`nix-store -qR') on bootstrapTools. - stdenvLinux = import ../generic { + stdenvLinux = import ../generic rec { name = "stdenv-linux"; inherit system; @@ -240,10 +242,15 @@ rec { fetchurlBoot = fetchurl; extraAttrs = { - inherit (stdenvLinuxBoot2Pkgs) binutils /* gcc */ glibc; + inherit (stdenvLinuxBoot2Pkgs) glibc; + }; + + overrides = { + inherit gcc; + inherit (stdenvLinuxBoot2Pkgs) binutils glibc; inherit (stdenvLinuxBoot3Pkgs) gzip bzip2 bash coreutils diffutils findutils gawk - gnumake gnused gnutar gnugrep patch patchelf + gnumake gnused gnutar gnugrep gnupatch patchelf attr acl; }; }; diff --git a/pkgs/stdenv/mingw/default.nix b/pkgs/stdenv/mingw/default.nix index bedf3986d170..71c974cfad85 100644 --- a/pkgs/stdenv/mingw/default.nix +++ b/pkgs/stdenv/mingw/default.nix @@ -62,7 +62,7 @@ let { body = stdenv // mkDerivationFun // { inherit fetchurl; - pkgconfig = pkgconfigBin; + overrides.pkgconfig = pkgconfigBin; }; shell = diff --git a/pkgs/tools/networking/dhcp/default.nix b/pkgs/tools/networking/dhcp/default.nix index 49a2de6e08f9..67997c700e99 100644 --- a/pkgs/tools/networking/dhcp/default.nix +++ b/pkgs/tools/networking/dhcp/default.nix @@ -1,4 +1,4 @@ -{ stdenv, fetchurl, nettools, iputils, iproute, makeWrapper }: +{ stdenv, fetchurl, nettools, iputils, iproute, makeWrapper, coreutils, gnused }: stdenv.mkDerivation rec { name = "dhcp-4.1.1-P1"; @@ -32,7 +32,7 @@ stdenv.mkDerivation rec { substituteInPlace $out/sbin/dhclient-script \ --replace /sbin/ip ${iproute}/sbin/ip wrapProgram "$out/sbin/dhclient-script" --prefix PATH : \ - "${nettools}/bin:${nettools}/sbin:${iputils}/bin:${stdenv.coreutils}/bin:${stdenv.gnused}/bin" + "${nettools}/bin:${nettools}/sbin:${iputils}/bin:${coreutils}/bin:${gnused}/bin" ''; preConfigure = diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 9926bf5e6841..b7474fd98507 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -93,10 +93,11 @@ let # (un-overriden) set of packages, allowing packageOverrides # attributes to refer to the original attributes (e.g. "foo = # ... pkgs.foo ..."). - __overrides = (getConfig ["packageOverrides"] (pkgs: {})) pkgsOrig; + overrides = (getConfig ["packageOverrides"] (pkgs: {})) pkgsOrig // + (if pkgsOrig.stdenv ? overrides then pkgsOrig.stdenv.overrides else { }); pkgsOrig = pkgsFun {}; # the un-overriden packages, passed to packageOverrides - pkgs = pkgsFun __overrides; # the overriden, final packages + pkgs = pkgsFun overrides; # the overriden, final packages # We use `callPackage' to be able to omit function arguments that @@ -113,6 +114,7 @@ let # The package compositions. Yes, this isn't properly indented. pkgsFun = __overrides: with helperFunctions; helperFunctions // rec { + # Override system. This is useful to build i686 packages on x86_64-linux. forceSystem = system: (import ./all-packages.nix) { inherit system; @@ -152,10 +154,6 @@ let # inside the set for derivations. recurseIntoAttrs = attrs: attrs // {recurseForDerivations = true;}; - useFromStdenv = it : alternative : if ((bootStdenv != null || - crossSystem == null) && builtins.hasAttr it stdenv) then - (builtins.getAttr it stdenv) else alternative; - # Return the first available value in the order: pkg.val, val, or default. getPkgConfig = pkg : val : default : (getConfig [ pkg val ] (getConfig [ val ] default)); @@ -265,15 +263,10 @@ let inherit stdenv mercurial nix; }; - # `fetchurl' downloads a file from the network. The `useFromStdenv' - # is there to allow stdenv to determine fetchurl. Used during the - # stdenv-linux bootstrap phases to prevent lots of different curls - # from being built. - fetchurl = useFromStdenv "fetchurl" - (import ../build-support/fetchurl { - curl = curl; - stdenv = stdenv; - }); + # `fetchurl' downloads a file from the network. + fetchurl = import ../build-support/fetchurl { + inherit curl stdenv; + }; # fetchurlBoot is used for curl and its dependencies in order to # prevent a cyclic dependency (curl depends on curl.tar.bz2, @@ -428,10 +421,7 @@ let bsdiff = callPackage ../tools/compression/bsdiff { }; - bzip2 = useFromStdenv "bzip2" - (import ../tools/compression/bzip2 { - inherit fetchurl stdenv; - }); + bzip2 = callPackage ../tools/compression/bzip2 { }; cabextract = callPackage ../tools/archivers/cabextract { }; @@ -469,18 +459,14 @@ let convmv = callPackage ../tools/misc/convmv { }; - coreutils_real = makeOverridable (if stdenv ? isDietLibC - then import ../tools/misc/coreutils-5 - else import ../tools/misc/coreutils) + coreutils = callPackage (if stdenv ? isDietLibC + then ../tools/misc/coreutils-5 + else ../tools/misc/coreutils) { - inherit fetchurl stdenv acl perl gmp; - # TODO: Add ACL support for cross-Linux. - aclSupport = (crossSystem == null) && stdenv.isLinux; + aclSupport = crossSystem == null && stdenv.isLinux; }; - coreutils = useFromStdenv "coreutils" coreutils_real; - cpio = callPackage ../tools/archivers/cpio { }; cromfs = callPackage ../tools/archivers/cromfs { }; @@ -529,10 +515,7 @@ let diffstat = callPackage ../tools/text/diffstat { }; - diffutils = useFromStdenv "diffutils" - (import ../tools/text/diffutils { - inherit fetchurl stdenv coreutils; - }); + diffutils = callPackage ../tools/text/diffutils { }; dirmngr = callPackage ../tools/security/dirmngr { }; @@ -590,12 +573,10 @@ let file = callPackage ../tools/misc/file { }; - findutils = useFromStdenv "findutils" - (if stdenv.isDarwin then findutils4227 else - import ../tools/misc/findutils { - inherit fetchurl stdenv coreutils; - } - ); + findutils = + if stdenv.isDarwin + then findutils4227 + else callPackage ../tools/misc/findutils { }; findutils4227 = callPackage ../tools/misc/findutils/4.2.27.nix { }; @@ -611,10 +592,7 @@ let unix2dos = callPackage ../tools/text/unix2dos { }; - gawk = useFromStdenv "gawk" - (import ../tools/text/gawk { - inherit fetchurl stdenv; - }); + gawk = callPackage ../tools/text/gawk { }; gdmap = callPackage ../tools/system/gdmap { inherit (gtkLibs216) gtk; @@ -645,14 +623,9 @@ let inherit (gtkLibs) glib; }; - gnugrep = useFromStdenv "gnugrep" - (import ../tools/text/gnugrep { - inherit fetchurl stdenv pcre; - }); + gnugrep = callPackage ../tools/text/gnugrep { }; - gnupatch = useFromStdenv "patch" (import ../tools/text/gnupatch { - inherit fetchurl stdenv ed; - }); + gnupatch = callPackage ../tools/text/gnupatch { }; gnupg1orig = callPackage ../tools/security/gnupg1 { ideaSupport = false; @@ -671,17 +644,11 @@ let lua = null; }; - gnused = useFromStdenv "gnused" - (import ../tools/text/gnused { - inherit fetchurl stdenv; - }); + gnused = callPackage ../tools/text/gnused { }; gnused_4_2 = callPackage ../tools/text/gnused/4.2.nix { }; - gnutar = useFromStdenv "gnutar" - (import ../tools/archivers/gnutar { - inherit fetchurl stdenv; - }); + gnutar = callPackage ../tools/archivers/gnutar { }; gnuvd = callPackage ../tools/misc/gnuvd { }; @@ -731,10 +698,7 @@ let inherit openssl gmp nettools iproute; }; - gzip = useFromStdenv "gzip" - (import ../tools/compression/gzip { - inherit fetchurl stdenv; - }); + gzip = callPackage ../tools/compression/gzip { }; pigz = callPackage ../tools/compression/pigz { }; @@ -1385,14 +1349,11 @@ let ### SHELLS - bash = lowPrio (useFromStdenv "bash" bashReal); - - bashReal = callPackage ../shells/bash { + bash = lowPrio (callPackage ../shells/bash { texinfo = null; - }; + }); - bashInteractive = appendToName "interactive" (bashReal.override { - inherit readline texinfo; + bashInteractive = appendToName "interactive" (callPackage ../shells/bash { interactive = true; }); @@ -1480,7 +1441,7 @@ let profiledCompiler = false; }); - gcc44 = useFromStdenv "gcc" gcc44_real; + gcc44 = gcc44_real; gcc43 = lowPrio (wrapGCC (makeOverridable (import ../development/compilers/gcc-4.3) { inherit stdenv fetchurl texinfo gmp mpfr noSysDirs; @@ -2076,8 +2037,7 @@ let fetchurl = fetchurlBoot; }; - perl = useFromStdenv "perl" - (if system != "i686-cygwin" then perl510 else sysPerl); + perl = if system != "i686-cygwin" then perl510 else sysPerl; php = makeOverridable (import ../development/interpreters/php) { inherit @@ -2274,10 +2234,9 @@ let avrdude = callPackage ../development/tools/misc/avrdude { }; - binutils = useFromStdenv "binutils" - (import ../development/tools/misc/binutils { - inherit fetchurl stdenv noSysDirs; - }); + binutils = callPackage ../development/tools/misc/binutils { + inherit noSysDirs; + }; binutilsCross = forceBuildDrv (import ../development/tools/misc/binutils { inherit stdenv fetchurl; @@ -2378,10 +2337,7 @@ let gnum4 = callPackage ../development/tools/misc/gnum4 { }; - gnumake = useFromStdenv "gnumake" - (import ../development/tools/build-managers/gnumake { - inherit fetchurl stdenv; - }); + gnumake = callPackage ../development/tools/build-managers/gnumake { }; gnumake380 = callPackage ../development/tools/build-managers/gnumake-3.80 { }; @@ -2447,31 +2403,19 @@ let */ }; - patchelf = useFromStdenv "patchelf" - (import ../development/tools/misc/patchelf { - inherit fetchurl stdenv; - }); + patchelf = callPackage ../development/tools/misc/patchelf { }; patchelf06 = callPackage ../development/tools/misc/patchelf/0.6.nix { }; pmccabe = callPackage ../development/tools/misc/pmccabe { }; - /** - * pkgconfig is optionally taken from the stdenv to allow bootstrapping - * of glib and pkgconfig itself on MinGW. - */ - pkgconfigReal = useFromStdenv "pkgconfig" - (import ../development/tools/misc/pkgconfig { - inherit fetchurl stdenv; - }); - /* Make pkgconfig always return a buildDrv, never a proper hostDrv, because most usage of pkgconfig as buildInput (inheritance of pre-cross nixpkgs) means using it using as buildNativeInput cross_renaming: we should make all programs use pkgconfig as buildNativeInput after the renaming. */ - pkgconfig = forceBuildDrv pkgconfigReal; + pkgconfig = forceBuildDrv (callPackage ../development/tools/misc/pkgconfig { }); radare = callPackage ../development/tools/analysis/radare { inherit (gtkLibs) gtk; @@ -2549,10 +2493,7 @@ let aalib = callPackage ../development/libraries/aalib { }; - acl = useFromStdenv "acl" - (import ../development/libraries/acl { - inherit stdenv fetchurl gettext attr libtool; - }); + acl = callPackage ../development/libraries/acl { }; adns = import ../development/libraries/adns/1.4.nix { inherit stdenv fetchurl; @@ -2589,10 +2530,7 @@ let inherit fetchurl stdenv; }); - attr = useFromStdenv "attr" - (import ../development/libraries/attr { - inherit stdenv fetchurl gettext libtool; - }); + attr = callPackage ../development/libraries/attr { }; aubio = callPackage ../development/libraries/aubio { }; @@ -2831,7 +2769,7 @@ let glfw = callPackage ../development/libraries/glfw { }; - glibc = useFromStdenv "glibc" glibc211; + glibc = glibc211; glibc25 = callPackage ../development/libraries/glibc-2.5 { kernelHeaders = linuxHeaders;