lol
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

at 18.09-beta 429 lines 15 kB view raw
1{ lib 2, localSystem, crossSystem, config, overlays 3 4# Allow passing in bootstrap files directly so we can test the stdenv bootstrap process when changing the bootstrap tools 5, bootstrapFiles ? let 6 fetch = { file, sha256, executable ? true }: import <nix/fetchurl.nix> { 7 url = "http://tarballs.nixos.org/stdenv-darwin/x86_64/d5bdfcbfe6346761a332918a267e82799ec954d2/${file}"; 8 inherit (localSystem) system; 9 inherit sha256 executable; 10 }; in { 11 sh = fetch { file = "sh"; sha256 = "07wm33f1yzfpcd3rh42f8g096k4cvv7g65p968j28agzmm2s7s8m"; }; 12 bzip2 = fetch { file = "bzip2"; sha256 = "0y9ri2aprkrp2dkzm6229l0mw4rxr2jy7vvh3d8mxv2698v2kdbm"; }; 13 mkdir = fetch { file = "mkdir"; sha256 = "0sb07xpy66ws6f2jfnpjibyimzb71al8n8c6y4nr8h50al3g90nr"; }; 14 cpio = fetch { file = "cpio"; sha256 = "0r5c54hg678w7zydx27bzl9p3v9fs25y5ix6vdfi1ilqim7xh65n"; }; 15 tarball = fetch { file = "bootstrap-tools.cpio.bz2"; sha256 = "18hp5w6klr8g307ap4368r255qpzg9r0vwg9vqvj8f2zy1xilcjf"; executable = false; }; 16 } 17}: 18 19assert crossSystem == null; 20 21let 22 inherit (localSystem) system platform; 23 24 commonImpureHostDeps = [ 25 "/bin/sh" 26 "/usr/lib/libSystem.B.dylib" 27 "/usr/lib/system/libunc.dylib" # This dependency is "hidden", so our scanning code doesn't pick it up 28 ]; 29in rec { 30 commonPreHook = '' 31 export NIX_ENFORCE_PURITY="''${NIX_ENFORCE_PURITY-1}" 32 export NIX_ENFORCE_NO_NATIVE="''${NIX_ENFORCE_NO_NATIVE-1}" 33 export NIX_IGNORE_LD_THROUGH_GCC=1 34 stripAllFlags=" " # the Darwin "strip" command doesn't know "-s" 35 export MACOSX_DEPLOYMENT_TARGET=10.10 36 export SDKROOT= 37 export CMAKE_OSX_ARCHITECTURES=x86_64 38 # Workaround for https://openradar.appspot.com/22671534 on 10.11. 39 export gl_cv_func_getcwd_abort_bug=no 40 ''; 41 42 bootstrapTools = derivation rec { 43 inherit system; 44 45 name = "bootstrap-tools"; 46 builder = bootstrapFiles.sh; # Not a filename! Attribute 'sh' on bootstrapFiles 47 args = [ ./unpack-bootstrap-tools.sh ]; 48 49 inherit (bootstrapFiles) mkdir bzip2 cpio tarball; 50 reexportedLibrariesFile = 51 ../../os-specific/darwin/apple-source-releases/Libsystem/reexported_libraries; 52 53 __impureHostDeps = commonImpureHostDeps; 54 }; 55 56 stageFun = step: last: {shell ? "${bootstrapTools}/bin/bash", 57 overrides ? (self: super: {}), 58 extraPreHook ? "", 59 extraNativeBuildInputs, 60 extraBuildInputs, 61 libcxx, 62 allowedRequisites ? null}: 63 let 64 name = "bootstrap-stage${toString step}"; 65 66 buildPackages = lib.optionalAttrs (last ? stdenv) { 67 inherit (last) stdenv; 68 }; 69 70 coreutils = { name = "${name}-coreutils"; outPath = bootstrapTools; }; 71 gnugrep = { name = "${name}-gnugrep"; outPath = bootstrapTools; }; 72 73 bintools = import ../../build-support/bintools-wrapper { 74 inherit shell; 75 inherit (last) stdenvNoCC; 76 77 nativeTools = false; 78 nativeLibc = false; 79 inherit buildPackages coreutils gnugrep; 80 libc = last.pkgs.darwin.Libsystem; 81 bintools = { name = "${name}-binutils"; outPath = bootstrapTools; }; 82 }; 83 84 cc = if isNull last then "/dev/null" else import ../../build-support/cc-wrapper { 85 inherit shell; 86 inherit (last) stdenvNoCC; 87 88 extraPackages = lib.optional (libcxx != null) libcxx; 89 90 nativeTools = false; 91 propagateDoc = false; 92 nativeLibc = false; 93 inherit buildPackages coreutils gnugrep bintools; 94 libc = last.pkgs.darwin.Libsystem; 95 isClang = true; 96 cc = { name = "${name}-clang"; outPath = bootstrapTools; }; 97 }; 98 99 thisStdenv = import ../generic { 100 name = "${name}-stdenv-darwin"; 101 102 inherit config shell extraNativeBuildInputs extraBuildInputs; 103 allowedRequisites = if allowedRequisites == null then null else allowedRequisites ++ [ 104 cc.expand-response-params cc.bintools 105 ]; 106 107 buildPlatform = localSystem; 108 hostPlatform = localSystem; 109 targetPlatform = localSystem; 110 111 inherit cc; 112 113 preHook = lib.optionalString (shell == "${bootstrapTools}/bin/bash") '' 114 # Don't patch #!/interpreter because it leads to retained 115 # dependencies on the bootstrapTools in the final stdenv. 116 dontPatchShebangs=1 117 '' + '' 118 ${commonPreHook} 119 ${extraPreHook} 120 ''; 121 initialPath = [ bootstrapTools ]; 122 123 fetchurlBoot = import ../../build-support/fetchurl { 124 inherit lib; 125 stdenvNoCC = stage0.stdenv; 126 curl = bootstrapTools; 127 }; 128 129 # The stdenvs themselves don't use mkDerivation, so I need to specify this here 130 __stdenvImpureHostDeps = commonImpureHostDeps; 131 __extraImpureHostDeps = commonImpureHostDeps; 132 133 extraAttrs = { 134 inherit platform; 135 parent = last; 136 137 # This is used all over the place so I figured I'd just leave it here for now 138 secure-format-patch = ./darwin-secure-format.patch; 139 }; 140 overrides = self: super: (overrides self super) // { fetchurl = thisStdenv.fetchurlBoot; }; 141 }; 142 143 in { 144 inherit config overlays; 145 stdenv = thisStdenv; 146 }; 147 148 stage0 = stageFun 0 null { 149 overrides = self: super: with stage0; rec { 150 darwin = super.darwin // { 151 Libsystem = stdenv.mkDerivation { 152 name = "bootstrap-stage0-Libsystem"; 153 buildCommand = '' 154 mkdir -p $out 155 ln -s ${bootstrapTools}/lib $out/lib 156 ln -s ${bootstrapTools}/include-Libsystem $out/include 157 ''; 158 }; 159 dyld = bootstrapTools; 160 }; 161 162 llvmPackages_5 = { 163 libcxx = stdenv.mkDerivation { 164 name = "bootstrap-stage0-libcxx"; 165 phases = [ "installPhase" "fixupPhase" ]; 166 installPhase = '' 167 mkdir -p $out/lib $out/include 168 ln -s ${bootstrapTools}/lib/libc++.dylib $out/lib/libc++.dylib 169 ln -s ${bootstrapTools}/include/c++ $out/include/c++ 170 ''; 171 linkCxxAbi = false; 172 setupHook = ../../development/compilers/llvm/3.9/libc++/setup-hook.sh; 173 }; 174 175 libcxxabi = stdenv.mkDerivation { 176 name = "bootstrap-stage0-libcxxabi"; 177 buildCommand = '' 178 mkdir -p $out/lib 179 ln -s ${bootstrapTools}/lib/libc++abi.dylib $out/lib/libc++abi.dylib 180 ''; 181 }; 182 }; 183 }; 184 185 extraNativeBuildInputs = []; 186 extraBuildInputs = []; 187 libcxx = null; 188 }; 189 190 stage1 = prevStage: let 191 persistent = self: super: with prevStage; { 192 cmake = super.cmake.override { 193 majorVersion = "3.9"; # FIXME: update ApplicationServices patch 194 isBootstrap = true; 195 useSharedLibraries = false; 196 }; 197 198 python = super.callPackage ../../development/interpreters/python/cpython/2.7/boot.nix { 199 CF = null; # use CoreFoundation from bootstrap-tools 200 configd = null; 201 }; 202 }; 203 in with prevStage; stageFun 1 prevStage { 204 extraPreHook = "export NIX_CFLAGS_COMPILE+=\" -F${bootstrapTools}/Library/Frameworks\""; 205 extraNativeBuildInputs = []; 206 extraBuildInputs = [ ]; 207 libcxx = pkgs.libcxx; 208 209 allowedRequisites = 210 [ bootstrapTools ] ++ (with pkgs; [ libcxx libcxxabi ]) ++ [ pkgs.darwin.Libsystem ]; 211 212 overrides = persistent; 213 }; 214 215 stage2 = prevStage: let 216 persistent = self: super: with prevStage; { 217 inherit 218 zlib patchutils m4 scons flex perl bison unifdef unzip openssl python 219 libxml2 gettext sharutils gmp libarchive ncurses pkg-config libedit groff 220 openssh sqlite sed serf openldap db cyrus-sasl expat apr-util subversion xz 221 findfreetype libssh curl cmake autoconf automake libtool ed cpio coreutils; 222 223 darwin = super.darwin // { 224 inherit (darwin) 225 dyld Libsystem xnu configd ICU libdispatch libclosure launchd; 226 }; 227 }; 228 in with prevStage; stageFun 2 prevStage { 229 extraPreHook = '' 230 export PATH_LOCALE=${pkgs.darwin.locale}/share/locale 231 ''; 232 233 extraNativeBuildInputs = [ pkgs.xz ]; 234 extraBuildInputs = [ pkgs.darwin.CF ]; 235 libcxx = pkgs.libcxx; 236 237 allowedRequisites = 238 [ bootstrapTools ] ++ 239 (with pkgs; [ xz.bin xz.out libcxx libcxxabi ]) ++ 240 (with pkgs.darwin; [ dyld Libsystem CF ICU locale ]); 241 242 overrides = persistent; 243 }; 244 245 stage3 = prevStage: let 246 persistent = self: super: with prevStage; { 247 inherit 248 patchutils m4 scons flex perl bison unifdef unzip openssl python 249 gettext sharutils libarchive pkg-config groff bash subversion 250 openssh sqlite sed serf openldap db cyrus-sasl expat apr-util 251 findfreetype libssh curl cmake autoconf automake libtool cpio; 252 253 # Avoid pulling in a full python and it's extra dependencies for the llvm/clang builds. 254 libxml2 = super.libxml2.override { pythonSupport = false; }; 255 256 llvmPackages_5 = super.llvmPackages_5 // (let 257 libraries = super.llvmPackages_5.libraries.extend (_: _: { 258 inherit (llvmPackages_5) libcxx libcxxabi; 259 }); 260 in { inherit libraries; } // libraries); 261 262 darwin = super.darwin // { 263 inherit (darwin) 264 dyld Libsystem xnu configd libdispatch libclosure launchd libiconv locale; 265 }; 266 }; 267 in with prevStage; stageFun 3 prevStage { 268 shell = "${pkgs.bash}/bin/bash"; 269 270 # We have a valid shell here (this one has no bootstrap-tools runtime deps) so stageFun 271 # enables patchShebangs above. Unfortunately, patchShebangs ignores our $SHELL setting 272 # and instead goes by $PATH, which happens to contain bootstrapTools. So it goes and 273 # patches our shebangs back to point at bootstrapTools. This makes sure bash comes first. 274 extraNativeBuildInputs = with pkgs; [ xz pkgs.bash ]; 275 extraBuildInputs = [ pkgs.darwin.CF ]; 276 libcxx = pkgs.libcxx; 277 278 extraPreHook = '' 279 export PATH=${pkgs.bash}/bin:$PATH 280 export PATH_LOCALE=${pkgs.darwin.locale}/share/locale 281 ''; 282 283 allowedRequisites = 284 [ bootstrapTools ] ++ 285 (with pkgs; [ xz.bin xz.out bash libcxx libcxxabi ]) ++ 286 (with pkgs.darwin; [ dyld ICU Libsystem locale ]); 287 288 overrides = persistent; 289 }; 290 291 stage4 = prevStage: let 292 persistent = self: super: with prevStage; { 293 inherit 294 gnumake gzip gnused bzip2 gawk ed xz patch bash 295 ncurses libffi zlib gmp pcre gnugrep 296 coreutils findutils diffutils patchutils; 297 298 # Hack to make sure we don't link ncurses in bootstrap tools. The proper 299 # solution is to avoid passing -L/nix-store/...-bootstrap-tools/lib, 300 # quite a sledgehammer just to get the C runtime. 301 gettext = super.gettext.overrideAttrs (drv: { 302 configureFlags = drv.configureFlags ++ [ 303 "--disable-curses" 304 ]; 305 }); 306 307 llvmPackages_5 = super.llvmPackages_5 // (let 308 tools = super.llvmPackages_5.tools.extend (llvmSelf: _: { 309 inherit (llvmPackages_5) llvm clang-unwrapped; 310 }); 311 libraries = super.llvmPackages_5.libraries.extend (llvmSelf: _: { 312 inherit (llvmPackages_5) libcxx libcxxabi compiler-rt; 313 }); 314 in { inherit tools libraries; } // tools // libraries); 315 316 darwin = super.darwin // { 317 inherit (darwin) dyld Libsystem libiconv locale; 318 }; 319 }; 320 in with prevStage; stageFun 4 prevStage { 321 shell = "${pkgs.bash}/bin/bash"; 322 extraNativeBuildInputs = with pkgs; [ xz pkgs.bash ]; 323 extraBuildInputs = [ pkgs.darwin.CF ]; 324 libcxx = pkgs.libcxx; 325 326 extraPreHook = '' 327 export PATH_LOCALE=${pkgs.darwin.locale}/share/locale 328 ''; 329 overrides = persistent; 330 }; 331 332 stdenvDarwin = prevStage: let 333 pkgs = prevStage; 334 persistent = self: super: with prevStage; { 335 inherit 336 gnumake gzip gnused bzip2 gawk ed xz patch bash 337 ncurses libffi zlib llvm gmp pcre gnugrep 338 coreutils findutils diffutils patchutils; 339 340 llvmPackages_5 = super.llvmPackages_5 // (let 341 tools = super.llvmPackages_5.tools.extend (_: super: { 342 inherit (llvmPackages_5) llvm clang-unwrapped; 343 }); 344 libraries = super.llvmPackages_5.libraries.extend (_: _: { 345 inherit (llvmPackages_5) compiler-rt libcxx libcxxabi; 346 }); 347 in { inherit tools libraries; } // tools // libraries); 348 349 darwin = super.darwin // { 350 inherit (darwin) dyld ICU Libsystem libiconv; 351 } // lib.optionalAttrs (super.stdenv.targetPlatform == localSystem) { 352 inherit (darwin) binutils binutils-unwrapped cctools; 353 }; 354 } // lib.optionalAttrs (super.stdenv.targetPlatform == localSystem) { 355 # Need to get rid of these when cross-compiling. 356 inherit binutils binutils-unwrapped; 357 }; 358 in import ../generic rec { 359 name = "stdenv-darwin"; 360 361 inherit config; 362 inherit (pkgs.stdenv) fetchurlBoot; 363 364 buildPlatform = localSystem; 365 hostPlatform = localSystem; 366 targetPlatform = localSystem; 367 368 preHook = commonPreHook + '' 369 export NIX_COREFOUNDATION_RPATH=${pkgs.darwin.CF}/Library/Frameworks 370 export PATH_LOCALE=${pkgs.darwin.locale}/share/locale 371 ''; 372 373 __stdenvImpureHostDeps = commonImpureHostDeps; 374 __extraImpureHostDeps = commonImpureHostDeps; 375 376 initialPath = import ../common-path.nix { inherit pkgs; }; 377 shell = "${pkgs.bash}/bin/bash"; 378 379 cc = pkgs.llvmPackages.libcxxClang.override { 380 cc = pkgs.llvmPackages.clang-unwrapped; 381 }; 382 383 extraNativeBuildInputs = []; 384 extraBuildInputs = [ pkgs.darwin.CF ]; 385 386 extraAttrs = { 387 inherit platform bootstrapTools; 388 libc = pkgs.darwin.Libsystem; 389 shellPackage = pkgs.bash; 390 391 # This is used all over the place so I figured I'd just leave it here for now 392 secure-format-patch = ./darwin-secure-format.patch; 393 }; 394 395 allowedRequisites = (with pkgs; [ 396 xz.out xz.bin libcxx libcxxabi gmp.out gnumake findutils bzip2.out 397 bzip2.bin llvmPackages.llvm llvmPackages.llvm.lib llvmPackages.compiler-rt llvmPackages.compiler-rt.dev 398 zlib.out zlib.dev libffi.out coreutils ed diffutils gnutar 399 gzip ncurses.out ncurses.dev ncurses.man gnused bash gawk 400 gnugrep llvmPackages.clang-unwrapped llvmPackages.clang-unwrapped.lib patch pcre.out gettext 401 binutils.bintools darwin.binutils darwin.binutils.bintools 402 cc.expand-response-params 403 ]) ++ (with pkgs.darwin; [ 404 dyld Libsystem CF cctools ICU libiconv locale 405 ]); 406 407 overrides = lib.composeExtensions persistent (self: super: { 408 clang = cc; 409 llvmPackages = super.llvmPackages // { clang = cc; }; 410 inherit cc; 411 412 darwin = super.darwin // { 413 xnu = super.darwin.xnu.override { python = super.python.override { configd = null; }; }; 414 }; 415 }); 416 }; 417 418 stagesDarwin = [ 419 ({}: stage0) 420 stage1 421 stage2 422 stage3 423 stage4 424 (prevStage: { 425 inherit config overlays; 426 stdenv = stdenvDarwin prevStage; 427 }) 428 ]; 429}