commit e846889b707d2e03b340de40f519c96fbf21e750
parent a21e9b28c005725aac9586e746c6b48b57720249
Author: Katja (zaphyra) <git@ctu.cx>
Date: Sat, 24 May 2025 17:59:08 +0200
parent a21e9b28c005725aac9586e746c6b48b57720249
Author: Katja (zaphyra) <git@ctu.cx>
Date: Sat, 24 May 2025 17:59:08 +0200
packages: add `gotosocial`
1 file changed, 99 insertions(+), 0 deletions(-)
A
|
99
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
diff --git a/packages/gotosocial/default.nix b/packages/gotosocial/default.nix @@ -0,0 +1,99 @@ +{ + applyPatches, + fetchgit, + mkYarnPackage, + buildGo124Module, + lib, + makeWrapper, + installShellFiles, + ... +}: + +buildGo124Module rec { + pname = "gotosocial"; + version = "0.20.0-${builtins.substring 0 6 rev}"; + rev = "b6ff55662e0281c0d6e111f9307625ef695df2fa"; + hash = "sha256-btdStdOlIWIFzTQYFzinH5N/U71LETkg8phY7p+eDtw="; + + src = applyPatches { + src = fetchgit { + url = "https://codeberg.org/superseriousbusiness/gotosocial/"; + inherit rev hash; + }; + patches = [ ]; + }; + + frontend-assets = mkYarnPackage { + name = "${pname}_${version}-frontend-assets"; + inherit src version; + + packageJSON = "${src}/web/source/package.json"; + yarnLock = "${src}/web/source/yarn.lock"; + + configurePhase = '' + cp -r $node_modules node_modules + chmod +w -R node_modules + ''; + + buildPhase = '' + 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 + ''; + + distPhase = "true"; + installPhase = "cp -r ./web/assets $out"; + + meta.license = lib.licenses.agpl3Only; + }; + + ldflags = [ + "-s" + "-w" + "-extldflags '-static'" + "-X 'main.Commit=${rev}'" + "-X 'main.Version=${version}'" + ]; + tags = [ + "netgo" + "osusergo" + "static_build" + ]; + + vendorHash = null; + + nativeBuildInputs = [ installShellFiles ]; + buildInputs = [ makeWrapper ]; + + doCheck = false; + + installCheckPhase = '' + runHook preCheck + $out/bin/gotosocial --help + runHook postCheck + ''; + + postInstall = '' + mkdir -p $out/share/web/assets + + cp -r ./web/template $out/share/web/ + cp -rf ${frontend-assets}/. $out/share/web/assets + + installShellCompletion --cmd gotosocial \ + --bash <($out/bin/gotosocial completion bash) \ + --fish <($out/bin/gotosocial completion fish) \ + --zsh <($out/bin/gotosocial completion zsh) + ''; + + meta = with lib; { + description = "An ActivityPub social network server, written in Golang."; + homepage = "https://github.com/superseriousbusiness/gotosocial"; + license = licenses.agpl3Only; + }; + +}