gotosocial: fix cross-compilation on RISCV

This commit is contained in:
Jonas Heinrich
2026-07-22 16:10:12 +02:00
parent 2554179c70
commit ce01b16cd6
+22 -2
View File
@@ -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