Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
at 23.05 77 lines 2.7 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 substituteInPlace fpcsrc/compiler/Makefile \ 40 --replace \ 41 "\$(CODESIGN) --remove-signature" \ 42 "${./remove-signature.sh}" \ 43 --replace "ifneq (\$(CODESIGN),)" "ifeq (\$(OS_TARGET), darwin)" 44 ''; 45 46 NIX_LDFLAGS = lib.optionalString 47 stdenv.isDarwin (with darwin.apple_sdk.frameworks; "-F${CoreFoundation}/Library/Frameworks"); 48 49 makeFlags = [ "NOGDB=1" "FPC=${startFPC}/bin/fpc" ]; 50 51 installFlags = [ "INSTALL_PREFIX=\${out}" ]; 52 53 postInstall = '' 54 for i in $out/lib/fpc/*/ppc*; do 55 ln -fs $i $out/bin/$(basename $i) 56 done 57 mkdir -p $out/lib/fpc/etc/ 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 64 ''; 65 66 passthru = { 67 bootstrap = startFPC; 68 }; 69 70 meta = with lib; { 71 description = "Free Pascal Compiler from a source distribution"; 72 homepage = "https://www.freepascal.org"; 73 maintainers = [ maintainers.raskin ]; 74 license = with licenses; [ gpl2 lgpl2 ]; 75 platforms = platforms.unix; 76 }; 77}