about summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--pkgs/by-name/sh/sharkey/package.nix4
-rw-r--r--pkgs/by-name/sh/sharkey/unstable_package.nix176
2 files changed, 180 insertions, 0 deletions
diff --git a/pkgs/by-name/sh/sharkey/package.nix b/pkgs/by-name/sh/sharkey/package.nix
new file mode 100644
index 0000000..22261fa
--- /dev/null
+++ b/pkgs/by-name/sh/sharkey/package.nix
@@ -0,0 +1,4 @@
+{pkgsUnstable}:
+# NOTE(@bpeetz): The package was written for unstable, and I don't see a reason to migrate
+# it back, considering that 25.05 is right around the corner. <2025-04-22>
+pkgsUnstable.callPackage ./unstable_package.nix {}
diff --git a/pkgs/by-name/sh/sharkey/unstable_package.nix b/pkgs/by-name/sh/sharkey/unstable_package.nix
new file mode 100644
index 0000000..3922ca0
--- /dev/null
+++ b/pkgs/by-name/sh/sharkey/unstable_package.nix
@@ -0,0 +1,176 @@
+# 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.2";
+
+  src = fetchFromGitLab {
+    owner = "TransFem-org";
+    repo = "Sharkey";
+    domain = "activitypub.software";
+    rev = finalAttrs.version;
+    hash = "sha256-KVr4KLtJ22LEk94GuxeTk8/GcFs7oU/gkoVTvrgbYBg=";
+    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-XWcDchvrYSJr0s/DMb8FIEK7MdE6aC2bAbrW88Ig4ug=";
+  };
+
+  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";
+  };
+})