I am running nix 2.0.4
as a single user setup on Ubuntu18.04.
This is my first try to create a nix derivation.
I am trying to create a nix derivation of the official .deb
package of draw.io with the following nix file based on the official nix packaging guide:
{
stdenv, fetchurl, lib, makeWrapper,
gtk3-x11, gnome2, atk, cairo,
gdk_pixbuf, glib, dbus_libs, xlibs,
nspr, nss, alsaLib, cups, fontconfig,
expat
}:
stdenv.mkDerivation rec {
version = "8.8.0";
name = "draw.io-${version}";
src = fetchurl {
url = "https://github.com/jgraph/drawio-desktop/releases/download/v${version}/draw.io-amd64-${version}.deb";
sha256 = "0zl4dg2hzy17gcpzdqkq5bah540r0asfvvif2h3cjjd4kc0kd887";
};
nativeBuildInputs = [ makeWrapper ];
sourceRoot = ".";
unpackCmd = ''
ar p "$src" data.tar.xz | tar xJ
'';
installPhase = ''
mkdir -p $out/bin
cp -R usr/share opt $out/
# fix the path in the desktop file
substituteInPlace \
$out/share/applications/draw.io.desktop \
--replace /opt/ $out/opt/
# symlink the binary to bin/
ln -s $out/opt/draw.io/draw.io $out/bin/draw.io
'';
preFixup = let
lpath = lib.makeLibraryPath [
alsaLib
atk
cairo
cups
dbus_libs
expat
fontconfig
gtk3-x11
gnome2.GConf
gnome2.pango
gdk_pixbuf
glib
nspr
nss
stdenv.cc.cc.lib
xlibs.libX11
xlibs.libxcb
xlibs.libXi
xlibs.libXcursor
xlibs.libXdamage
xlibs.libXrandr
xlibs.libXcomposite
xlibs.libXext
xlibs.libXfixes
xlibs.libXrender
xlibs.libXtst
xlibs.libXScrnSaver
];
in ''
patchelf \
--set-interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" \
--set-rpath "$out/opt/draw.io:${lpath}" \
$out/opt/draw.io/draw.io
'';
meta = with stdenv.lib; {
homepage = https://github.com/jgraph/drawio;
description = "draw.io diagramming tool";
license = licenses.asl20;
platforms = platforms.linux;
maintainers = [ maintainers.fishi0x01 ];
};
}
The package gets built and installed without issues via:
nix-build -A draw-io
nix-env -f . -iA draw-io
Sadly, the resulting binary crashes:
$ draw.io
Trace/breakpoint trap (core dumped)
From the syslog I only get:
kernel: [200185.947695] traps: Chrome_IOThread[7044] trap int3 ip:267aa43 sp:7ff1c83a4450 error:0 in draw.io[1802000+3733000]
Does anybody have a pointer on how I could proceed on that one? Am i missing anything crucial in installPhase
of preFixup
stage?