Merge pull request #302387 from wegank/darwin-stdenv-2

stdenv.darwin: bootstrap darwin using updated tools (resurrected)

authored by Bernardo Meurer and committed by GitHub f682fc11 cea802fc

+53 -149
+20 -10
pkgs/stdenv/darwin/bootstrap-files/aarch64-apple-darwin.nix
··· 1 - let 2 - fetch = { file, sha256, executable ? true }: import <nix/fetchurl.nix> { 3 - url = "http://tarballs.nixos.org/stdenv-darwin/aarch64/20acd4c4f14040485f40e55c0a76c186aa8ca4f3/${file}"; 4 - inherit sha256 executable; 5 - }; in 1 + # Autogenerated by maintainers/scripts/bootstrap-files/refresh-tarballs.bash as: 2 + # $ ./refresh-tarballs.bash --targets=aarch64-apple-darwin 3 + # 4 + # Metadata: 5 + # - nixpkgs revision: d03a4482228d4d6dbd2d4b425b6dfcd49ebe765f 6 + # - hydra build: https://hydra.nixos.org/job/nixpkgs/trunk/stdenvBootstrapTools.aarch64-apple-darwin.build/latest 7 + # - resolved hydra build: https://hydra.nixos.org/build/255282138 8 + # - instantiated derivation: /nix/store/cahnprnkg9z2aij3hj4rkbkc4l8190mf-stdenv-bootstrap-tools.drv 9 + # - output directory: /nix/store/zxxcz7sza5ypy061rsg7cmr7h0a96hbb-stdenv-bootstrap-tools 10 + # - build time: Wed, 03 Apr 2024 07:59:44 +0000 6 11 { 7 - sh = fetch { file = "sh"; sha256 = "17m3xrlbl99j3vm7rzz3ghb47094dyddrbvs2a6jalczvmx7spnj"; }; 8 - bzip2 = fetch { file = "bzip2"; sha256 = "1khs8s5klf76plhlvlc1ma838r8pc1qigk9f5bdycwgbn0nx240q"; }; 9 - mkdir = fetch { file = "mkdir"; sha256 = "1m9nk90paazl93v43myv2ay68c1arz39pqr7lk5ddbgb177hgg8a"; }; 10 - cpio = fetch { file = "cpio"; sha256 = "17pxq61yjjvyd738fy9f392hc9cfzkl612sdr9rxr3v0dgvm8y09"; }; 11 - tarball = fetch { file = "bootstrap-tools.cpio.bz2"; sha256 = "1v2332k33akm6mrm4bj749rxnnmc2pkbgcslmd0bbkf76bz2ildy"; executable = false; }; 12 + bootstrapTools = import <nix/fetchurl.nix> { 13 + url = "http://tarballs.nixos.org/stdenv/aarch64-apple-darwin/d03a4482228d4d6dbd2d4b425b6dfcd49ebe765f/bootstrap-tools.tar.xz"; 14 + hash = "sha256-a37OgMdTHjFyKs4UTxoD7zx6Te3A7zsSjhbFHzbNxQ8="; 15 + }; 16 + unpack = import <nix/fetchurl.nix> { 17 + url = "http://tarballs.nixos.org/stdenv/aarch64-apple-darwin/d03a4482228d4d6dbd2d4b425b6dfcd49ebe765f/unpack.nar.xz"; 18 + hash = "sha256-XCVy6TMDJ1DKFnhIT1NHzdQUjY/TPKLV67Zi/ANIpms="; 19 + name = "unpack"; 20 + unpack = true; 21 + }; 12 22 }
+20 -10
pkgs/stdenv/darwin/bootstrap-files/x86_64-apple-darwin.nix
··· 1 - let 2 - fetch = { file, sha256, executable ? true }: import <nix/fetchurl.nix> { 3 - url = "http://tarballs.nixos.org/stdenv-darwin/x86_64/c253216595572930316f2be737dc288a1da22558/${file}"; 4 - inherit sha256 executable; 5 - }; in 1 + # Autogenerated by maintainers/scripts/bootstrap-files/refresh-tarballs.bash as: 2 + # $ ./refresh-tarballs.bash --targets=x86_64-apple-darwin 3 + # 4 + # Metadata: 5 + # - nixpkgs revision: d03a4482228d4d6dbd2d4b425b6dfcd49ebe765f 6 + # - hydra build: https://hydra.nixos.org/job/nixpkgs/trunk/stdenvBootstrapTools.x86_64-apple-darwin.build/latest 7 + # - resolved hydra build: https://hydra.nixos.org/build/255281731 8 + # - instantiated derivation: /nix/store/44wnr0ikrbcxkakfqhhm2cz6gsh6wjni-stdenv-bootstrap-tools.drv 9 + # - output directory: /nix/store/lsl9rl3zj9nr318w471vvmlvxzj21b2k-stdenv-bootstrap-tools 10 + # - build time: Wed, 03 Apr 2024 07:56:15 +0000 6 11 { 7 - sh = fetch { file = "sh"; sha256 = "sha256-igMAVEfumFv/LUNTGfNi2nSehgTNIP4Sg+f3L7u6SMA="; }; 8 - bzip2 = fetch { file = "bzip2"; sha256 = "sha256-K3rhkJZipudT1Jgh+l41Y/fNsMkrPtiAsNRDha/lpZI="; }; 9 - mkdir = fetch { file = "mkdir"; sha256 = "sha256-VddFELwLDJGNADKB1fWwWPBtIAlEUgJv2hXRmC4NEeM="; }; 10 - cpio = fetch { file = "cpio"; sha256 = "sha256-SWkwvLaFyV44kLKL2nx720SvcL4ej/p2V/bX3uqAGO0="; }; 11 - tarball = fetch { file = "bootstrap-tools.cpio.bz2"; sha256 = "sha256-kRC/bhCmlD4L7KAvJQgcukk7AinkMz4IwmG1rqlh5tA="; executable = false; }; 12 + bootstrapTools = import <nix/fetchurl.nix> { 13 + url = "http://tarballs.nixos.org/stdenv/x86_64-apple-darwin/d03a4482228d4d6dbd2d4b425b6dfcd49ebe765f/bootstrap-tools.tar.xz"; 14 + hash = "sha256-3OBigzlbu/Z6g8r7hsOWg95HTv7IJw9Nvbamwvw+88w="; 15 + }; 16 + unpack = import <nix/fetchurl.nix> { 17 + url = "http://tarballs.nixos.org/stdenv/x86_64-apple-darwin/d03a4482228d4d6dbd2d4b425b6dfcd49ebe765f/unpack.nar.xz"; 18 + hash = "sha256-93GK8LjjgUBknxsylfGVr0DG4AbWVIQEIWrwxhDW07k="; 19 + name = "unpack"; 20 + unpack = true; 21 + }; 12 22 }
+12 -15
pkgs/stdenv/darwin/default.nix
··· 52 52 inherit system; 53 53 54 54 name = "bootstrap-tools"; 55 - builder = bootstrapFiles.sh; # Not a filename! Attribute 'sh' on bootstrapFiles 56 - args = if localSystem.isAarch64 then [ ./unpack-bootstrap-tools-aarch64.sh ] else [ ./unpack-bootstrap-tools.sh ]; 55 + builder = "${bootstrapFiles.unpack}/bin/bash"; 56 + 57 + args = [ 58 + "${bootstrapFiles.unpack}/bootstrap-tools-unpack.sh" 59 + bootstrapFiles.bootstrapTools 60 + ]; 57 61 58 - inherit (bootstrapFiles) mkdir bzip2 cpio tarball; 62 + PATH = lib.makeBinPath [ 63 + (placeholder "out") 64 + bootstrapFiles.unpack 65 + ]; 59 66 60 67 __impureHostDeps = commonImpureHostDeps; 61 68 } // lib.optionalAttrs config.contentAddressedByDefault { ··· 226 233 ccWrapperStdenv = self.stdenv; 227 234 228 235 bash = bootstrapTools; 229 - 230 236 coreutils = bootstrapTools; 237 + cpio = bootstrapTools; 231 238 gnugrep = bootstrapTools; 232 - 233 - # Either pbzx or Libsystem is required from bootstrap tools (one is used building the other). 234 - pbzx = if localSystem.isAarch64 then bootstrapTools else super.pbzx; 235 - cpio = self.stdenv.mkDerivation { 236 - name = "bootstrap-stage0-cpio"; 237 - buildCommand = '' 238 - mkdir -p $out/bin 239 - ln -s ${bootstrapFiles.cpio} $out/bin/cpio 240 - ''; 241 - passthru.isFromBootstrapFiles = true; 242 - }; 239 + pbzx = bootstrapTools; 243 240 244 241 darwin = super.darwin.overrideScope (selfDarwin: superDarwin: { 245 242 # Prevent CF from being propagated to the initial stdenv. Packages that require it
+1 -3
pkgs/stdenv/darwin/make-bootstrap-tools.nix
··· 395 395 }; 396 396 397 397 # The ultimate test: bootstrap a whole stdenv from the tools specified above and get a package set out of it 398 - # TODO: uncomment once https://github.com/NixOS/nixpkgs/issues/222717 is resolved 399 - /* 398 + # eg: nix-build -A freshBootstrapTools.test-pkgs.stdenv 400 399 test-pkgs = import test-pkgspath { 401 400 # if the bootstrap tools are for another platform, we should be testing 402 401 # that platform. ··· 406 405 args' = args // { inherit bootstrapFiles; }; 407 406 in (import (test-pkgspath + "/pkgs/stdenv/darwin") args'); 408 407 }; 409 - */ 410 408 }
-57
pkgs/stdenv/darwin/unpack-bootstrap-tools-aarch64.sh
··· 1 - set -euo pipefail 2 - 3 - # Unpack the bootstrap tools tarball. 4 - echo Unpacking the bootstrap tools... 5 - $mkdir $out 6 - $bzip2 -d < $tarball | (cd $out && $cpio -i) 7 - 8 - export PATH=$out/bin 9 - 10 - # Fix codesign wrapper paths 11 - sed -i \ 12 - -e "1c\ 13 - #!$out/bin/bash" \ 14 - -e "s|[^( ]*\bsigtool\b|$out/bin/sigtool|g" \ 15 - $out/bin/codesign 16 - 17 - updateInstallName() { 18 - local path="$1" 19 - 20 - cp "$path" "$path.new" 21 - install_name_tool -id "$path" "$path.new" 22 - # workaround for https://github.com/NixOS/nixpkgs/issues/294518 23 - # libc++.1.0.dylib contains wrong LC_RPATH 24 - if [[ ${path} == *libc++.1.0.dylib ]]; then 25 - install_name_tool -add_rpath @loader_path/.. "${path}.new" 26 - fi 27 - codesign -f -i "$(basename "$path")" -s - "$path.new" 28 - mv -f "$path.new" "$path" 29 - } 30 - 31 - find $out 32 - 33 - ln -s bash $out/bin/sh 34 - ln -s bzip2 $out/bin/bunzip2 35 - 36 - find $out/lib -type f -name '*.dylib' -print0 | while IFS= read -r -d $'\0' lib; do 37 - updateInstallName "$lib" 38 - done 39 - 40 - # Provide a gunzip script. 41 - cat > $out/bin/gunzip <<EOF 42 - #!$out/bin/sh 43 - exec $out/bin/gzip -d "\$@" 44 - EOF 45 - chmod +x $out/bin/gunzip 46 - 47 - # Provide fgrep/egrep. 48 - echo "#! $out/bin/sh" > $out/bin/egrep 49 - echo "exec $out/bin/grep -E \"\$@\"" >> $out/bin/egrep 50 - echo "#! $out/bin/sh" > $out/bin/fgrep 51 - echo "exec $out/bin/grep -F \"\$@\"" >> $out/bin/fgrep 52 - 53 - cat >$out/bin/dsymutil << EOF 54 - #!$out/bin/sh 55 - EOF 56 - 57 - chmod +x $out/bin/egrep $out/bin/fgrep $out/bin/dsymutil
-54
pkgs/stdenv/darwin/unpack-bootstrap-tools.sh
··· 1 - set -e 2 - 3 - # Unpack the bootstrap tools tarball. 4 - echo Unpacking the bootstrap tools... 5 - $mkdir $out 6 - $bzip2 -d < $tarball | (cd $out && $cpio -i) 7 - 8 - # Set the ELF interpreter / RPATH in the bootstrap binaries. 9 - echo Patching the tools... 10 - 11 - export PATH=$out/bin 12 - 13 - for i in $out/bin/*; do 14 - if ! test -L $i; then 15 - echo patching $i 16 - install_name_tool -add_rpath $out/lib $i || true 17 - fi 18 - done 19 - 20 - for i in $out/lib/*.dylib $out/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation; do 21 - if test ! -L "$i" -a "$i" != "$out/lib/libSystem*.dylib"; then 22 - echo "Patching $i" 23 - 24 - id=$(otool -D "$i" | tail -n 1) 25 - install_name_tool -id "$(dirname $i)/$(basename $id)" $i 26 - 27 - libs=$(otool -L "$i" | tail -n +2 | grep -v libSystem | cat) 28 - if [ -n "$libs" ]; then 29 - install_name_tool -add_rpath $out/lib $i 30 - fi 31 - fi 32 - done 33 - 34 - ln -s bash $out/bin/sh 35 - ln -s bzip2 $out/bin/bunzip2 36 - 37 - # Provide a gunzip script. 38 - cat > $out/bin/gunzip <<EOF 39 - #!$out/bin/sh 40 - exec $out/bin/gzip -d "\$@" 41 - EOF 42 - chmod +x $out/bin/gunzip 43 - 44 - # Provide fgrep/egrep. 45 - echo "#! $out/bin/sh" > $out/bin/egrep 46 - echo "exec $out/bin/grep -E \"\$@\"" >> $out/bin/egrep 47 - echo "#! $out/bin/sh" > $out/bin/fgrep 48 - echo "exec $out/bin/grep -F \"\$@\"" >> $out/bin/fgrep 49 - 50 - cat >$out/bin/dsymutil << EOF 51 - #!$out/bin/sh 52 - EOF 53 - 54 - chmod +x $out/bin/egrep $out/bin/fgrep $out/bin/dsymutil