Installing non-free java application

I’m struggling to install the enterprise version of Dbeaver properly. It is a Java application.

I’ve partially modeled my flake on the open-source version.

The main difference, is I do not need to build the ee version with Maven.

I’ve made some progress with the patches. But it is mostly trial and error at this point.

The application will start but crash.

I guess I’m supposed to use autoPatchelfHook and makeWrapper. But I’m stuck.

Thanks for the help.

errors

JVM terminated. Exit code=2
/nix/store/1h90kkcamc1lzmgppzn2z5d40ifbmb2d-dbeaver-ee-latest/jre/bin/java
-XX:+IgnoreUnrecognizedVMOptions
-Dosgi.requiredJavaVersion=17
--add-opens=java.base/java.io=ALL-UNNAMED
--add-opens=java.base/java.lang=ALL-UNNAMED
--add-opens=java.base/java.lang.reflect=ALL-UNNAMED
--add-opens=java.base/java.net=ALL-UNNAMED
--add-opens=java.base/java.nio=ALL-UNNAMED
--add-opens=java.base/java.nio.charset=ALL-UNNAMED
--add-opens=java.base/java.text=ALL-UNNAMED
--add-opens=java.base/java.time=ALL-UNNAMED
--add-opens=java.base/java.util=ALL-UNNAMED
--add-opens=java.base/java.util.concurrent=ALL-UNNAMED
--add-opens=java.base/java.util.concurrent.atomic=ALL-UNNAMED
--add-opens=java.base/jdk.internal.vm=ALL-UNNAMED
--add-opens=java.base/jdk.internal.misc=ALL-UNNAMED
--add-opens=java.base/sun.nio.ch=ALL-UNNAMED
--add-opens=java.base/sun.security.ssl=ALL-UNNAMED
--add-opens=java.base/sun.security.action=ALL-UNNAMED
--add-opens=java.base/sun.security.util=ALL-UNNAMED
--add-opens=java.security.jgss/sun.security.jgss=ALL-UNNAMED
--add-opens=java.security.jgss/sun.security.krb5=ALL-UNNAMED
flake.nix

## export NIXPKGS_ALLOW_UNFREE=1
## Check: nix flake check --impure
## Buid: nix build .#dbeaver-ee --impure
## Run: ./result/bin/dbeaver
{
  description = "A flake for building DBeaver Enterprise";

  inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";

  outputs = {
    self,
    nixpkgs,
  }: let
    pkgs = nixpkgs.legacyPackages.x86_64-linux;
    lib = nixpkgs.lib;
  in {
    packages.x86_64-linux.dbeaver-ee = pkgs.stdenv.mkDerivation rec {
      pname = "dbeaver-ee";
      version = "latest";

      src = pkgs.fetchurl {
        url = "https://dbeaver.com/files/dbeaver-ee-latest-linux.gtk.x86_64.tar.gz";
        ## nix-prefetch-url --unpack https://dbeaver.com/files/dbeaver-ee-latest-linux.gtk.x86_64.tar.gz
        sha256 = "d2c8c76d70b56790e3a553a9fe4ed25820cbaca1a38a821e690822da9e4b4e1b";
      };

      nativeBuildInputs = [pkgs.makeWrapper];

      buildInputs =
        [
          pkgs.fontconfig
          pkgs.freetype
          pkgs.glib
          pkgs.gtk3
          pkgs.xorg.libX11
          pkgs.xorg.libXrender
          pkgs.xorg.libXtst
          pkgs.zlib
        ]
        ++ lib.optionals pkgs.stdenv.isLinux [pkgs.webkitgtk_4_1 pkgs.glib-networking];

      installPhase = ''
        runHook preInstall
        mkdir -p $out/bin $out/share/pixmaps
        cp -r ./* $out/
        interpreter=$(cat $NIX_CC/nix-support/dynamic-linker)
        patchelf --set-interpreter $interpreter $out/dbeaver
        makeWrapper $out/dbeaver $out/bin/dbeaver \
          --prefix PATH : ${lib.makeBinPath [pkgs.jdk17]} \
          --prefix LD_LIBRARY_PATH : ${lib.makeLibraryPath buildInputs} \
          --prefix GIO_EXTRA_MODULES : "${pkgs.glib-networking}/lib/gio/modules" \
          --prefix XDG_DATA_DIRS : "$GSETTINGS_SCHEMAS_PATH"
        ln -s $out/dbeaver/icon.xpm $out/share/pixmaps/dbeaver.xpm
        runHook postInstall
      '';

      meta = with lib; {
        homepage = "https://dbeaver.com/";
        description = "Universal SQL Client for developers, DBA and analysts. Supports MySQL, PostgreSQL, MariaDB, SQLite, and more";
        license = licenses.unfree;
        platforms = ["x86_64-linux"];
      };
    };
  };
}

Try using a JVM from Nixpkgs rather than using the bundled JVM. A bundled JVM would likely require a lot of patchelf patching.

Thanks for the suggestion. Unfortunately, it did not work.

Solution: https://github.com/berts83231/dbeaver-enterprise-nix-flake/blob/f49e4cba6be5cd7e2de9eaa43aff3d82987819b3/flake.nix

Inspired by the old way the installed DBeaver Community from a tarball.