2009-02-02 16:03:38 +01:00
|
|
|
{system, allPackages ? import ../../..}:
|
2004-03-08 17:02:46 +01:00
|
|
|
|
2009-02-02 16:03:38 +01:00
|
|
|
rec {
|
2004-03-08 17:02:46 +01:00
|
|
|
|
2008-06-18 17:09:13 +02:00
|
|
|
shell = "/bin/bash";
|
|
|
|
|
2009-09-30 17:19:25 +02:00
|
|
|
path = (if system == "i386-sunos" then [ "/usr/gnu" ] else []) ++
|
2009-10-16 12:03:27 +02:00
|
|
|
(if system == "i686-netbsd" then [ "/usr/pkg" ] else []) ++
|
2009-09-30 17:19:25 +02:00
|
|
|
["/" "/usr" "/usr/local"];
|
2008-06-18 17:09:13 +02:00
|
|
|
|
|
|
|
prehookBase = builtins.toFile "prehook-base.sh" ''
|
|
|
|
# Disable purity tests; it's allowed (even needed) to link to
|
|
|
|
# libraries outside the Nix store (like the C library).
|
|
|
|
export NIX_ENFORCE_PURITY=
|
|
|
|
'';
|
|
|
|
|
|
|
|
prehookDarwin = builtins.toFile "prehook-darwin.sh" ''
|
|
|
|
source ${prehookBase}
|
|
|
|
export NIX_DONT_SET_RPATH=1
|
|
|
|
export NIX_NO_SELF_RPATH=1
|
|
|
|
dontFixLibtool=1
|
|
|
|
NIX_STRIP_DEBUG=0
|
|
|
|
stripAllFlags=" " # the Darwin "strip" command doesn't know "-s"
|
|
|
|
'';
|
|
|
|
|
|
|
|
prehookFreeBSD = builtins.toFile "prehook-freebsd.sh" ''
|
|
|
|
source ${prehookBase}
|
|
|
|
|
|
|
|
alias make=gmake
|
2009-10-16 12:09:33 +02:00
|
|
|
alias tar=gtar
|
2009-10-16 12:18:55 +02:00
|
|
|
alias sed=gsed
|
2008-06-18 17:09:13 +02:00
|
|
|
export MAKE=gmake
|
|
|
|
shopt -s expand_aliases
|
|
|
|
|
|
|
|
# Filter out stupid GCC warnings (in gcc-wrapper).
|
|
|
|
export NIX_GCC_NEEDS_GREP=1
|
|
|
|
'';
|
|
|
|
|
2009-09-23 15:30:04 +02:00
|
|
|
prehookOpenBSD = builtins.toFile "prehook-openbsd.sh" ''
|
|
|
|
source ${prehookBase}
|
|
|
|
|
|
|
|
alias make=gmake
|
|
|
|
alias grep=ggrep
|
2009-09-23 15:54:45 +02:00
|
|
|
alias mv=gmv
|
|
|
|
alias ln=gln
|
|
|
|
alias sed=gsed
|
2009-10-16 12:09:33 +02:00
|
|
|
alias tar=gtar
|
2009-10-16 12:21:27 +02:00
|
|
|
|
2009-09-23 15:30:04 +02:00
|
|
|
export MAKE=gmake
|
|
|
|
shopt -s expand_aliases
|
|
|
|
|
|
|
|
# Filter out stupid GCC warnings (in gcc-wrapper).
|
|
|
|
export NIX_GCC_NEEDS_GREP=1
|
|
|
|
'';
|
|
|
|
|
2009-10-16 12:03:27 +02:00
|
|
|
prehookNetBSD = builtins.toFile "prehook-netbsd.sh" ''
|
|
|
|
source ${prehookBase}
|
|
|
|
|
|
|
|
alias make=gmake
|
|
|
|
alias sed=gsed
|
2009-10-16 12:09:33 +02:00
|
|
|
alias tar=gtar
|
2009-10-16 12:03:27 +02:00
|
|
|
export MAKE=gmake
|
|
|
|
shopt -s expand_aliases
|
|
|
|
|
|
|
|
# Filter out stupid GCC warnings (in gcc-wrapper).
|
|
|
|
export NIX_GCC_NEEDS_GREP=1
|
|
|
|
'';
|
|
|
|
|
2008-06-18 17:09:13 +02:00
|
|
|
prehookCygwin = builtins.toFile "prehook-cygwin.sh" ''
|
|
|
|
source ${prehookBase}
|
|
|
|
|
|
|
|
if test -z "$cygwinConfigureEnableShared"; then
|
|
|
|
export configureFlags="$configureFlags --disable-shared"
|
|
|
|
fi
|
|
|
|
|
|
|
|
PATH_DELIMITER=';'
|
|
|
|
'';
|
|
|
|
|
|
|
|
|
|
|
|
# A function that builds a "native" stdenv (one that uses tools in
|
|
|
|
# /usr etc.).
|
2009-02-02 16:03:38 +01:00
|
|
|
makeStdenv =
|
|
|
|
{gcc, fetchurl, extraPath ? []}:
|
|
|
|
|
|
|
|
import ../generic {
|
|
|
|
name = "stdenv-native";
|
2008-06-18 17:09:13 +02:00
|
|
|
|
2009-02-02 16:03:38 +01:00
|
|
|
preHook =
|
|
|
|
if system == "i686-darwin" || system == "powerpc-darwin" then prehookDarwin else
|
|
|
|
if system == "i686-freebsd" then prehookFreeBSD else
|
2009-09-23 15:30:04 +02:00
|
|
|
if system == "i686-openbsd" then prehookOpenBSD else
|
2009-10-16 12:03:27 +02:00
|
|
|
if system == "i686-netbsd" then prehookNetBSD else
|
2009-02-02 16:03:38 +01:00
|
|
|
prehookBase;
|
2008-06-18 17:09:13 +02:00
|
|
|
|
2009-02-02 16:03:38 +01:00
|
|
|
initialPath = extraPath ++ path;
|
2008-06-18 17:09:13 +02:00
|
|
|
|
2009-02-02 16:03:38 +01:00
|
|
|
fetchurlBoot = fetchurl;
|
2008-06-18 17:09:13 +02:00
|
|
|
|
2009-02-02 16:03:38 +01:00
|
|
|
inherit system shell gcc;
|
2008-06-18 17:09:13 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2009-02-02 16:03:38 +01:00
|
|
|
stdenvBoot0 = makeStdenv {
|
|
|
|
gcc = "/no-such-path";
|
|
|
|
fetchurl = null;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
gcc = import ../../build-support/gcc-wrapper {
|
|
|
|
name = "gcc-native";
|
|
|
|
nativeTools = true;
|
|
|
|
nativeLibc = true;
|
2009-09-30 17:19:25 +02:00
|
|
|
nativePrefix = if system == "i386-sunos" then "/usr/gnu" else "/usr";
|
2009-02-02 16:03:38 +01:00
|
|
|
stdenv = stdenvBoot0;
|
2004-03-08 17:02:46 +01:00
|
|
|
};
|
2004-03-29 19:23:01 +02:00
|
|
|
|
2009-02-02 16:03:38 +01:00
|
|
|
|
|
|
|
fetchurl = import ../../build-support/fetchurl {
|
|
|
|
stdenv = stdenvBoot0;
|
|
|
|
# Curl should be in /usr/bin or so.
|
|
|
|
curl = null;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2008-06-18 17:09:13 +02:00
|
|
|
# First build a stdenv based only on tools outside the store.
|
|
|
|
stdenvBoot1 = makeStdenv {
|
2009-02-02 16:03:38 +01:00
|
|
|
inherit gcc fetchurl;
|
|
|
|
} // {inherit fetchurl;};
|
2008-06-18 17:09:13 +02:00
|
|
|
|
2009-02-02 16:03:38 +01:00
|
|
|
stdenvBoot1Pkgs = allPackages {
|
2008-06-18 17:09:13 +02:00
|
|
|
inherit system;
|
|
|
|
bootStdenv = stdenvBoot1;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
# Using that, build a stdenv that adds the `replace' command (which
|
|
|
|
# most systems don't have, so we mustn't rely on the native
|
|
|
|
# environment providing it).
|
|
|
|
stdenvBoot2 = makeStdenv {
|
2009-02-02 16:03:38 +01:00
|
|
|
inherit gcc fetchurl;
|
2008-06-18 17:09:13 +02:00
|
|
|
extraPath = [stdenvBoot1Pkgs.replace];
|
|
|
|
};
|
|
|
|
|
2009-02-02 16:03:38 +01:00
|
|
|
|
|
|
|
stdenv = stdenvBoot2;
|
|
|
|
}
|