Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Package request: stl-thumb #233835

Open
balacij opened this issue May 24, 2023 · 5 comments
Open

Package request: stl-thumb #233835

balacij opened this issue May 24, 2023 · 5 comments
Labels
0.kind: packaging request Request for a new package to be added

Comments

@balacij
Copy link
Contributor

balacij commented May 24, 2023

Project description

stl-thumb is a thumbnail generator for STL and OBJ files (helpful for file managers). It is tested against Gnome and KDE (KDE with an extra plugin needed), and Windows, but any file manager should work.

Metadata

@balacij balacij added the 0.kind: packaging request Request for a new package to be added label May 24, 2023
@EdCordata
Copy link

Wish to add, that stl-thumb-kde is also needed for KDE integration:
https://github.com/unlimitedbacon/stl-thumb-kde

@balacij
Copy link
Contributor Author

balacij commented Jun 22, 2023

I gave it a go. stl-thumb compiles, but the test suite (and usage) fails with an error Creating EventLoop multiple times is not supported. It seems something is going awry with the rust-windowing/winit package usage. I'm not quite sure how to fix that unfortunately.

(the package derivation)

Note that I had to use the (current) master blob because of a git dependency in v0.5's released Cargo.lock file, which buildRustPackage doesn't seem to like.

{
  lib,
  pkgs,
  stdenv,
  fetchFromGitHub,
}:
pkgs.rustPlatform.buildRustPackage rec {
  pname = "stl-thumb";
  version = "v0.5.0-dec70d8";

  src = fetchFromGitHub {
    owner = "unlimitedbacon";
    repo = pname;
    rev = "dec70d8d8cfbb6c635ecbd8c1f3d3959ea42f5e8";
    sha256 = "sha256-xF3sl3LOno3MeLK11cP48KlkbQDIZ/7Ax17dD8DL+po=";
  };

  #   doCheck = false;

  cargoSha256 = "sha256-uaVyw3RKuzFjmVCagvzhOKMw8RiWvOG5siwUCwblpZ4=";

  meta = with lib; {
    description = "Thumbnail generator for STL files";
    homepage = "https://github.com/unlimitedbacon/stl-thumb";
    license = licenses.mit;
    maintainers = [];
  };

  buildInputs = with pkgs; [
    fontconfig
  ];

  nativeBuildInputs = with pkgs; [
    cmake
    pkg-config
  ];
}

@tomberek
Copy link
Contributor

tomberek commented Aug 27, 2023

Still ran into the same "Creating EventLoop multiple..." errors:

stl-thumb
{
  lib,
  pkgs,
  stdenv,
  fetchFromGitHub,
  libX11,
  libXcursor,
  libXrandr,
  libXi
}:
pkgs.rustPlatform.buildRustPackage rec {
  pname = "stl-thumb";
  version = "v0.5.0-dec70d8";

  src = /home/tom/t7/stl-thumb;
  src2 = fetchFromGitHub {
    owner = "unlimitedbacon";
    repo = pname;
    rev = "dec70d8d8cfbb6c635ecbd8c1f3d3959ea42f5e8";
    sha256 = "sha256-xF3sl3LOno3MeLK11cP48KlkbQDIZ/7Ax17dD8DL+po=";
  };

  doCheck = false;

  cargoSha256 = "sha256-1sQzMyrzy43l5MJxqg9ihUpp0rskuIXndTnh230wO6Q=";
  postInstall = ''
    mkdir $out/include
    cp libstl_thumb.h $out/include
    mkdir -p $out/thumbnailers
    mkdir -p $out/mime/packages
    cp stl-thumb.thumbnailer $out/thumbnailers/stl-thumb.thumbnailer
    cp stl-thumb-mime.xml $out/mime/packages/stl-thumb-mime.xml
  '';

  meta = with lib; {
    description = "Thumbnail generator for STL files";
    homepage = "https://github.com/unlimitedbacon/stl-thumb";
    license = licenses.mit;
    maintainers = [];
  };
  buildInputs = with pkgs; [
    fontconfig
    libX11
  ];
  propagatedBuildInputs = [
    libXcursor
    libXrandr
    libXi
  ];
  nativeBuildInputs = with pkgs; [
    cmake
    pkg-config
  ];
}
stl-thumb-kde
{
  libsForQt5,
  stl-thumb,
  dolphin
}:
libsForQt5.callPackage
({
  stdenv,
  fetchFromGitHub,
  cmake,
  extra-cmake-modules,
  qtbase,
  wrapQtAppsHook,
  kio,
}:
stdenv.mkDerivation {
  name = "stl-thumb-kde";
  src = fetchFromGitHub {
    owner = "unlimitedbacon";
    repo = "stl-thumb-kde";
    rev = "79abfa5210386a3d9997ac8c9131b81aba4a94d0";
    hash = "sha256-cj3DVJ2s9x9whsRkbAiZzM58qtHfS+vHg7ieZeHPez4=";
  };
  nativeBuildInputs = [cmake extra-cmake-modules wrapQtAppsHook ]; 
  buildInputs = [ qtbase kio stl-thumb ];
  postInstall = ''
    mkdir -p $out/bin
    ln -s ${dolphin}/bin/dolphin $out/bin/dolphin
  '';
}) {}

@MarSoft
Copy link

MarSoft commented Oct 1, 2023

The actual error is not Creating EventLoop multiple times is not supported. but above: Failed to initialize any backend! Wayland status: NoWaylandLib X11 status: LibraryOpenError(OpenError { kind: Library, detail: "opening library failed (libX11.so.6: cannot open shared ob ject file: No such file or directory); opening library failed (libX11.so: cannot open shared object file: No such file or directory)" })

stl-thumb tries to load X11/Wayland bindings dynamically. (And it does so even despite the job is to just convert one file to another.) On NixOS, it cannot find the libraries.
I used the solution from mc filemanager in nixpkgs: patch the binary to make it explicitly require the required libraries. And it worked for me!
Here is the piece you should insert to stl-thumb derivation for it to work:

    # libs are loaded dynamically; make make sure we'll find them
    postFixup = with pkgs; '' 
      patchelf \ 
        --add-needed ${xorg.libX11}/lib/libX11.so \ 
        --add-needed ${wayland}/lib/libwayland-client.so \ 
        --add-needed ${libGL}/lib/libEGL.so \ 
        $out/bin/stl-thumb 
    '';

NOTICE: we should likely make some of the lines conditional to make X11/Wayland support configurable. For now we will depend on both X11 and Wayland which is not good.

@SyntaxualSugar
Copy link

I think I've got this working, but my pull request has 2 failing checks and I am not sure where to find the failures. If anyone has experience contributing to nixpkgs, I'd love suggestions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
0.kind: packaging request Request for a new package to be added
Projects
None yet
Development

No branches or pull requests

5 participants