nixpkgs mirror (for testing) github.com/NixOS/nixpkgs
nix
at devShellTools-shell 100 lines 2.6 kB view raw
1{ 2 lib, 3 apple-sdk, 4 apple-sdk_13, 5 bzip2, 6 libmd, 7 libresolv, 8 libutil, 9 libxo, 10 mkAppleDerivation, 11 ncurses, 12 pkg-config, 13 shell_cmds, 14 stdenvNoCC, 15 xz, 16 zlib, 17}: 18 19let 20 Libc = apple-sdk.sourceRelease "Libc"; 21 Libc_13 = apple-sdk_13.sourceRelease "Libc"; 22 23 CommonCrypto = apple-sdk.sourceRelease "CommonCrypto"; 24 libplatform = apple-sdk.sourceRelease "libplatform"; 25 xnu = apple-sdk.sourceRelease "xnu"; 26 27 privateHeaders = stdenvNoCC.mkDerivation { 28 name = "text_cmds-deps-private-headers"; 29 30 buildCommand = '' 31 install -D -t "$out/include" \ 32 '${libplatform}/private/_simple.h' \ 33 '${Libc_13}/include/vis.h' 34 install -D -t "$out/include/os" \ 35 '${Libc}/os/assumes.h' \ 36 '${xnu}/libkern/os/base_private.h' 37 install -D -t "$out/include/CommonCrypto" \ 38 '${CommonCrypto}/include/Private/CommonDigestSPI.h' 39 ''; 40 }; 41in 42mkAppleDerivation { 43 releaseName = "text_cmds"; 44 45 outputs = [ 46 "out" 47 "man" 48 ]; 49 50 xcodeHash = "sha256-dZ+yJyfflhmUyx3gitRXC115QxS87SGC4/HjMa199Ts="; 51 52 postPatch = '' 53 # Improve compatiblity with libmd in nixpkgs. 54 substituteInPlace md5/md5.c \ 55 --replace-fail '<sha224.h>' '<sha2.h>' \ 56 --replace-fail SHA224_Init SHA224Init \ 57 --replace-fail SHA224_Update SHA224Update \ 58 --replace-fail SHA224_End SHA224End \ 59 --replace-fail SHA224_Data SHA224Data \ 60 --replace-fail SHA224_CTX SHA2_CTX \ 61 --replace-fail '<sha384.h>' '<sha512.h>' \ 62 --replace-fail 'const void *, unsigned int, char *' 'const uint8_t *, size_t, char *' 63 '' 64 + lib.optionalString (lib.versionOlder (lib.getVersion apple-sdk) "13.0") '' 65 # Backport vis APIs from the 13.3 SDK (needed by vis). 66 cp '${Libc_13}/gen/FreeBSD/vis.c' vis/vis-libc.c 67 # Backport errx APIs from the 13.3 SDK (needed by lots of things). 68 mkdir sys 69 cp '${Libc_13}/gen/FreeBSD/err.c' err-libc.c 70 cp '${Libc_13}/include/err.h' err.h 71 cp '${Libc_13}/fbsdcompat/sys/cdefs.h' sys/cdefs.h 72 substituteInPlace err.h \ 73 --replace-fail '__cold' "" 74 touch namespace.h un-namespace.h libc_private.h 75 ''; 76 77 env.NIX_CFLAGS_COMPILE = "-I${privateHeaders}/include"; 78 79 nativeBuildInputs = [ pkg-config ]; 80 81 buildInputs = [ 82 bzip2 83 libmd 84 libresolv 85 libutil 86 libxo 87 ncurses 88 xz 89 zlib 90 ]; 91 92 postInstall = '' 93 # Patch the shebangs to use `sh` from shell_cmds. 94 HOST_PATH='${lib.getBin shell_cmds}/bin' patchShebangs --host "$out/bin" 95 ''; 96 97 meta = { 98 description = "Text commands for Darwin"; 99 }; 100}