Hello
I am trying to package a software built with lazarus IDE.
I can compile correctly with nixos, however when I try to compile it on nix on top of archlinux, it fails.
this is one of my first attempts to package software for nix, so maybe you’ll find it is not so clean, in that case tell me how I could improve it…
Here are the files I use:
$ cat nix/default-gtk.nix
with import <nixpkgs> {};
libsForQt5.callPackage ./build-gtk.nix { }
$ cat nix/build-gtk.nix
{stdenv, lib, autoPatchelfHook, lazarus, fpc, pango, atk, alsa-lib, glib, gdk-pixbuf, gtk2, cairo, glibc ,libX11, fetchurl,p7zip}:
stdenv.mkDerivation rec {
name = "AyEmul";
src = fetchurl {
url = "https://bulba.untergrund.net/Ay_Emul29b32.src.7z";
sha256 = "sha256-g4zVhpbQx9hcTfgvceoRSbN+MRV1rPzWlUnDR0lfSXY=";
};
nativeBuildInputs = [ autoPatchelfHook lazarus fpc glibc cairo pango atk alsa-lib glib gdk-pixbuf gtk2] ;
NIX_LDFLAGS = "--as-needed -rpath ${lib.makeLibraryPath buildInputs}";
sourceRoot = ".";
unpackCmd = ''
${p7zip}/bin/7zr x $curSrc
'';
buildInputs = [ pango cairo glib atk gtk2 libX11 gdk-pixbuf p7zip ];
buildPhase = ''
ldir="${lazarus}/"
HOME=/tmp/lazhome lazbuild Ay_Emul.lpi --lazarusdir="$ldir/share/lazarus/"
'';
installPhase = ''
mkdir -p $out/bin/
cp ./lib/x86_64-linux/Ay_Emul $out/bin/Ay_Emul
'';
}
I use this command:
$ nix-env -f nix/default-gtk.nix -i
It fails with:
(9022) Compiling resource /tmp/nix-build-AyEmul.drv-0/lib/x86_64-linux/Ay_Emul.or
(9015) Linking /tmp/nix-build-AyEmul.drv-0/lib/x86_64-linux/Ay_Emul
/nix/store/rq6bh3qfrqnyqwik0w3q6w180zg3w2pa-binutils-2.38/bin/ld: /lib//libcairo.so: undefined reference to `hypot@GLIBC_2.35'
/tmp/nix-build-AyEmul.drv-0/Ay_Emul.lpr(69,1) Error: (9013) Error while linking
/tmp/nix-build-AyEmul.drv-0/Ay_Emul.lpr(69,1) Fatal: (10026) There were 1 errors compiling module, stopping
It seems that lazarus used /lib/libcairo.so from my arch and not the one from the nix store
Do you know how I could solve this ?
Thank you