Package a prebuilt eclipse based app by nix

I knew the app is based on eclipse, so I have taken a look for built-eclipse in nixpkgs and code the wrapper. But now, it still has some problem.

!SESSION 2020-07-28 13:58:55.349 -----------------------------------------------
eclipse.buildId=5.6.2.200518-aa79d0918f
java.version=1.8.0_222
java.vendor=Oracle Corporation
BootLoader constants: OS=linux, ARCH=x86_64, WS=gtk, NL=en_US
Command-line arguments:  -os linux -ws gtk -arch x86_64

!ENTRY org.eclipse.osgi 4 0 2020-07-28 13:58:56.612
!MESSAGE Application error
!STACK 1
java.lang.UnsatisfiedLinkError: org.eclipse.swt.internal.gtk.OS._cachejvmptr()V
	at org.eclipse.swt.internal.gtk.OS._cachejvmptr(Native Method)
	at org.eclipse.swt.internal.gtk.OS.cachejvmptr(OS.java:495)
	at org.eclipse.swt.internal.gtk.OS.<clinit>(OS.java:93)
	at org.eclipse.swt.internal.Converter.wcsToMbcs(Converter.java:209)
	at org.eclipse.swt.internal.Converter.wcsToMbcs(Converter.java:155)
	at org.eclipse.swt.widgets.Display.<clinit>(Display.java:164)
	at org.eclipse.ui.internal.Workbench.createDisplay(Workbench.java:762)
	at org.eclipse.ui.PlatformUI.createDisplay(PlatformUI.java:166)
	at org.eclipse.ui.internal.ide.application.IDEApplication.createDisplay(IDEApplication.java:180)
	at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:123)
	at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:203)
	at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:137)
	at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:107)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:401)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:255)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:657)
	at org.eclipse.equinox.launcher.Main.basicRun(Main.java:594)
	at org.eclipse.equinox.launcher.Main.run(Main.java:1465)
	at org.eclipse.equinox.launcher.Main.main(Main.java:1438)

The part nix expression of fixup is following.

    ( # wrap ide
      cd ${placeholder "out"}/ide
      patchelf --set-interpreter ${stdenv.glibc.out}/lib/ld-linux*.so.2 ./omnetpp
      mv ./omnetpp ./.omnetpp_wrapped
      makeWrapper ./.omnetpp_wrapped ./omnetpp \
        --prefix XDG_DATA_DIRS : "$GSETTINGS_SCHEMAS_PATH" \
        --prefix LD_LIBRARY_PATH : ${stdenv.lib.makeLibraryPath [ freetype
                                                                  fontconfig
                                                                  libX11
                                                                  libXrender
                                                                  zlib
                                                                  libXtst
                                                                  glib
                                                                  gtk
                                                                  webkitgtk
                                                                ]} \

        --prefix PATH : ${jdk}/bin
    )

I have no idea what I missed.

I solve this. Unpack the jar files and use ldd to find what I should to add into LD path. The reason is some dependencies of these depndencies are needed as well.

1 Like

could you share the derivation please? I’ve tried grepping on nixpkgs, but I didn’t find anything. I’m trying to package an Eclipse-based binary as well, and I’m having a hard time with it.

https://gitlab.com/Vonfry/omnetpp-nix

1 Like