Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
at 24.05-beta 80 lines 2.8 kB view raw
1{ lib, stdenv, fetchurl, gawk, fetchpatch, undmg, cpio, xar, darwin, libiconv }: 2 3let startFPC = import ./binary.nix { inherit stdenv fetchurl undmg cpio xar lib; }; in 4 5stdenv.mkDerivation rec { 6 version = "3.2.2"; 7 pname = "fpc"; 8 9 src = fetchurl { 10 url = "mirror://sourceforge/freepascal/fpcbuild-${version}.tar.gz"; 11 sha256 = "85ef993043bb83f999e2212f1bca766eb71f6f973d362e2290475dbaaf50161f"; 12 }; 13 14 buildInputs = [ startFPC gawk ] 15 ++ lib.optionals stdenv.isDarwin [ 16 libiconv 17 darwin.apple_sdk.frameworks.CoreFoundation 18 ]; 19 20 glibc = stdenv.cc.libc.out; 21 22 # Patch paths for linux systems. Other platforms will need their own patches. 23 patches = [ 24 ./mark-paths.patch # mark paths for later substitution in postPatch 25 ] ++ lib.optional stdenv.isAarch64 (fetchpatch { 26 # backport upstream patch for aarch64 glibc 2.34 27 url = "https://gitlab.com/freepascal.org/fpc/source/-/commit/a20a7e3497bccf3415bf47ccc55f133eb9d6d6a0.patch"; 28 hash = "sha256-xKTBwuOxOwX9KCazQbBNLhMXCqkuJgIFvlXewHY63GM="; 29 stripLen = 1; 30 extraPrefix = "fpcsrc/"; 31 }); 32 33 postPatch = '' 34 # substitute the markers set by the mark-paths patch 35 substituteInPlace fpcsrc/compiler/systems/t_linux.pas --subst-var-by dynlinker-prefix "${glibc}" 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 # Remove the -no_uuid strip flag which does not work on llvm-strip, only 40 # Apple strip. 41 substituteInPlace fpcsrc/compiler/Makefile \ 42 --replace \ 43 "\$(CODESIGN) --remove-signature" \ 44 "${./remove-signature.sh}" \ 45 --replace "ifneq (\$(CODESIGN),)" "ifeq (\$(OS_TARGET), darwin)" \ 46 --replace "-no_uuid" "" 47 ''; 48 49 NIX_LDFLAGS = lib.optionalString 50 stdenv.isDarwin (with darwin.apple_sdk.frameworks; "-F${CoreFoundation}/Library/Frameworks"); 51 52 makeFlags = [ "NOGDB=1" "FPC=${startFPC}/bin/fpc" ]; 53 54 installFlags = [ "INSTALL_PREFIX=\${out}" ]; 55 56 postInstall = '' 57 for i in $out/lib/fpc/*/ppc*; do 58 ln -fs $i $out/bin/$(basename $i) 59 done 60 mkdir -p $out/lib/fpc/etc/ 61 $out/lib/fpc/*/samplecfg $out/lib/fpc/${version} $out/lib/fpc/etc/ 62 63 # Generate config files in /etc since on darwin, ppc* does not follow symlinks 64 # to resolve the location of /etc 65 mkdir -p $out/etc 66 $out/lib/fpc/*/samplecfg $out/lib/fpc/${version} $out/etc 67 ''; 68 69 passthru = { 70 bootstrap = startFPC; 71 }; 72 73 meta = with lib; { 74 description = "Free Pascal Compiler from a source distribution"; 75 homepage = "https://www.freepascal.org"; 76 maintainers = [ maintainers.raskin ]; 77 license = with licenses; [ gpl2 lgpl2 ]; 78 platforms = platforms.unix; 79 }; 80}