nixpkgs mirror (for testing) github.com/NixOS/nixpkgs
nix
at devShellTools-shell 84 lines 2.5 kB view raw
1{ 2 lib, 3 apple-sdk, 4 apple-sdk_12, 5 bison, 6 buildPackages, 7 flex, 8 meson, 9 mkAppleDerivation, 10 replaceVars, 11 stdenv, 12 stdenvNoCC, 13}: 14 15let 16 Libc = apple-sdk.sourceRelease "Libc"; 17 18 # Older versions of xnu are missing required headers. The one for the 11.3 SDK doesn’t define a needed function 19 # that was added in 11.3. This version of xnu has everything that’s needed. 20 xnu = apple-sdk_12.sourceRelease "xnu"; 21 22 privateHeaders = stdenvNoCC.mkDerivation { 23 name = "adv_cmds-deps-private-headers"; 24 25 buildCommand = '' 26 install -D -t "$out/include/os" \ 27 '${Libc}/os/assumes.h' \ 28 '${xnu}/libkern/os/base_private.h' 29 ''; 30 }; 31 32 # bootstrap_cmds is used to build libkrb5, which is a transitive dependency of Meson due to OpenLDAP. 33 # This causes an infinite recursion unless Meson’s tests are disabled. 34 mkAppleDerivation' = mkAppleDerivation.override { 35 meson = meson.overrideAttrs { doInstallCheck = false; }; 36 }; 37in 38mkAppleDerivation' { 39 releaseName = "bootstrap_cmds"; 40 41 outputs = [ 42 "out" 43 "man" 44 ]; 45 46 xcodeHash = "sha256-N28WLkFo8fXiQqqpmRmOBE3BzqXHIy94fhZIxEkmOw4="; 47 xcodeProject = "mig.xcodeproj"; 48 49 patches = [ 50 # Make sure that `mig` in nixpkgs uses the correct clang 51 (replaceVars ./patches/0001-Specify-MIGCC-for-use-with-substitute.patch { 52 clang = "${lib.getBin buildPackages.targetPackages.clang}/bin/${buildPackages.targetPackages.clang.targetPrefix}clang"; 53 }) 54 # `mig` by default only removes the working directory at the end of the script. 55 # If an error happens, it is left behind. Always clean it up. 56 ./patches/0002-Always-remove-working-directory.patch 57 ]; 58 59 postPatch = '' 60 # Fix the name to something Meson will like. 61 substituteInPlace migcom.tproj/lexxer.l \ 62 --replace-fail 'y.tab.h' 'parser.tab.h' 63 ''; 64 65 env.NIX_CFLAGS_COMPILE = "-I${privateHeaders}/include"; 66 67 nativeBuildInputs = [ 68 bison 69 flex 70 ]; 71 72 postInstall = '' 73 mv "$out/bin/mig.sh" "$out/bin/mig" 74 chmod a+x "$out/bin/mig" 75 patchShebangs --build "$out/bin/mig" 76 77 substituteInPlace "$out/bin/mig" \ 78 --replace-fail 'arch=`/usr/bin/arch`' 'arch=${stdenv.targetPlatform.darwinArch}' \ 79 --replace-fail '/usr/bin/mktemp' '${lib.getBin buildPackages.coreutils}/bin/mktemp' \ 80 --replace-fail '/usr/bin/xcrun' '${buildPackages.xcbuild.xcrun}/bin/xcrun' 81 ''; 82 83 meta.description = "Contains mig command for generating headers from definitions"; 84}