From 1e575d357262ebac561d41042b699342c8aa0fd8 Mon Sep 17 00:00:00 2001 From: Peter Simons Date: Mon, 19 Oct 2009 09:17:10 +0000 Subject: [PATCH] perl-5.8 and perl-5.10: fixed build on MacOS X On MacOS X, we used to use the native perl interpreter from /usr/bin. Unfortunately, that interpreter fails to build a number of packages (Subversion, Git, etc. ...), because it assumes knowledge about the underlying C compiler that is not valid for the compiler used by Nix. For example, /usr/bin/perl assumes that the compiler can build binaries for both the ppc and the x86 architecture. /usr/bin/gcc can do that, but the gcc from Nix can't. The solution is to compile Perl 5.10 in Nix so that the ./configure phase can properly detect the system's capabilities. However, note that the resulting binary is impure: it will find headers in /usr/include and libraries in /usr/lib. In this respect, the Nix-compiled perl binary is no different than the native one in /usr/bin -- it's just configured more accurately. svn path=/nixpkgs/trunk/; revision=17870 --- .../interpreters/perl-5.10/default.nix | 12 ++++--- .../interpreters/perl-5.8/builder.sh | 22 ------------- .../interpreters/perl-5.8/default.nix | 32 +++++++++++++++++-- pkgs/top-level/all-packages.nix | 11 +++---- 4 files changed, 42 insertions(+), 35 deletions(-) delete mode 100644 pkgs/development/interpreters/perl-5.8/builder.sh diff --git a/pkgs/development/interpreters/perl-5.10/default.nix b/pkgs/development/interpreters/perl-5.10/default.nix index a8b8dd536a7..442f428ac6f 100644 --- a/pkgs/development/interpreters/perl-5.10/default.nix +++ b/pkgs/development/interpreters/perl-5.10/default.nix @@ -1,4 +1,6 @@ -{stdenv, fetchurl}: +{ stdenv, fetchurl +, impureLibcPath ? null +}: stdenv.mkDerivation { name = "perl-5.10.0"; @@ -34,9 +36,9 @@ stdenv.mkDerivation { preConfigure = '' configureFlags="$configureFlags -Dprefix=$out -Dman1dir=$out/share/man/man1 -Dman3dir=$out/share/man/man3" - - if test "$NIX_ENFORCE_PURITY" = "1"; then - GLIBC=$(cat $NIX_GCC/nix-support/orig-libc) + + if test "${if impureLibcPath == null then "$NIX_ENFORCE_PURITY" else "1"}" = "1"; then + GLIBC=${if impureLibcPath == null then "$(cat $NIX_GCC/nix-support/orig-libc)" else impureLibcPath} configureFlags="$configureFlags -Dlocincpth=$GLIBC/include -Dloclibpth=$GLIBC/lib" fi ''; @@ -44,7 +46,7 @@ stdenv.mkDerivation { preBuild = '' # Make Cwd work on NixOS (where we don't have a /bin/pwd). - substituteInPlace lib/Cwd.pm --replace "'/bin/pwd'" "'$(type -tP pwd)'" + ${if stdenv.system == "i686-darwin" then "" else "substituteInPlace lib/Cwd.pm --replace \"'/bin/pwd'\" \"'$(type -tP pwd)'\""} ''; setupHook = ./setup-hook.sh; diff --git a/pkgs/development/interpreters/perl-5.8/builder.sh b/pkgs/development/interpreters/perl-5.8/builder.sh deleted file mode 100644 index 79458b3249b..00000000000 --- a/pkgs/development/interpreters/perl-5.8/builder.sh +++ /dev/null @@ -1,22 +0,0 @@ -source $stdenv/setup - -if test "$NIX_ENFORCE_PURITY" = "1"; then - GLIBC=$(cat $NIX_GCC/nix-support/orig-libc) - extraflags="-Dlocincpth=$GLIBC/include -Dloclibpth=$GLIBC/lib" -fi - -configureScript=./Configure -configureFlags="-de -Dcc=gcc -Dprefix=$out -Uinstallusrbinperl $extraflags" -dontAddPrefix=1 - -preBuild() { - # Make Cwd work on NixOS (where we don't have a /bin/pwd). - substituteInPlace lib/Cwd.pm --replace "'/bin/pwd'" "'$(type -tP pwd)'" -} - -postInstall() { - ensureDir "$out/nix-support" - cp $setupHook $out/nix-support/setup-hook -} - -genericBuild diff --git a/pkgs/development/interpreters/perl-5.8/default.nix b/pkgs/development/interpreters/perl-5.8/default.nix index 074d41ebd76..48e32416406 100644 --- a/pkgs/development/interpreters/perl-5.8/default.nix +++ b/pkgs/development/interpreters/perl-5.8/default.nix @@ -1,9 +1,37 @@ -{stdenv, fetchurl}: +{ stdenv, fetchurl +, impureLibcPath ? null +}: stdenv.mkDerivation { name = "perl-5.8.8"; - builder = ./builder.sh; + builder = + '' +source $stdenv/setup + +if test "$NIX_ENFORCE_PURITY" = "1"; then + GLIBC=${if impureLibcPath == null then "$(cat $NIX_GCC/nix-support/orig-libc)" else impureLibcPath} + extraflags="-Dlocincpth=$GLIBC/include -Dloclibpth=$GLIBC/lib" +fi + +configureScript=./Configure +configureFlags="-de -Dcc=gcc -Dprefix=$out -Uinstallusrbinperl $extraflags" +dontAddPrefix=1 + +preBuild() { + # Make Cwd work on NixOS (where we don't have a /bin/pwd). + substituteInPlace lib/Cwd.pm --replace "'/bin/pwd'" "'$(type -tP pwd)'" +} + +postInstall() { + ensureDir "$out/nix-support" + cp $setupHook $out/nix-support/setup-hook +} + +genericBuild + + ''; + src = fetchurl { url = mirror://cpan/src/perl-5.8.8.tar.bz2; sha256 = "1j8vzc6lva49mwdxkzhvm78dkxyprqs4n4057amqvsh4kh6i92l1"; diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 94deef7bccc..42e918d47c3 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -2341,16 +2341,15 @@ let inherit (bleedingEdgeRepos) sourceByName; }; - perl = if !stdenv.isLinux then sysPerl else perlReal; - - perl58 = if !stdenv.isLinux then sysPerl else - import ../development/interpreters/perl-5.8 { + perl58 = import ../development/interpreters/perl-5.8 { inherit fetchurl stdenv; + impureLibcPath = if stdenv.isLinux then null else "/usr"; }; - perlReal = import ../development/interpreters/perl-5.10 { - fetchurl = fetchurlBoot; + perl = import ../development/interpreters/perl-5.10 { inherit stdenv; + fetchurl = fetchurlBoot; + impureLibcPath = if stdenv.isLinux then null else "/usr"; }; # FIXME: unixODBC needs patching on Darwin (see darwinports)