Merge pull request #188866 from fourplusone/fpc-darwin

fpc: support darwin

authored by superherointj and committed by GitHub ee6767ac cc9c837a

+63 -6
+17
pkgs/development/compilers/fpc/binary-builder-darwin.sh
··· 1 + source $stdenv/setup 2 + 3 + pkgdir=$(pwd)/pkg 4 + deploydir=$(pwd)/deploy 5 + 6 + undmg $src 7 + mkdir $out 8 + mkdir $pkgdir 9 + mkdir $deploydir 10 + 11 + pkg=*.mpkg/Contents/Packages/*.pkg 12 + xar -xf $pkg -C $pkgdir 13 + pushd $deploydir 14 + cat $pkgdir/Payload | gunzip -dc | cpio -i 15 + popd 16 + echo $deploydir 17 + cp -r $deploydir/usr/local/* $out
+19 -2
pkgs/development/compilers/fpc/binary.nix
··· 1 - { stdenv, fetchurl }: 1 + { stdenv, fetchurl, undmg, cpio, xar, lib }: 2 2 3 3 stdenv.mkDerivation rec { 4 4 pname = "fpc-binary"; ··· 20 20 url = "mirror://sourceforge/project/freepascal/Linux/${version}/fpc-${version}.aarch64-linux.tar"; 21 21 sha256 = "b39470f9b6b5b82f50fc8680a5da37d2834f2129c65c24c5628a80894d565451"; 22 22 } 23 + else if stdenv.isDarwin then 24 + fetchurl { 25 + url = "mirror://sourceforge/project/freepascal/Mac%20OS%20X/${version}/fpc-${version}.intelarm64-macosx.dmg"; 26 + sha256 = "05d4510c8c887e3c68de20272abf62171aa5b2ef1eba6bce25e4c0bc41ba8b7d"; 27 + } 23 28 else throw "Not supported on ${stdenv.hostPlatform.system}."; 24 29 25 - builder = ./binary-builder.sh; 30 + 31 + nativeBuildInputs = lib.optionals stdenv.hostPlatform.isDarwin [ 32 + undmg 33 + xar 34 + cpio 35 + ]; 36 + 37 + builder = 38 + if stdenv.hostPlatform.isLinux then 39 + ./binary-builder.sh 40 + else if stdenv.hostPlatform.isDarwin then 41 + ./binary-builder-darwin.sh 42 + else throw "Not supported on ${stdenv.hostPlatform}."; 26 43 27 44 meta = { 28 45 description = "Free Pascal Compiler from a binary distribution";
+24 -4
pkgs/development/compilers/fpc/default.nix
··· 1 - { lib, stdenv, fetchurl, gawk, fetchpatch }: 1 + { lib, stdenv, fetchurl, gawk, fetchpatch, undmg, cpio, xar, darwin, libiconv }: 2 2 3 - let startFPC = import ./binary.nix { inherit stdenv fetchurl; }; in 3 + let startFPC = import ./binary.nix { inherit stdenv fetchurl undmg cpio xar lib; }; in 4 4 5 5 stdenv.mkDerivation rec { 6 6 version = "3.2.2"; ··· 11 11 sha256 = "85ef993043bb83f999e2212f1bca766eb71f6f973d362e2290475dbaaf50161f"; 12 12 }; 13 13 14 - buildInputs = [ startFPC gawk ]; 14 + buildInputs = [ startFPC gawk ] 15 + ++ lib.optionals stdenv.isDarwin [ 16 + libiconv 17 + darwin.apple_sdk.frameworks.CoreFoundation 18 + ]; 19 + 15 20 glibc = stdenv.cc.libc.out; 16 21 17 22 # Patch paths for linux systems. Other platforms will need their own patches. ··· 29 34 # substitute the markers set by the mark-paths patch 30 35 substituteInPlace fpcsrc/compiler/systems/t_linux.pas --subst-var-by dynlinker-prefix "${glibc}" 31 36 substituteInPlace fpcsrc/compiler/systems/t_linux.pas --subst-var-by syslibpath "${glibc}/lib" 37 + # Replace the `codesign --remove-signature` command with a custom script, since `codesign` is not available 38 + # in nixpkgs 39 + substituteInPlace fpcsrc/compiler/Makefile \ 40 + --replace \ 41 + "\$(CODESIGN) --remove-signature" \ 42 + "${./remove-signature.sh}" \ 43 + --replace "ifneq (\$(CODESIGN),)" "ifeq (\$(OS_TARGET), darwin)" 32 44 ''; 45 + 46 + NIX_LDFLAGS = lib.optionalString 47 + stdenv.isDarwin (with darwin.apple_sdk.frameworks; "-F${CoreFoundation}/Library/Frameworks"); 33 48 34 49 makeFlags = [ "NOGDB=1" "FPC=${startFPC}/bin/fpc" ]; 35 50 ··· 41 56 done 42 57 mkdir -p $out/lib/fpc/etc/ 43 58 $out/lib/fpc/*/samplecfg $out/lib/fpc/${version} $out/lib/fpc/etc/ 59 + 60 + # Generate config files in /etc since on darwin, ppc* does not follow symlinks 61 + # to resolve the location of /etc 62 + mkdir -p $out/etc 63 + $out/lib/fpc/*/samplecfg $out/lib/fpc/${version} $out/etc 44 64 ''; 45 65 46 66 passthru = { ··· 52 72 homepage = "https://www.freepascal.org"; 53 73 maintainers = [ maintainers.raskin ]; 54 74 license = with licenses; [ gpl2 lgpl2 ]; 55 - platforms = platforms.linux; 75 + platforms = platforms.unix; 56 76 }; 57 77 }
+3
pkgs/development/compilers/fpc/remove-signature.sh
··· 1 + source $stdenv/setup 2 + 3 + codesign_allocate -r -i "$1" -o "$1"