2015-02-03 23:04:19 +01:00
|
|
|
{ system ? builtins.currentSystem
|
|
|
|
, allPackages ? import ../../top-level/all-packages.nix
|
|
|
|
, platform ? null
|
|
|
|
, config ? {}
|
|
|
|
}:
|
|
|
|
|
|
|
|
rec {
|
|
|
|
allPackages = import ../../top-level/all-packages.nix;
|
|
|
|
|
|
|
|
bootstrapTools = derivation {
|
|
|
|
inherit system;
|
|
|
|
|
|
|
|
name = "trivial-bootstrap-tools";
|
|
|
|
builder = "/bin/sh";
|
2015-03-23 12:03:01 +01:00
|
|
|
args = [ ./trivial-bootstrap.sh ];
|
2015-02-03 23:04:19 +01:00
|
|
|
|
|
|
|
mkdir = "/bin/mkdir";
|
|
|
|
ln = "/bin/ln";
|
|
|
|
};
|
|
|
|
|
|
|
|
# The simplest stdenv possible to run fetchadc and get the Apple command-line tools
|
|
|
|
stage0 = rec {
|
|
|
|
fetchurl = import ../../build-support/fetchurl {
|
|
|
|
inherit stdenv;
|
|
|
|
curl = bootstrapTools;
|
|
|
|
};
|
|
|
|
|
|
|
|
stdenv = import ../generic {
|
|
|
|
inherit system config;
|
|
|
|
name = "stdenv-darwin-boot-0";
|
|
|
|
shell = "/bin/bash";
|
|
|
|
initialPath = [ bootstrapTools ];
|
|
|
|
fetchurlBoot = fetchurl;
|
2015-06-15 19:26:52 +02:00
|
|
|
cc = null;
|
2015-02-03 23:04:19 +01:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
buildTools = import ../../os-specific/darwin/command-line-tools {
|
|
|
|
inherit (stage0) stdenv fetchurl;
|
|
|
|
xar = bootstrapTools;
|
|
|
|
gzip = bootstrapTools;
|
|
|
|
cpio = bootstrapTools;
|
|
|
|
};
|
|
|
|
|
|
|
|
preHook = ''
|
|
|
|
export NIX_IGNORE_LD_THROUGH_GCC=1
|
|
|
|
export NIX_DONT_SET_RPATH=1
|
|
|
|
export NIX_NO_SELF_RPATH=1
|
|
|
|
dontFixLibtool=1
|
|
|
|
stripAllFlags=" " # the Darwin "strip" command doesn't know "-s"
|
|
|
|
xargsFlags=" "
|
|
|
|
export MACOSX_DEPLOYMENT_TARGET=10.7
|
2015-03-23 16:46:41 +01:00
|
|
|
# Use the 10.9 SDK if we're running on 10.9, and 10.10 if we're
|
|
|
|
# running on 10.10. We need to use the 10.10 headers for functions
|
|
|
|
# like readlinkat() that are dynamically detected by configure
|
|
|
|
# scripts. Very impure, obviously.
|
|
|
|
export SDKROOT=$(/usr/bin/xcrun --sdk macosx"$(/usr/bin/sw_vers -productVersion | /usr/bin/cut -d. -f1,2)" --show-sdk-path 2> /dev/null || echo /)
|
2015-03-05 06:35:57 +01:00
|
|
|
export NIX_CFLAGS_COMPILE+=" --sysroot=/var/empty -idirafter $SDKROOT/usr/include -F$SDKROOT/System/Library/Frameworks -Wno-multichar -Wno-deprecated-declarations"
|
|
|
|
export NIX_LDFLAGS_AFTER+=" -L$SDKROOT/usr/lib"
|
2015-02-03 23:04:19 +01:00
|
|
|
export CMAKE_OSX_ARCHITECTURES=x86_64
|
|
|
|
'';
|
2014-08-17 22:17:13 +02:00
|
|
|
|
2015-02-03 23:04:19 +01:00
|
|
|
# A stdenv that wraps the Apple command-line tools and our other trivial symlinked bootstrap tools
|
|
|
|
stage1 = rec {
|
|
|
|
nativePrefix = "${buildTools.tools}/Library/Developer/CommandLineTools/usr";
|
2014-08-17 22:17:13 +02:00
|
|
|
|
2015-02-03 23:04:19 +01:00
|
|
|
stdenv = import ../generic {
|
|
|
|
name = "stdenv-darwin-boot-1";
|
2014-08-17 22:17:13 +02:00
|
|
|
|
2015-02-03 23:04:19 +01:00
|
|
|
inherit system config;
|
2015-03-25 01:32:27 +01:00
|
|
|
inherit (stage0.stdenv) shell fetchurlBoot;
|
|
|
|
|
|
|
|
initialPath = stage0.stdenv.initialPath ++ [ nativePrefix ];
|
2015-02-03 23:04:19 +01:00
|
|
|
|
|
|
|
preHook = preHook + "\n" + ''
|
|
|
|
export NIX_LDFLAGS_AFTER+=" -L/usr/lib"
|
|
|
|
export NIX_ENFORCE_PURITY=
|
|
|
|
export NIX_CFLAGS_COMPILE+=" -isystem ${nativePrefix}/include/c++/v1 -stdlib=libc++"
|
|
|
|
export NIX_CFLAGS_LINK+=" -stdlib=libc++ -Wl,-rpath,${nativePrefix}/lib"
|
|
|
|
'';
|
|
|
|
|
|
|
|
cc = import ../../build-support/cc-wrapper {
|
|
|
|
nativeTools = true;
|
|
|
|
nativePrefix = nativePrefix;
|
|
|
|
nativeLibc = true;
|
|
|
|
stdenv = stage0.stdenv;
|
|
|
|
shell = "/bin/bash";
|
|
|
|
cc = {
|
|
|
|
name = "clang-9.9.9";
|
|
|
|
cc = "/usr";
|
2015-03-25 01:32:27 +01:00
|
|
|
outPath = nativePrefix;
|
2015-02-03 23:04:19 +01:00
|
|
|
};
|
2015-05-11 23:30:13 +02:00
|
|
|
isClang = true;
|
2015-02-03 23:04:19 +01:00
|
|
|
};
|
|
|
|
};
|
|
|
|
pkgs = allPackages {
|
|
|
|
inherit system platform;
|
|
|
|
bootStdenv = stdenv;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
stage2 = rec {
|
|
|
|
stdenv = import ../generic {
|
|
|
|
name = "stdenv-darwin-boot-2";
|
|
|
|
|
|
|
|
inherit system config;
|
|
|
|
inherit (stage1.stdenv) shell fetchurlBoot preHook cc;
|
|
|
|
|
2015-06-20 07:08:01 +02:00
|
|
|
initialPath = [ stage1.pkgs.xz stage1.pkgs.gnused ] ++ stage1.stdenv.initialPath;
|
2015-02-03 23:04:19 +01:00
|
|
|
};
|
|
|
|
pkgs = allPackages {
|
|
|
|
inherit system platform;
|
|
|
|
bootStdenv = stdenv;
|
|
|
|
};
|
2014-08-17 22:17:13 +02:00
|
|
|
};
|
|
|
|
|
2015-02-03 23:04:19 +01:00
|
|
|
# Use stage1 to build a whole set of actual tools so we don't have to rely on the Apple prebuilt ones or
|
|
|
|
# the ugly symlinked bootstrap tools anymore.
|
|
|
|
stage3 = with stage2; import ../generic {
|
|
|
|
name = "stdenv-darwin-boot-3";
|
2014-08-17 22:17:13 +02:00
|
|
|
|
2015-02-03 23:04:19 +01:00
|
|
|
inherit system config;
|
|
|
|
inherit (stdenv) fetchurlBoot;
|
2014-08-17 22:17:13 +02:00
|
|
|
|
2015-02-03 23:04:19 +01:00
|
|
|
initialPath = (import ../common-path.nix) { inherit pkgs; };
|
|
|
|
|
|
|
|
preHook = preHook + "\n" + ''
|
|
|
|
export NIX_ENFORCE_PURITY=1
|
|
|
|
'';
|
|
|
|
|
|
|
|
cc = import ../../build-support/cc-wrapper {
|
|
|
|
inherit stdenv;
|
2015-05-11 23:30:13 +02:00
|
|
|
nativeTools = false;
|
|
|
|
nativeLibc = true;
|
|
|
|
binutils = pkgs.darwin.cctools;
|
|
|
|
cc = pkgs.llvmPackages.clang-unwrapped;
|
|
|
|
coreutils = pkgs.coreutils;
|
|
|
|
shell = "${pkgs.bash}/bin/bash";
|
2015-02-03 23:41:12 +01:00
|
|
|
extraPackages = [ pkgs.libcxx ];
|
2015-05-11 23:30:13 +02:00
|
|
|
isClang = true;
|
2015-02-03 23:04:19 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
shell = "${pkgs.bash}/bin/bash";
|
2014-08-17 22:17:13 +02:00
|
|
|
};
|
2015-02-03 23:04:19 +01:00
|
|
|
|
|
|
|
stdenvDarwin = stage3;
|
2014-08-17 22:17:13 +02:00
|
|
|
}
|