TablePlus *.deb package

I’m trying to wrap TablePlus - which is a commercial database management tool - as a nix package from the provided *.deb package.

The current nix expression I came up with looks like this:


let
  pkgs = import <nixpkgs> {};
  tableplus = pkgs.stdenv.mkDerivation {
    name = "TablePlus";
    src = pkgs.fetchurl {
      url = "https://deb.tableplus.com/debian/pool/main/t/tableplus/tableplus_0.1.84_amd64.deb";
      sha256 = "01bfrv91hrigq5rni9vignlnhfr33zwhya5nivqi545cjmqfrv2w";
    };
    sourceRoot = "opt/tableplus";

    unpackPhase = ''
      runHook preUnpack
      dpkg-deb -x $src .
      runHook postUnpack
    '';

    installPhase = ''
      runHook preInstall
      ls -la
      mkdir -p "$out/bin"
      mkdir -p "$out/resource"
      cp -R "tableplus" "$out/bin/tableplus"
      cp -R "resource/" "$out/resource"
      chmod -R g-w "$out"
      # # Desktop file
      # mkdir -p "$out/share/applications"
      # cp "$desktopItem}/share/applications/"* "$out/share/applications"
      runHook postInstall
    '';

    nativeBuildInputs = with pkgs; [
      autoPatchelfHook
      dpkg
      makeWrapper
      wrapGAppsHook
    ];
    buildInputs = with pkgs; [
      stdenv.cc.cc.lib
      libgee
      json-glib
      openldap
      gtksourceview4
      gnome.libsecret
      gnome.gtksourceview
    ];
  };
in with pkgs;
  stdenv.mkDerivation {
  name = "testproj";
  buildInputs = [
    tableplus
  ];
  nativeBuildInputs = [
  ];
  shellHook = ''
    echo ${tableplus}
  '';
}

Packaging and installing seems to work but when I run ${tableplus}/bin/tableplus I’ll get ${tableplus}/bin/tableplus: /nix/store/7ndx3pmvfpc8mxw9aqm2vxpq8jylvqdc-openldap-2.4.58/lib/libldap_r-2.4.so.2: no version information available (required by ${tableplus}/bin/tableplus}.

Any pointers on what I’m doing wrong here?

2 Likes

Huh… strange. I tried it again and now it seems to be working :smiley:

1 Like

I also tried to package it. It appears that TablePlus is asking for librairies that Nix cannot currently propose. Here is the package I made.

{ lib
, stdenv
, autoPatchelfHook
, dpkg
, libsecret
, libgee
, glib
, gtksourceview
, cairo
, gdk-pixbuf
, pango
, openldap
, cyrus_sasl
, libkrb5
}:

