From ce01b16cd63545f06300e80a93271c50ec76acfb Mon Sep 17 00:00:00 2001 From: Jonas Heinrich Date: Wed, 22 Jul 2026 16:10:12 +0200 Subject: [PATCH] gotosocial: fix cross-compilation on RISCV --- pkgs/by-name/go/gotosocial/package.nix | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/pkgs/by-name/go/gotosocial/package.nix b/pkgs/by-name/go/gotosocial/package.nix index 779772adaa5a..1e4622f41d28 100644 --- a/pkgs/by-name/go/gotosocial/package.nix +++ b/pkgs/by-name/go/gotosocial/package.nix @@ -1,13 +1,25 @@ { lib, + stdenv, buildGo125Module, fetchFromCodeberg, fetchYarnDeps, nodejs, yarn, yarnConfigHook, + makeBinaryWrapper, + ffmpeg, nixosTests, nix-update-script, + # Wazero (the WASM runtime GoToSocial uses to bundle ffmpeg/ffprobe/sqlite3) + # only has a fast "compiler" backend for amd64 and arm64. On every other + # architecture (riscv64, 32-bit ARM, ppc64le, ...) it falls back to a WASM + # interpreter that is far too slow for real-world media processing. + # Upstream exposes the explicitly unsupported/experimental "nowasm" build + # tag for this situation: it drops the embedded WASM ffmpeg/ffprobe/sqlite3 + # and instead shells out to ffmpeg/ffprobe binaries found on $PATH. + # See: https://docs.gotosocial.org/en/latest/advanced/builds/nowasm/ + withWasm ? stdenv.hostPlatform.isx86_64 || stdenv.hostPlatform.isAarch64, }: buildGo125Module (finalAttrs: { pname = "gotosocial"; @@ -30,13 +42,15 @@ buildGo125Module (finalAttrs: { tags = [ "kvformat" - ]; + ] + ++ lib.optionals (!withWasm) [ "nowasm" ]; nativeBuildInputs = [ nodejs yarn yarnConfigHook - ]; + ] + ++ lib.optionals (!withWasm) [ makeBinaryWrapper ]; yarnOfflineCache = fetchYarnDeps { yarnLock = "${finalAttrs.src}/web/source/yarn.lock"; @@ -68,6 +82,12 @@ buildGo125Module (finalAttrs: { mkdir -p $out/share/gotosocial/web mv web/{assets,template} $out/share/gotosocial/web + '' + + lib.optionalString (!withWasm) '' + # nowasm builds need ffmpeg/ffprobe available on $PATH at runtime, + # since the embedded WASM copies have been compiled out. + wrapProgram $out/bin/gotosocial \ + --prefix PATH : ${lib.makeBinPath [ ffmpeg ]} ''; # tests are working only on x86_64-linux