pytrainer: unpin python 3.10
[NixPkgs.git] / pkgs / development / compilers / fpc / lazarus.nix
blobba2eeada5e466405598021df6bbd4b206d47ddd7
1 { stdenv, lib, fetchurl, makeWrapper, writeText
2 , fpc, gtk2, glib, pango, atk, gdk-pixbuf
3 , libXi, xorgproto, libX11, libXext
4 , gdb, gnumake, binutils
5 , withQt ? false, qtbase ? null, libqt5pas ? null, wrapQtAppsHook ? null
6 }:
8 # TODO:
9 #  1. the build date is embedded in the binary through `$I %DATE%` - we should dump that
11 let
12   version = "3.2-0";
14   # as of 2.0.10 a suffix is being added. That may or may not disappear and then
15   # come back, so just leave this here.
16   majorMinorPatch = v:
17     builtins.concatStringsSep "." (lib.take 2 (lib.splitVersion v));
19   overrides = writeText "revision.inc" (lib.concatStringsSep "\n" (lib.mapAttrsToList (k: v:
20     "const ${k} = '${v}';") {
21       # this is technically the SVN revision but as we don't have that replace
22       # it with the version instead of showing "Unknown"
23       RevisionStr = version;
24     }));
27 stdenv.mkDerivation rec {
28   pname = "lazarus-${LCL_PLATFORM}";
29   inherit version;
31   src = fetchurl {
32     url = "mirror://sourceforge/lazarus/Lazarus%20Zip%20_%20GZip/Lazarus%20${majorMinorPatch version}/lazarus-${version}.tar.gz";
33     sha256 = "69f43f0a10b9e09deea5f35094c73b84464b82d3f40d8a2fcfcb5a5ab03c6edf";
34   };
36   postPatch = ''
37     cp ${overrides} ide/${overrides.name}
38   '';
40   buildInputs = [
41     # we need gtk2 unconditionally as that is the default target when building applications with lazarus
42     fpc gtk2 glib libXi xorgproto
43     libX11 libXext pango atk
44     stdenv.cc gdk-pixbuf
45   ]
46   ++ lib.optionals withQt [ libqt5pas qtbase ];
48   # Disable parallel build, errors:
49   #  Fatal: (1018) Compilation aborted
50   enableParallelBuilding = false;
52   nativeBuildInputs = [
53     makeWrapper
54   ] ++ lib.optional withQt wrapQtAppsHook;
56   makeFlags = [
57     "FPC=fpc"
58     "PP=fpc"
59     "LAZARUS_INSTALL_DIR=${placeholder "out"}/share/lazarus/"
60     "INSTALL_PREFIX=${placeholder "out"}/"
61     "REQUIRE_PACKAGES+=tachartlazaruspkg"
62     "bigide"
63   ];
65   LCL_PLATFORM = if withQt then "qt5" else "gtk2";
67   NIX_LDFLAGS = lib.concatStringsSep " " ([
68     "-L${stdenv.cc.cc.lib}/lib"
69     "-lX11"
70     "-lXext"
71     "-lXi"
72     "-latk-1.0"
73     "-lc"
74     "-lcairo"
75     "-lgcc_s"
76     "-lgdk-x11-2.0"
77     "-lgdk_pixbuf-2.0"
78     "-lglib-2.0"
79     "-lgtk-x11-2.0"
80     "-lpango-1.0"
81   ]
82   ++ lib.optionals withQt [
83     "-L${lib.getLib libqt5pas}/lib"
84     "-lQt5Pas"
85   ]);
87   preBuild = ''
88     mkdir -p $out/share "$out/lazarus"
89     tar xf ${fpc.src} --strip-components=1 -C $out/share -m
90     substituteInPlace ide/packages/ideconfig/include/unix/lazbaseconf.inc \
91       --replace '/usr/fpcsrc' "$out/share/fpcsrc"
92   '';
94   postInstall = let
95     ldFlags = ''$(echo "$NIX_LDFLAGS" | sed -re 's/-rpath [^ ]+//g')'';
96   in ''
97     wrapProgram $out/bin/startlazarus \
98       --prefix NIX_LDFLAGS ' ' "${ldFlags}" \
99       --prefix NIX_LDFLAGS_${binutils.suffixSalt} ' ' "${ldFlags}" \
100       --prefix LCL_PLATFORM ' ' "$LCL_PLATFORM" \
101       --prefix PATH ':' "${lib.makeBinPath [ fpc gdb gnumake binutils ]}"
102   '';
104   meta = with lib; {
105     description = "Graphical IDE for the FreePascal language";
106     homepage = "https://www.lazarus.freepascal.org";
107     license = licenses.gpl2Plus ;
108     maintainers = with maintainers; [ raskin ];
109     platforms = platforms.linux;
110   };