# Source: https://github.com/sodiboo/system/blob/b63c7b27f49043e8701b3ff5e1441cd27d5a2fff/sharkey/package.nix { lib, stdenv, fetchFromGitLab, # Build time makeWrapper, copyDesktopItems, jq, moreutils, cacert, python3, pkg-config, # Run time bash, jemalloc, ffmpeg-headless, nodejs, pnpm_9, glib, vips, pixman, pango, cairo, }: stdenv.mkDerivation (finalAttrs: { pname = "sharkey"; version = "2025.2.3"; src = fetchFromGitLab { owner = "TransFem-org"; repo = "Sharkey"; domain = "activitypub.software"; rev = finalAttrs.version; hash = "sha256-VBfkJuoQzQ93sUmJNnr1JUjA2GQNgOIuX+j8nAz3bb4="; fetchSubmodules = true; }; pnpmDeps = stdenv.mkDerivation { pname = "${finalAttrs.pname}-pnpm-deps"; inherit (finalAttrs) src version; nativeBuildInputs = [ jq moreutils pnpm_9 cacert ]; # https://github.com/NixOS/nixpkgs/blob/763e59ffedb5c25774387bf99bc725df5df82d10/pkgs/applications/misc/pot/default.nix#L56 installPhase = '' export HOME=$(mktemp --directory) pnpm config set store-dir $out pnpm config set side-effects-cache false pnpm install --force --frozen-lockfile --ignore-scripts ''; fixupPhase = '' rm --recursive --force $out/v3/tmp for f in $(find $out -name "*.json"); do sed --in-place --regexp-extended --expression='s/"checkedAt":[0-9]+,//g' "$f" jq --sort-keys . "$f" | sponge "$f" done ''; dontBuild = true; outputHashMode = "recursive"; outputHash = "sha256-ALstAaN8dr5qSnc/ly0hv+oaeKrYFQ3GhObYXOv4E6I="; }; nativeBuildInputs = [ copyDesktopItems pnpm_9 nodejs makeWrapper python3 pkg-config ]; buildInputs = [ glib vips pixman pango cairo ]; configurePhase = '' runHook preConfigure export HOME=$(mktemp --directory) export STORE_PATH=$(mktemp --directory) export npm_config_nodedir=${nodejs} cp --no-target-directory --recursive "$pnpmDeps" "$STORE_PATH" chmod --recursive +w "$STORE_PATH" pnpm config set store-dir "$STORE_PATH" pnpm install --offline --frozen-lockfile --ignore-scripts ( cd node_modules/.pnpm/node_modules/v-code-diff pnpm run postinstall ) ( cd node_modules/.pnpm/node_modules/re2 pnpm run rebuild ) ( cd node_modules/.pnpm/node_modules/sharp pnpm run install ) ( cd node_modules/.pnpm/node_modules/canvas pnpm run install ) runHook postConfigure ''; buildPhase = '' runHook preBuild pnpm build runHook postBuild ''; installPhase = let libPath = lib.makeLibraryPath [ jemalloc ffmpeg-headless stdenv.cc.cc.lib ]; binPath = lib.makeBinPath [ bash pnpm_9 nodejs ]; in # bash '' runHook preInstall mkdir --parents $out/Sharkey ln --symbolic /var/lib/sharkey $out/Sharkey/files ln --symbolic /run/sharkey $out/Sharkey/.config cp --recursive * $out/Sharkey # We cannot `--set` the PATH, because sharkey runs shellscripts at start (and maybe # at other times), which need these things. makeWrapper ${lib.getExe pnpm_9} $out/bin/sharkey \ --chdir $out/Sharkey \ --prefix PATH : ${binPath} \ --prefix LD_LIBRARY_PATH : ${libPath} runHook postInstall ''; passthru = { inherit (finalAttrs) pnpmDeps; }; meta = { description = "🌎 A Sharkish microblogging platform 🚀"; homepage = "https://joinsharkey.org"; license = lib.licenses.gpl3Only; platforms = ["x86_64-linux" "aarch64-linux"]; mainProgram = "sharkey"; }; })