stdenv.mkDerivation rec {
  pname = "table-plus";
  version = "0.1.178";

  src = builtins.fetchurl {
    url = "https://deb.tableplus.com/debian/21/pool/main/t/tableplus/tableplus_${version}_amd64.deb";
    # sha265 = "";
  };

  nativeBuildInputs = [ autoPatchelfHook dpkg ];

  buildInputs = [
    stdenv.cc.cc.lib
    libsecret
    libgee
    glib
    gtksourceview
    cairo
    gdk-pixbuf
    pango
    openldap
    cyrus_sasl
    libkrb5
  ];

  unpackPhase = ''
    mkdir pkg
    dpkg-deb -x $src pkg
    sourceRoot=pkg
  '';

  installPhase = ''
    mkdir -p $out/{bin,share,lib}
    mv opt/tableplus/* $out/share
    ln -s $out/share/tableplus $out/bin/tableplus

    # Fix libraries
    ln -s ${openldap}/lib/libldap-2.4.so.2 $out/lib/libldap-2.5.so.0
    ln -s ${cyrus_sasl.out}/lib/libsasl2.so.3 $out/lib/libsasl2.so.2

    mkdir -p $out/share/applications
    mv $out/share/tableplus.desktop $out/share/applications

    substituteInPlace $out/share/applications/tableplus.desktop \
      --replace "/usr/local/bin/tableplus" "tableplus" \
      --replace "/opt/tableplus/resource/image/logo.png" "$out/share/resource/image/logo.png"
  '';
}

See the trick for the librairies ? Well, it does not work obviously! Starting table plus with this dirty trick gives

./result/bin/tableplus: /nix/store/gvz8284pg2vnvhgirb84pf5shznh12k6-table-plus-0.1.178/lib/libldap-2.5.so.0: no version information available (required by ./result/bin/tableplus)
./result/bin/tableplus: /nix/store/gvz8284pg2vnvhgirb84pf5shznh12k6-table-plus-0.1.178/lib/libsasl2.so.2: no version information available (required by ./result/bin/tableplus)
./result/bin/tableplus: /nix/store/s9qbqh7gzacs7h68b2jfmn9l6q4jwfjz-glibc-2.33-59/lib/libc.so.6: version `GLIBC_2.34' not found (required by ./result/bin/tableplus)

Sadly, I’m not skilled enough to fix that on my own. For me

  • cyrus_sasl does not provide libsasl2.so.2
  • openldap does not provide libldap-2.5.so.0 (current version: 2.4)
  • Glibc is not recent enough to support at least the version 2.34 (current version: 2.33)
3 Likes

I found a way to make tableplus work by rebuilding libldap and libsasl from the debian package. Keep in mind I am new to nix, this solution may be improved on:

let
  pkgs = import <nixpkgs> {};
in pkgs.stdenv.mkDerivation {
  name = "TablePlus";

    libldapSrc = pkgs.fetchurl {
      url = "http://ftp.de.debian.org/debian/pool/main/o/openldap/libldap-2.5-0_2.5.13+dfsg-2+b1_amd64.deb";
      sha256 = "ifecgulBnb0gtBXnYQEJy03k/Cy3UPEIkgnukZ9SG+g=";
    };

    libsaslSrc = pkgs.fetchurl {
      url = "http://archive.ubuntu.com/ubuntu/pool/main/c/cyrus-sasl2/libsasl2-2_2.1.27+dfsg-2_amd64.deb";
      sha256 = "3OguEgUoKpB8lvlzUItzB7imn6Td46+Sl+YCFXM/LTA=";
    };

    tableplusSrc = pkgs.fetchurl {
      url = "https://deb.tableplus.com/debian/21/pool/main/t/tableplus/tableplus_0.1.192_amd64.deb";
      sha256 = "SOsmjW6CGx28S3P4TaJ2kFdRXX+qR+7as9wiYqorAFA=";
    };

    unpackPhase = ''
      runHook preUnpack
      dpkg-deb -x $tableplusSrc tableplus
      dpkg-deb -x $libldapSrc libldap
      dpkg-deb -x $libsaslSrc libsasl
      runHook postUnpack
    '';

    installPhase = ''
      runHook preInstall
      mkdir -p "$out/lib"
      mkdir -p "$out/bin"
      mkdir -p "$out/resource"
      # deps
      cp -R libldap/usr/lib/x86_64-linux-gnu/* "$out/lib/"
      cp -R libsasl/usr/lib/x86_64-linux-gnu/* "$out/lib/"
      # tableplus
      cp -R "tableplus/opt/tableplus/tableplus" "$out/bin/tableplus"
      cp -R "tableplus/opt/tableplus/resource/" "$out/resource"
      chmod -R g-w "$out"
      # # Desktop file
      # mkdir -p "$out/share/applications"
      #cp "$desktopItem}/share/applications/"* "$out/share/applications"
      runHook postInstall
    '';

    nativeBuildInputs = with pkgs; [
      autoPatchelfHook
      dpkg
      makeWrapper
      wrapGAppsHook
    ];

    buildInputs = with pkgs; [
      gtksourceview
      gtksourceview4
      json-glib
      libgee
      libkrb5
      libsecret
      openldap
      stdenv.cc.cc.lib
    ];

    meta = with pkgs.stdenv.lib; {
      description = "Tableplus";
      homepage = https://tableplus.com/;
      platforms = [ "x86_64-linux" ];
    };
  }
1 Like

Guys, were we able to find an improved solution? Or what @emilien-jegou has proposed in their last comment is what we finalised upon? (I’m very new to Nix as well so I’m not totally sure what’s the preferred way now to install TablePlus).

Somebody has proposed a solution here as well, and other have presented alternate methods here

That would be me :smiley:

I haven’t seriously tried further to get it running and simply used beekeeper-studio which is an electron application. It gets the job done but I’d rather use table plus if I’m honest…


N. b. I think this is a really hairy problem that is very much nothing for beginners. Therefore it is also way above my proverbial paygrade ^^