Attempting to package GlamorousToolkit

Hi All,

I’m attempting to package Glamorous Toolkit (GT) (https://gtoolkit.com) having just moved to NixOS from Ubuntu two weeks ago. I’m able to run GT using a script I wrote that patches (patchelf) the installed binaries.

Building the package completes successfully and the executables print version information correctly, however attempting to actually run the application just hangs. I’ve tried running the program with strace, but nothing stood out prior to it hanging.

I noticed during the build process that it shrinks the RPATHs and strips unnecessary symbols during the build process and was wondering if there is a way to disble this. I’m hoping that it will provide a bit more information to help track the issue down.

I’ve included the nix package file below in case there’s something obviously wrong with it.

Thanks very much,
Alistair

{ stdenv, lib, makeWrapper, fetchzip, pkgs, xorg }:
stdenv.mkDerivation rec {
  version = "0.7.2";
  name = "GlamorousToolkitVM-${version}";

  src = fetchzip {
    url = "https://github.com/feenkcom/gtoolkit-vm/releases/download/v0.7.2/GlamorousToolkit-x86_64-unknown-linux-gnu.zip";
    sha256 = "Tahe/P0sxmuhSG5JxOkyQGLTOyVrjMEkxvzPc2CBV0Y=";
    stripRoot = false;
  };
  sourceRoot = ".";

  dontConfigure = true;
  dontBuild = true;

  buildInputs = [ 
      pkgs.gtk3 
      pkgs.glib 
      xorg.libX11 
      pkgs.cairo 
      pkgs.libglvnd 
      pkgs.fontconfig 
      pkgs.freetype 
      pkgs.xorg.libxcb 
      pkgs.xorg.libXrender 
      pkgs.xorg.libXext 
      pkgs.libuuid 
      pkgs.dbus 
      pkgs.xorg.libXcursor 
      pkgs.xorg.libXrandr 
      pkgs.xorg.libXi 
      stdenv.cc.cc.lib
    ];


  installPhase = ''
    mkdir $out
    cp -a $src/bin $src/lib $out/
  '';

  # we prepare our library path in the let clause to avoid it become part of the input of mkDerivation
  libPath = lib.makeLibraryPath [ 
      pkgs.gtk3 
      pkgs.glib 
      xorg.libX11 
      pkgs.cairo 
      pkgs.libglvnd 
      pkgs.fontconfig 
      pkgs.freetype 
      pkgs.xorg.libxcb 
      pkgs.xorg.libXrender 
      pkgs.xorg.libXext 
      pkgs.libuuid 
      pkgs.dbus 
      pkgs.xorg.libXcursor 
      pkgs.xorg.libXrandr 
      pkgs.xorg.libXi 
      stdenv.cc.cc.lib
    ];

  preFixup = ''
    echo "libPath=${libPath}"
    chmod +x $out/lib/*.so
    patchelf \
      --set-interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" \
      --set-rpath "${libPath}:$out/lib" \
      $out/bin/GlamorousToolkit $out/bin/GlamorousToolkit-cli
    patchelf \
      --set-rpath "${libPath}:$out/lib" \
      $out/lib/*.so
    ln -s $out/lib/libcrypto.so $out/lib/libcrypto.so.1.1
    ln -s $out/lib/libcairo.so $out/lib/libcairo.so.2
  '';

  meta = with lib; {
    homepage = https://gtoolkit.com;
    description = "The GlamorousToolkit Environment";
    license = licenses.mit;
    platforms = platforms.linux;
  };
}

The fixup phase is where the steps you want to skip happen. There are specific options if you want to disable those for troubleshooting: nixpkgs manual: fixup phase

Have you considered building from source instead? It may seem like more work up front, but is generally preferred if feasible.

1 Like

Thanks, adamcstephens!

Adding dontPatchELF = true makes the executables work as expected. I’ll need to investigate further, but my current hypothesis is that one of the packages in the makeLibraryPath is bringing in a library that is required, but isn’t surfacing as dependency, so is being removed from from the rpath.

I agree that building from source would be better, however GT is made up of outputs from several different git repositories, along with shared libraries from other open source projects. That’s more than I have time to take on at the moment. :slight_smile:

Thanks again.