Need help with packaging Scenebuilder

Hi! I’m trying to run Scenebuilder (a javafx UI maker application).
It is packaged in the AUR but not in nixpkgs.
I’ve been following the steps in Packaging/Binaries - NixOS Wiki and currently stuck at The Dynamic Loader part, getting this error:

dlopen(/home/kazimazi/dev/deb-playground/scenebuilder/opt/scenebuilder/lib/runtime/lib/libjli.so) failed. Error: libz.so.1: cannot open shared object file: No such file or directory

I tried to set the correct rpath with the path of zlib, but nothing changed.
Could anyone give me some pointers?

What does your derivation/default.nix look like so far? Do you have zlib as a buildInput? (I would guess so, since the wiki-page already does that.)

ah, I haven’t gathered all the stuff to a default.nix yet, I should do that too

made a not working derivation (same issue as in the original post)

{ stdenv, lib, dpkg, zlib, makeWrapper, fetchurl }:
stdenv.mkDerivation rec {
  name = "scenebuilder-${version}";
  version = "16.0.0";

  src = fetchurl {
    url = "https://download2.gluonhq.com/scenebuilder/${version}/install/linux/SceneBuilder-${version}.deb";
    sha256 = "sha256-5tQ35S6SGrIUCzvkyEK34gPkZ6uKNUvm8YeZlLAfC7k=";
  };

  nativeBuildInputs = [ dpkg ];
  buildInputs = [ zlib ];

  unpackPhase = "dpkg-deb -x ${src} ./";

  dontConfigure = true;
  dontBuild = true;

  installPhase = ''
    mkdir -p $out/bin
    cp -R opt $out/
    # symlink the binary to bin/
    ln -s $out/opt/scenebuilder/bin/SceneBuilder $out/bin/SceneBuilder
  '';
  preFixup = let
    libPath = lib.makeLibraryPath [
    ];
  in ''
    patchelf \
      --set-interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" \
      --set-rpath "${libPath}" \
      $out/opt/scenebuilder/bin/SceneBuilder
  '';

  meta = with lib; {
    homepage =  https://gluonhq.com/products/scene-builder/;
    description = "asdfg";
    license = licenses.bsd3; # FIXME
    platforms = platforms.linux;
    maintainers = [ kazimazi ];
  };
}

So, tried it out, and it looks like libjli.so also needs patching.

This got the build further for me:

  preFixup = let
    libPath = lib.makeLibraryPath [
      zlib
    ];
  in ''
    patchelf \
      --set-interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" \
      --set-rpath "${libPath}" \
      $out/opt/scenebuilder/bin/SceneBuilder
    patchelf \
      --set-rpath "${libPath}" \
      $out/opt/scenebuilder/lib/runtime/lib/libjli.so
  '';

I added zlib to the makeLibraryPath invocation, and added a patchelf call for libjli.so. It now fails with other similar errors (no libX11.so), but I guess they require similar solutions.

Trying with pkgs.autoPatchelfHook (mentioned on the page you linked) in the nativeBuildInputs (and leaving out the preFixup commands) seems to take care of this automatically, but requires some more dependencies (it seems to find the zlib dependency in libjli.so already).

Very nice! I’ve eliminated some missing dependencies, currently I’m getting this error:

error: builder for '/nix/store/skg36wq1qqifaqz6assj7dnx6y6m610v-scenebuilder-16.0.0.drv' failed with exit code 1;
       last 10 log lines:
       ...
       >   libavcodec-ffmpeg.so.56 -> not found!
       >   libavformat-ffmpeg.so.56 -> not found!

This is troubling since nix-locate -1 -w lib/libavcodec-ffmpeg.so.56 doesn’t return anything.
I’m kinda stuck again.

{ stdenv
, lib
, dpkg
, zlib
, makeWrapper
, fetchurl
, autoPatchelfHook
, gnome2
, gtk2-x11
, xlibs
}:
stdenv.mkDerivation rec {
  name = "scenebuilder-${version}";
  version = "16.0.0";

  src = fetchurl {
    url = "https://download2.gluonhq.com/scenebuilder/${version}/install/linux/SceneBuilder-${version}.deb";
    sha256 = "sha256-5tQ35S6SGrIUCzvkyEK34gPkZ6uKNUvm8YeZlLAfC7k=";
  };

  nativeBuildInputs = [
    dpkg
    autoPatchelfHook
  ];

  buildInputs = [
    gnome2.pango
    gtk2-x11
    xlibs.libXtst
  ];

  unpackPhase = "dpkg-deb -x ${src} ./";

  dontConfigure = true;
  dontBuild = true;

  installPhase = ''
    mkdir -p $out/bin
    cp -R opt $out/
    # symlink the binary to bin/
    ln -s $out/opt/scenebuilder/bin/SceneBuilder $out/bin/SceneBuilder
  '';

  meta = with lib; {
    homepage =  https://gluonhq.com/products/scene-builder/;
    description = "asdfg";
    license = licenses.bsd3; # FIXME
    platforms = platforms.linux;
    maintainers = [ kazimazi ];
  };
}

Mhhm, nixpkgs/default.nix at 540199893d51d13f59364471ac245c0a4475d29f · NixOS/nixpkgs · GitHub and nixpkgs/default.nix at 540199893d51d13f59364471ac245c0a4475d29f · NixOS/nixpkgs · GitHub look promising, probably worth checking them out. Would also be interested in what a good way to find those is!

Already tried them, but not sure why they didn’t help.

Might as well give a shot to scenebuilder: init at 15.0.0 + scenic-view: init at 11.0.2 by wirew0rm · Pull Request #110398 · NixOS/nixpkgs · GitHub. Completely missed it.

1 Like

hey there,

let me know If you encounter any problems or have any questions or improvements. For me everything everything I tried was functional, but I’m not using it that heavily (using too many JavaFx libraries that are incompatible with scene builder, so I’m stuck with manually writing fxml).

I’ve also run into this situation where I was stuck trying to package something and when I asked for help I was pointed to an almost complete PR and a bunch of issues I had completely missed. Maybe github PRs (and NUR) should be included in nixos’s package search :smiley:

1 Like

Thx works really well, hopefully, it gets merged sometimes. I’m tired of building java stuff for now.:frowning:

Just to let you know, the PR was merged and scenebuilder is now in nixos-unstable. It’s still 15.0.1 but I plan on updating it to 16.0.0.

1 Like