{ tgcMaintainers, unstable, lib, fetchFromGitea, applyPatches, mkYarnPackage, makeWrapper, installShellFiles, nixosTests, ... }: unstable.buildGo125Module (finalAttrs: { pname = "gotosocial"; version = "0.21.0-unstable-2025-10-21-${builtins.substring 0 6 finalAttrs.rev}"; rev = "6cdb58fd376a10f68e5ec1c52373746d798a7734"; srcHash = "sha256-MrP6xzx3Y0l40LdaZSHrKyNSjZqcEmiXBsP9EaP48EE="; src = applyPatches { src = fetchFromGitea { domain = "codeberg.org"; owner = "superseriousbusiness"; repo = "gotosocial"; hash = finalAttrs.srcHash; inherit (finalAttrs) rev; }; patches = [ ./0001-disable-template-indentation.patch ]; }; frontend-assets = mkYarnPackage { name = "${finalAttrs.pname}-${finalAttrs.version}-frontendAssets"; inherit (finalAttrs) src version; packageJSON = "${finalAttrs.src}/web/source/package.json"; yarnLock = "${finalAttrs.src}/web/source/yarn.lock"; configurePhase = '' runHook preConfigure cp -r $node_modules node_modules chmod +w -R node_modules runHook postConfigure ''; buildPhase = '' runHook preBuild mkdir -p ./web/source ./web/assets cp -r $src/web/source/. ./web/source cp -r $src/web/assets/. ./web/assets export NODE_OPTIONS=--openssl-legacy-provider node ./node_modules/ts-patch/bin/ts-patch.js install yarn --offline --cwd ./web/source build runHook postBuild ''; distPhase = "true"; installPhase = "cp -r ./web/assets $out"; meta.license = lib.licenses.agpl3Only; }; ldflags = [ "-s" "-w" "-X 'main.Commit=${finalAttrs.rev}'" "-X 'main.Version=${finalAttrs.version}'" ]; tags = [ "netgo" "osusergo" "static_build" "kvformat" ]; env.CGO_ENABLED = 0; vendorHash = null; nativeBuildInputs = [ installShellFiles ]; buildInputs = [ makeWrapper ]; # tests are working only on x86_64-linux # doCheck = stdenv.hostPlatform.isLinux && stdenv.hostPlatform.isx86_64; # checks are currently very unstable in our setup, so we should test manually for now doCheck = false; checkFlags = let # flaky / broken tests skippedTests = [ # See: https://github.com/superseriousbusiness/gotosocial/issues/2651 "TestPage/minID,_maxID_and_limit_set" ]; in [ "-skip=^${builtins.concatStringsSep "$|^" skippedTests}$" ]; installCheckPhase = '' runHook preCheck $out/bin/gotosocial --help runHook postCheck ''; postInstall = '' mkdir -p $out/share/${finalAttrs.pname}/web/{templates,assets} cp -r ./web/template/. $out/share/${finalAttrs.pname}/web/template/ cp -rf ${finalAttrs.frontend-assets}/. $out/share/${finalAttrs.pname}/web/assets/ installShellCompletion --cmd gotosocial \ --bash <($out/bin/gotosocial completion bash) \ --fish <($out/bin/gotosocial completion fish) \ --zsh <($out/bin/gotosocial completion zsh) ''; passthru.tests.gotosocial = nixosTests.gotosocial; meta = with lib; { mainProgram = "gotosocial"; maintainers = [ tgcMaintainers.zaphyra ]; license = licenses.agpl3Only; homepage = "https://gotosocial.org"; changelog = "https://codeberg.org/superseriousbusiness/gotosocial/releases"; description = "Fast, fun, ActivityPub server, powered by Go"; longDescription = '' ActivityPub social network server, written in Golang. You can keep in touch with your friends, post, read, and share images and articles. All without being tracked or advertised to! A light-weight alternative to Mastodon and Pleroma, with support for clients! ''; }; })