2016-01-04 02:47:09 +00:00
|
|
|
{ system ? builtins.currentSystem
|
2016-03-13 18:24:55 +00:00
|
|
|
, allPackages ? import ../../..
|
2016-01-04 02:47:09 +00:00
|
|
|
, platform ? null
|
|
|
|
, config ? {}
|
|
|
|
|
|
|
|
# Allow passing in bootstrap files directly so we can test the stdenv bootstrap process when changing the bootstrap tools
|
|
|
|
, bootstrapFiles ? let
|
|
|
|
fetch = { file, sha256, executable ? true }: import <nix/fetchurl.nix> {
|
|
|
|
url = "http://tarballs.nixos.org/stdenv-darwin/x86_64/4f07c88d467216d9692fefc951deb5cd3c4cc722/${file}";
|
|
|
|
inherit sha256 system executable;
|
|
|
|
}; in {
|
|
|
|
sh = fetch { file = "sh"; sha256 = "1siix3wakzil31r2cydmh3v8a1nyq4605dwiabqc5lx73j4xzrzi"; };
|
|
|
|
bzip2 = fetch { file = "bzip2"; sha256 = "0zvqm977k11b5cl4ixxb5h0ds24g6z0f8m28z4pqxzpa353lqbla"; };
|
|
|
|
mkdir = fetch { file = "mkdir"; sha256 = "13frk8lsfgzlb65p9l26cvxf06aag43yjk7vg9msn7ix3v8cmrg1"; };
|
|
|
|
cpio = fetch { file = "cpio"; sha256 = "0ms5i9m1vdksj575sf1djwgm7zhnvfrrb44dxnfh9avr793rc2w4"; };
|
|
|
|
tarball = fetch { file = "bootstrap-tools.cpio.bz2"; sha256 = "1lz1b0grl4642h6n635xvi6imf0yyy1zyzdr9ing5aphzz0z5iic"; executable = false; };
|
|
|
|
}
|
2015-06-18 18:03:32 +01:00
|
|
|
}:
|
|
|
|
|
|
|
|
let
|
2015-11-13 02:59:17 +00:00
|
|
|
libSystemProfile = ''
|
|
|
|
(import "${./standard-sandbox.sb}")
|
|
|
|
'';
|
2015-06-18 18:03:32 +01:00
|
|
|
in rec {
|
2016-03-13 18:24:55 +00:00
|
|
|
allPackages = import ../../..;
|
2015-06-18 18:03:32 +01:00
|
|
|
|
|
|
|
commonPreHook = ''
|
2016-02-29 11:10:26 +00:00
|
|
|
export NIX_ENFORCE_PURITY="''${NIX_ENFORCE_PURITY-1}"
|
2016-03-15 16:35:07 +00:00
|
|
|
export NIX_ENFORCE_NO_NATIVE="''${NIX_ENFORCE_NO_NATIVE-1}"
|
2015-06-18 18:03:32 +01:00
|
|
|
export NIX_IGNORE_LD_THROUGH_GCC=1
|
|
|
|
stripAllFlags=" " # the Darwin "strip" command doesn't know "-s"
|
|
|
|
export MACOSX_DEPLOYMENT_TARGET=10.7
|
|
|
|
export SDKROOT=
|
|
|
|
export CMAKE_OSX_ARCHITECTURES=x86_64
|
2015-10-06 08:11:00 +01:00
|
|
|
# Workaround for https://openradar.appspot.com/22671534 on 10.11.
|
|
|
|
export gl_cv_func_getcwd_abort_bug=no
|
2015-06-18 18:03:32 +01:00
|
|
|
'';
|
|
|
|
|
|
|
|
# The one dependency of /bin/sh :(
|
2015-11-07 01:44:02 +00:00
|
|
|
binShClosure = ''
|
|
|
|
(allow file-read* (literal "/usr/lib/libncurses.5.4.dylib"))
|
|
|
|
'';
|
2015-06-18 18:03:32 +01:00
|
|
|
|
|
|
|
bootstrapTools = derivation rec {
|
2016-01-04 02:47:09 +00:00
|
|
|
inherit system;
|
2015-06-18 18:03:32 +01:00
|
|
|
|
|
|
|
name = "bootstrap-tools";
|
|
|
|
builder = bootstrapFiles.sh; # Not a filename! Attribute 'sh' on bootstrapFiles
|
|
|
|
args = [ ./unpack-bootstrap-tools.sh ];
|
|
|
|
|
2016-01-04 02:47:09 +00:00
|
|
|
inherit (bootstrapFiles) mkdir bzip2 cpio tarball;
|
2015-06-18 18:03:32 +01:00
|
|
|
|
2015-11-21 20:06:41 +00:00
|
|
|
__sandboxProfile = binShClosure + libSystemProfile;
|
2015-06-18 18:03:32 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
stageFun = step: last: {shell ? "${bootstrapTools}/bin/sh",
|
|
|
|
overrides ? (pkgs: {}),
|
|
|
|
extraPreHook ? "",
|
2016-03-23 17:11:42 +00:00
|
|
|
extraBuildInputs,
|
2015-06-18 18:03:32 +01:00
|
|
|
allowedRequisites ? null}:
|
|
|
|
let
|
|
|
|
thisStdenv = import ../generic {
|
|
|
|
inherit system config shell extraBuildInputs allowedRequisites;
|
|
|
|
|
|
|
|
name = "stdenv-darwin-boot-${toString step}";
|
|
|
|
|
2015-06-18 21:44:40 +01:00
|
|
|
cc = if isNull last then "/dev/null" else import ../../build-support/cc-wrapper {
|
2015-06-18 18:03:32 +01:00
|
|
|
inherit shell;
|
|
|
|
inherit (last) stdenv;
|
|
|
|
inherit (last.pkgs.darwin) dyld;
|
|
|
|
|
|
|
|
nativeTools = true;
|
|
|
|
nativePrefix = bootstrapTools;
|
|
|
|
nativeLibc = false;
|
|
|
|
libc = last.pkgs.darwin.Libsystem;
|
2015-08-04 17:55:29 +01:00
|
|
|
isClang = true;
|
2015-06-18 18:03:32 +01:00
|
|
|
cc = { name = "clang-9.9.9"; outPath = bootstrapTools; };
|
|
|
|
};
|
|
|
|
|
|
|
|
preHook = stage0.stdenv.lib.optionalString (shell == "${bootstrapTools}/bin/sh") ''
|
|
|
|
# Don't patch #!/interpreter because it leads to retained
|
|
|
|
# dependencies on the bootstrapTools in the final stdenv.
|
|
|
|
dontPatchShebangs=1
|
|
|
|
'' + ''
|
|
|
|
${commonPreHook}
|
|
|
|
${extraPreHook}
|
|
|
|
'';
|
2016-03-23 17:11:42 +00:00
|
|
|
initialPath = [ bootstrapTools ];
|
2015-06-18 18:03:32 +01:00
|
|
|
fetchurlBoot = import ../../build-support/fetchurl {
|
|
|
|
stdenv = stage0.stdenv;
|
|
|
|
curl = bootstrapTools;
|
|
|
|
};
|
|
|
|
|
|
|
|
# The stdenvs themselves don't use mkDerivation, so I need to specify this here
|
2015-11-21 20:06:41 +00:00
|
|
|
stdenvSandboxProfile = binShClosure + libSystemProfile;
|
|
|
|
extraSandboxProfile = binShClosure + libSystemProfile;
|
2015-06-18 18:03:32 +01:00
|
|
|
|
2016-01-16 19:53:56 +00:00
|
|
|
extraAttrs = { inherit platform; parent = last; };
|
2015-06-18 18:03:32 +01:00
|
|
|
overrides = pkgs: (overrides pkgs) // { fetchurl = thisStdenv.fetchurlBoot; };
|
|
|
|
};
|
|
|
|
|
|
|
|
thisPkgs = allPackages {
|
|
|
|
inherit system platform;
|
|
|
|
bootStdenv = thisStdenv;
|
|
|
|
};
|
|
|
|
in { stdenv = thisStdenv; pkgs = thisPkgs; };
|
|
|
|
|
|
|
|
stage0 = stageFun 0 null {
|
|
|
|
overrides = orig: with stage0; rec {
|
|
|
|
darwin = orig.darwin // {
|
|
|
|
Libsystem = stdenv.mkDerivation {
|
|
|
|
name = "bootstrap-Libsystem";
|
|
|
|
buildCommand = ''
|
|
|
|
mkdir -p $out
|
|
|
|
ln -s ${bootstrapTools}/lib $out/lib
|
|
|
|
ln -s ${bootstrapTools}/include-Libsystem $out/include
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
dyld = bootstrapTools;
|
|
|
|
};
|
|
|
|
|
|
|
|
libcxx = stdenv.mkDerivation {
|
|
|
|
name = "bootstrap-libcxx";
|
|
|
|
phases = [ "installPhase" "fixupPhase" ];
|
|
|
|
installPhase = ''
|
|
|
|
mkdir -p $out/lib $out/include
|
|
|
|
ln -s ${bootstrapTools}/lib/libc++.dylib $out/lib/libc++.dylib
|
|
|
|
ln -s ${bootstrapTools}/include/c++ $out/include/c++
|
|
|
|
'';
|
2015-07-27 22:25:34 +01:00
|
|
|
linkCxxAbi = false;
|
|
|
|
setupHook = ../../development/compilers/llvm/3.6/libc++/setup-hook.sh;
|
2015-06-18 18:03:32 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
libcxxabi = stdenv.mkDerivation {
|
|
|
|
name = "bootstrap-libcxxabi";
|
|
|
|
buildCommand = ''
|
|
|
|
mkdir -p $out/lib
|
|
|
|
ln -s ${bootstrapTools}/lib/libc++abi.dylib $out/lib/libc++abi.dylib
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
extraBuildInputs = [];
|
|
|
|
};
|
|
|
|
|
|
|
|
persistent0 = _: {};
|
|
|
|
|
|
|
|
stage1 = with stage0; stageFun 1 stage0 {
|
|
|
|
extraPreHook = "export NIX_CFLAGS_COMPILE+=\" -F${bootstrapTools}/Library/Frameworks\"";
|
|
|
|
extraBuildInputs = [ pkgs.libcxx ];
|
|
|
|
|
|
|
|
allowedRequisites =
|
|
|
|
[ bootstrapTools ] ++ (with pkgs; [ libcxx libcxxabi ]) ++ [ pkgs.darwin.Libsystem ];
|
|
|
|
|
|
|
|
overrides = persistent0;
|
|
|
|
};
|
|
|
|
|
|
|
|
persistent1 = orig: with stage1.pkgs; {
|
|
|
|
inherit
|
|
|
|
zlib patchutils m4 scons flex perl bison unifdef unzip openssl icu python
|
|
|
|
libxml2 gettext sharutils gmp libarchive ncurses pkg-config libedit groff
|
|
|
|
openssh sqlite sed serf openldap db cyrus-sasl expat apr-util subversion xz
|
|
|
|
findfreetype libssh curl cmake autoconf automake libtool ed cpio coreutils;
|
|
|
|
|
|
|
|
darwin = orig.darwin // {
|
|
|
|
inherit (darwin)
|
|
|
|
dyld Libsystem xnu configd libdispatch libclosure launchd;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
stage2 = with stage1; stageFun 2 stage1 {
|
2015-11-07 01:44:02 +00:00
|
|
|
extraPreHook = ''
|
|
|
|
export PATH_LOCALE=${pkgs.darwin.locale}/share/locale
|
|
|
|
'';
|
|
|
|
|
2016-03-23 17:11:42 +00:00
|
|
|
extraBuildInputs = with pkgs; [ xz darwin.CF libcxx ];
|
|
|
|
|
2015-06-18 18:03:32 +01:00
|
|
|
allowedRequisites =
|
|
|
|
[ bootstrapTools ] ++
|
2016-02-13 20:46:42 +00:00
|
|
|
(with pkgs; [ xz.bin xz.out libcxx libcxxabi icu.out ]) ++
|
2015-11-07 01:44:02 +00:00
|
|
|
(with pkgs.darwin; [ dyld Libsystem CF locale ]);
|
2015-06-18 18:03:32 +01:00
|
|
|
|
|
|
|
overrides = persistent1;
|
|
|
|
};
|
|
|
|
|
|
|
|
persistent2 = orig: with stage2.pkgs; {
|
|
|
|
inherit
|
|
|
|
patchutils m4 scons flex perl bison unifdef unzip openssl python
|
|
|
|
gettext sharutils libarchive pkg-config groff bash subversion
|
|
|
|
openssh sqlite sed serf openldap db cyrus-sasl expat apr-util
|
|
|
|
findfreetype libssh curl cmake autoconf automake libtool cpio
|
|
|
|
libcxx libcxxabi;
|
|
|
|
|
|
|
|
darwin = orig.darwin // {
|
|
|
|
inherit (darwin)
|
2015-11-07 01:44:02 +00:00
|
|
|
dyld Libsystem xnu configd libdispatch libclosure launchd libiconv locale;
|
2015-06-18 18:03:32 +01:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
stage3 = with stage2; stageFun 3 stage2 {
|
|
|
|
shell = "${pkgs.bash}/bin/bash";
|
|
|
|
|
|
|
|
# We have a valid shell here (this one has no bootstrap-tools runtime deps) so stageFun
|
|
|
|
# enables patchShebangs above. Unfortunately, patchShebangs ignores our $SHELL setting
|
|
|
|
# and instead goes by $PATH, which happens to contain bootstrapTools. So it goes and
|
|
|
|
# patches our shebangs back to point at bootstrapTools. This makes sure bash comes first.
|
2016-03-23 17:11:42 +00:00
|
|
|
extraBuildInputs = with pkgs; [ xz darwin.CF libcxx pkgs.bash ];
|
2015-06-18 18:03:32 +01:00
|
|
|
|
2015-11-07 01:44:02 +00:00
|
|
|
extraPreHook = ''
|
2016-03-23 17:11:42 +00:00
|
|
|
export PATH=${pkgs.bash}/bin:$PATH
|
2015-11-07 01:44:02 +00:00
|
|
|
export PATH_LOCALE=${pkgs.darwin.locale}/share/locale
|
|
|
|
'';
|
|
|
|
|
2015-06-18 18:03:32 +01:00
|
|
|
allowedRequisites =
|
|
|
|
[ bootstrapTools ] ++
|
2016-02-13 20:46:42 +00:00
|
|
|
(with pkgs; [ xz.bin xz.out icu.out bash libcxx libcxxabi ]) ++
|
2015-11-07 01:44:02 +00:00
|
|
|
(with pkgs.darwin; [ dyld Libsystem locale ]);
|
2015-06-18 18:03:32 +01:00
|
|
|
|
|
|
|
overrides = persistent2;
|
|
|
|
};
|
|
|
|
|
|
|
|
persistent3 = orig: with stage3.pkgs; {
|
|
|
|
inherit
|
|
|
|
gnumake gzip gnused bzip2 gawk ed xz patch bash
|
2015-10-05 16:46:49 +01:00
|
|
|
libcxxabi libcxx ncurses libffi zlib gmp pcre gnugrep
|
2015-06-18 18:03:32 +01:00
|
|
|
coreutils findutils diffutils patchutils;
|
|
|
|
|
2015-10-05 16:46:49 +01:00
|
|
|
llvmPackages = let llvmOverride = llvmPackages.llvm.override { inherit libcxxabi; };
|
|
|
|
in orig.llvmPackages // {
|
|
|
|
llvm = llvmOverride;
|
|
|
|
clang-unwrapped = llvmPackages.clang-unwrapped.override { llvm = llvmOverride; };
|
2015-06-18 18:03:32 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
darwin = orig.darwin // {
|
2015-11-07 01:44:02 +00:00
|
|
|
inherit (darwin) dyld Libsystem libiconv locale;
|
2015-06-18 18:03:32 +01:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
stage4 = with stage3; stageFun 4 stage3 {
|
|
|
|
shell = "${pkgs.bash}/bin/bash";
|
2016-03-23 17:11:42 +00:00
|
|
|
extraBuildInputs = with pkgs; [ xz darwin.CF libcxx pkgs.bash ];
|
2015-11-07 01:44:02 +00:00
|
|
|
extraPreHook = ''
|
|
|
|
export PATH_LOCALE=${pkgs.darwin.locale}/share/locale
|
|
|
|
'';
|
2015-06-18 18:03:32 +01:00
|
|
|
overrides = persistent3;
|
|
|
|
};
|
|
|
|
|
|
|
|
persistent4 = orig: with stage4.pkgs; {
|
|
|
|
inherit
|
|
|
|
gnumake gzip gnused bzip2 gawk ed xz patch bash
|
|
|
|
libcxxabi libcxx ncurses libffi zlib icu llvm gmp pcre gnugrep
|
|
|
|
coreutils findutils diffutils patchutils binutils binutils-raw;
|
|
|
|
|
|
|
|
llvmPackages = orig.llvmPackages // {
|
|
|
|
inherit (llvmPackages) llvm clang-unwrapped;
|
|
|
|
};
|
|
|
|
|
|
|
|
darwin = orig.darwin // {
|
2015-11-13 02:59:17 +00:00
|
|
|
inherit (darwin) dyld Libsystem cctools libiconv;
|
2015-06-18 18:03:32 +01:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
stage5 = with stage4; import ../generic rec {
|
|
|
|
inherit system config;
|
|
|
|
inherit (stdenv) fetchurlBoot;
|
|
|
|
|
|
|
|
name = "stdenv-darwin";
|
|
|
|
|
2015-11-13 02:59:17 +00:00
|
|
|
preHook = commonPreHook + ''
|
|
|
|
export PATH_LOCALE=${pkgs.darwin.locale}/share/locale
|
|
|
|
'';
|
2015-06-18 18:03:32 +01:00
|
|
|
|
2015-11-21 20:06:41 +00:00
|
|
|
stdenvSandboxProfile = binShClosure + libSystemProfile;
|
|
|
|
extraSandboxProfile = binShClosure + libSystemProfile;
|
2015-06-18 18:03:32 +01:00
|
|
|
|
|
|
|
initialPath = import ../common-path.nix { inherit pkgs; };
|
|
|
|
shell = "${pkgs.bash}/bin/bash";
|
|
|
|
|
|
|
|
cc = import ../../build-support/cc-wrapper {
|
|
|
|
inherit stdenv shell;
|
|
|
|
nativeTools = false;
|
|
|
|
nativeLibc = false;
|
2015-12-17 22:02:40 +00:00
|
|
|
inherit (pkgs) coreutils binutils gnugrep;
|
2015-06-18 18:03:32 +01:00
|
|
|
inherit (pkgs.darwin) dyld;
|
|
|
|
cc = pkgs.llvmPackages.clang-unwrapped;
|
|
|
|
libc = pkgs.darwin.Libsystem;
|
|
|
|
};
|
|
|
|
|
|
|
|
extraBuildInputs = with pkgs; [ darwin.CF libcxx ];
|
|
|
|
|
|
|
|
extraAttrs = {
|
|
|
|
inherit platform bootstrapTools;
|
|
|
|
libc = pkgs.darwin.Libsystem;
|
|
|
|
shellPackage = pkgs.bash;
|
2016-01-16 19:53:56 +00:00
|
|
|
parent = stage4;
|
2015-06-18 18:03:32 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
allowedRequisites = (with pkgs; [
|
2016-02-13 20:46:42 +00:00
|
|
|
xz.out xz.bin libcxx libcxxabi icu.out gmp.out gnumake findutils bzip2.out
|
2016-04-16 23:21:32 +01:00
|
|
|
bzip2.bin llvmPackages.llvm zlib.out zlib.dev libffi.out coreutils ed diffutils gnutar
|
2016-02-01 17:16:50 +00:00
|
|
|
gzip ncurses.out ncurses.dev ncurses.man gnused bash gawk
|
2016-02-13 20:46:42 +00:00
|
|
|
gnugrep llvmPackages.clang-unwrapped patch pcre.out binutils-raw.out
|
|
|
|
binutils-raw.dev binutils gettext
|
2015-06-18 18:03:32 +01:00
|
|
|
]) ++ (with pkgs.darwin; [
|
2015-11-13 02:59:17 +00:00
|
|
|
dyld Libsystem CF cctools libiconv locale
|
2015-06-18 18:03:32 +01:00
|
|
|
]);
|
|
|
|
|
|
|
|
overrides = orig: persistent4 orig // {
|
|
|
|
clang = cc;
|
|
|
|
inherit cc;
|
|
|
|
};
|
|
|
|
};
|
2016-01-04 02:47:09 +00:00
|
|
|
|
|
|
|
stdenvDarwin = stage5;
|
2015-06-18 18:03:32 +01:00
|
|
|
}
|