Kl4rry / simp

🖼️ Simp is a fast and simple GPU-accelerated image manipulation program.
Apache License 2.0
307 stars 14 forks source link

Unable to build/use on NixOS #33

Closed RAVENz46 closed 5 months ago

RAVENz46 commented 6 months ago

I wanna try this on NixOS but I couldn't.

install via flake

Build fail.

install via prebuild binary

Build success but unable to launch. Error log

$ simp
PanicInfo { payload: Any { .. }, message: Some(called `Result::unwrap()` on an `Err` value: Os(OsError { line: 80, file: "/home/runner/.cargo/registry/src/index.crates.io-6f17d22bba15001f/winit-0.29.15/src/platform_impl/linux/wayland/event_loop/mod.rs", error: WaylandError(Connection(NoWaylandLib)) })), location: Location { file: "src/main.rs", line: 67, col: 92 }, can_unwind: true, force_no_backtrace: false }
nix derivation ```nix { stdenv , lib , fetchzip , autoPatchelfHook }: stdenv.mkDerivation rec { pname = "simp"; version = "3.5.3"; src = fetchzip { url = "https://github.com/Kl4rry/simp/releases/download/v${version}/simp-x86_64-unknown-linux-gnu.tar.xz"; hash = "sha256-XR3c6FlJhaS1nhBP2O/9/KC5YyxGutBc31pfMWkc+FI="; }; nativeBuildInputs = [ autoPatchelfHook ]; buildInputs = [ stdenv.cc.cc.lib ]; installPhase = '' mkdir -p $out/bin cp ${pname} $out/bin ''; meta = with lib; { description = "Simp is a fast and simple GPU-accelerated image manipulation program"; homepage = "https://github.com/Kl4rry/simp"; license = licenses.asl20; maintainers = with maintainers; [ ]; mainProgram = "simp"; }; } ````

install via source

Build fail. Build log

error: failed to run custom build command for `simp v3.5.3 (/build/source)`

Caused by:
  process didn't exit successfully: `/build/source/target/release/build/simp-7e45d19a4a02abb7/build-script-build` (exit status: 101)
  --- stderr
  thread 'main' panicked at build.rs:38:10:
  called `Result::unwrap()` on an `Err` value: Os { code: 2, kind: NotFound, message: "No such file or directory" }
  note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
warning: build failed, waiting for other jobs to finish...
nix derivation ```nix { lib , rustPlatform , fetchFromGitHub , pkg-config , libxkbcommon , vulkan-loader , stdenv , darwin , wayland , libGL , xorg , makeDesktopItem , copyDesktopItems }: rustPlatform.buildRustPackage rec { pname = "simp"; version = "3.5.3"; src = fetchFromGitHub { owner = "Kl4rry"; repo = "simp"; rev = "v${version}"; hash = "sha256-NALVHcU+NhCT5w+pn6WhP+cFGPuDhnPt+IDNHN/oqls="; }; cargoHash = "sha256-Wp50ldXGy7MLQTnvZDx3LIr8jLBpkoCrh0/xPowIn54="; nativeBuildInputs = [ pkg-config copyDesktopItems ]; buildInputs = [ libxkbcommon vulkan-loader libGL ] ++ lib.optionals stdenv.isDarwin [ darwin.apple_sdk.frameworks.AppKit darwin.apple_sdk.frameworks.CoreGraphics darwin.apple_sdk.frameworks.Foundation darwin.apple_sdk.frameworks.Metal darwin.apple_sdk.frameworks.QuartzCore ] ++ lib.optionals stdenv.isLinux [ wayland xorg.libXcursor xorg.libXi xorg.libXrandr xorg.libX11 ]; desktopItems = [ (makeDesktopItem { name = "simp"; desktopName = "simp"; genericName= "Image Editor"; exec = "simp %U"; icon = "icon"; categories = [ "Graphics" ]; mimeTypes = [ "image/bmp" ]; }) ]; preBuild = '' mkdir -p $out/share/icons/hicolor/256x256/apps cp $src/icon.png $out/share/icons/hicolor/256x256/apps/ ''; postFixup = '' patchelf $out/bin/${pname} \ --add-rpath ${lib.makeLibraryPath [ libGL libxkbcommon wayland ]} ''; meta = with lib; { description = "Simp is a fast and simple GPU-accelerated image manipulation program"; homepage = "https://github.com/Kl4rry/simp"; license = licenses.asl20; maintainers = with maintainers; [ ]; mainProgram = "simp"; }; } ```
Kl4rry commented 6 months ago

The nix flake is user contributed and I do not have the ability to support it as I don't use nix. I would happily accept a PR that fixes this.

RAVENz46 commented 6 months ago

Fortunately, the source build went well, but I get this error. If you have any ideas on how to fix it, I would appreciate hearing from you.

$ simp
PanicInfo { payload: Any { .. }, message: Some(Unable to create adapter), location: Location { file: "src/main.rs", line: 117, col: 14 }, can_unwind: true, force_no_backtrace: false }
nix derivation ```nix { lib , rustPlatform , fetchFromGitHub , pkg-config , libxkbcommon , vulkan-loader , stdenv , darwin , wayland , makeDesktopItem , copyDesktopItems , cargo-about , libGL }: rustPlatform.buildRustPackage rec { pname = "simp"; version = "3.5.3"; src = fetchFromGitHub { owner = "Kl4rry"; repo = "simp"; rev = "v${version}"; hash = "sha256-NALVHcU+NhCT5w+pn6WhP+cFGPuDhnPt+IDNHN/oqls="; }; cargoHash = "sha256-Wp50ldXGy7MLQTnvZDx3LIr8jLBpkoCrh0/xPowIn54="; nativeBuildInputs = [ pkg-config cargo-about copyDesktopItems ]; buildInputs = [ libxkbcommon vulkan-loader libGL ] ++ lib.optionals stdenv.isDarwin [ darwin.apple_sdk.frameworks.AppKit darwin.apple_sdk.frameworks.CoreGraphics darwin.apple_sdk.frameworks.CoreServices darwin.apple_sdk.frameworks.Foundation darwin.apple_sdk.frameworks.Metal darwin.apple_sdk.frameworks.QuartzCore ] ++ lib.optionals stdenv.isLinux [ wayland ]; desktopItems = [ (makeDesktopItem { name = "simp"; desktopName = "simp"; genericName= "Image Editor"; exec = "simp %U"; icon = "icon"; categories = [ "Graphics" ]; mimeTypes = [ "image/bmp" ]; }) ]; preBuild = '' mkdir -p $out/share/icons/hicolor/256x256/apps cp $src/icon.png $out/share/icons/hicolor/256x256/apps/ sed -i '35,39c let git_hash=String::from("${version}");' build.rs ''; postFixup = '' patchelf $out/bin/${pname} \ --add-rpath ${lib.makeLibraryPath [ libGL libxkbcommon wayland ]} ''; meta = { description = "Simp is a fast and simple GPU-accelerated image manipulation program"; homepage = "https://github.com/Kl4rry/simp"; license = lib.licenses.asl20; maintainers = with lib.maintainers; [ ]; mainProgram = "simp"; }; } ```
Kl4rry commented 6 months ago

Are you using an Nvidia GPU? You could try forcing Vulkan/OpenGL by setting SIMP_GPU_BACKEND=vulkan or SIMP_GPU_BACKEND=gl

RAVENz46 commented 5 months ago

Thanks! I realized that I need to add vulkan-loader to library path and now it works!

final result ```nix { lib , rustPlatform , fetchFromGitHub , pkg-config , libxkbcommon , vulkan-loader , stdenv , darwin , wayland , makeDesktopItem , copyDesktopItems , cargo-about , libGL }: rustPlatform.buildRustPackage rec { pname = "simp"; version = "3.5.3"; src = fetchFromGitHub { owner = "Kl4rry"; repo = "simp"; rev = "v${version}"; hash = "sha256-NALVHcU+NhCT5w+pn6WhP+cFGPuDhnPt+IDNHN/oqls="; }; cargoHash = "sha256-Wp50ldXGy7MLQTnvZDx3LIr8jLBpkoCrh0/xPowIn54="; nativeBuildInputs = [ pkg-config cargo-about copyDesktopItems ]; buildInputs = [ libxkbcommon vulkan-loader libGL ] ++ lib.optionals stdenv.isDarwin [ darwin.apple_sdk.frameworks.AppKit darwin.apple_sdk.frameworks.CoreGraphics darwin.apple_sdk.frameworks.CoreServices darwin.apple_sdk.frameworks.Foundation darwin.apple_sdk.frameworks.Metal darwin.apple_sdk.frameworks.QuartzCore ] ++ lib.optionals stdenv.isLinux [ wayland ]; desktopItems = [ (makeDesktopItem { name = "simp"; desktopName = "simp"; genericName= "Image Editor"; exec = "simp %U"; icon = "icon"; categories = [ "Graphics" ]; mimeTypes = [ "image/bmp" ]; }) ]; preBuild = '' mkdir -p $out/share/icons/hicolor/256x256/apps cp $src/icon.png $out/share/icons/hicolor/256x256/apps/ sed -i '35,39c let git_hash=String::from("${version}");' build.rs ''; postFixup = '' patchelf $out/bin/${pname} \ --add-rpath ${lib.makeLibraryPath [ vulkan-loader libGL libxkbcommon wayland ]} ''; meta = { description = "Simp is a fast and simple GPU-accelerated image manipulation program"; homepage = "https://github.com/Kl4rry/simp"; license = lib.licenses.asl20; maintainers = with lib.maintainers; [ ]; mainProgram = "simp"; }; } ```
Kl4rry commented 5 months ago

Do you want to make a PR to update the flake with the new working one?