about summary refs log tree commit diff
path: root/pkgs/servers/web-apps/lemmy/ui.nix
diff options
context:
space:
mode:
Diffstat (limited to 'pkgs/servers/web-apps/lemmy/ui.nix')
-rw-r--r--pkgs/servers/web-apps/lemmy/ui.nix85
1 files changed, 35 insertions, 50 deletions
diff --git a/pkgs/servers/web-apps/lemmy/ui.nix b/pkgs/servers/web-apps/lemmy/ui.nix
index 2bb1ccaeb8428..b3b267d2f7228 100644
--- a/pkgs/servers/web-apps/lemmy/ui.nix
+++ b/pkgs/servers/web-apps/lemmy/ui.nix
@@ -1,11 +1,11 @@
 { lib
-, mkYarnPackage
+, stdenvNoCC
 , libsass
 , nodejs
 , python3
 , pkg-config
+, pnpm_9
 , fetchFromGitHub
-, fetchYarnDeps
 , nixosTests
 , vips
 , nodePackages
@@ -14,85 +14,70 @@
 let
   pinData = lib.importJSON ./pin.json;
 
-  pkgConfig = {
-    node-sass = {
-      nativeBuildInputs = [ pkg-config ];
-      buildInputs = [ libsass python3 ];
-      postInstall = ''
-        LIBSASS_EXT=auto yarn --offline run build
-        rm build/config.gypi
-      '';
-    };
-    sharp = {
-      nativeBuildInputs = [ pkg-config nodePackages.node-gyp nodePackages.semver ];
-      buildInputs = [ vips ];
-      postInstall = ''
-        yarn --offline run install
-      '';
-    };
-  };
 
-  name = "lemmy-ui";
+in
+
+stdenvNoCC.mkDerivation (finalAttrs: {
+
+  pname = "lemmy-ui";
   version = pinData.uiVersion;
 
-  src = fetchFromGitHub {
+  src = with finalAttrs; fetchFromGitHub {
     owner = "LemmyNet";
-    repo = name;
+    repo = pname;
     rev = version;
     fetchSubmodules = true;
     hash = pinData.uiHash;
   };
-in
-mkYarnPackage {
 
-  inherit src pkgConfig name version;
+  nativeBuildInputs = [
+    nodejs
+    pnpm_9.configHook
+  ];
 
-  extraBuildInputs = [ libsass ];
+  buildInputs = [libsass vips ];
 
-  packageJSON = ./package.json;
-  offlineCache = fetchYarnDeps {
-    yarnLock = src + "/yarn.lock";
-    hash = pinData.uiYarnDepsHash;
+  extraBuildInputs = [ libsass ];
+  pnpmDeps = pnpm_9.fetchDeps {
+    inherit (finalAttrs) pname version src;
+    hash = pinData.uiPNPMDepsHash;
   };
 
-  patchPhase = ''
-    substituteInPlace ./package.json \
-      --replace '$(git rev-parse --short HEAD)' "${src.rev}" \
-      --replace 'yarn clean' 'yarn --offline clean' \
-      --replace 'yarn run rimraf dist' 'yarn --offline run rimraf dist'
-  '';
+  buildPhase = ''
+    runHook preBuild
+
+    pnpm build:prod
 
-  yarnPreBuild = ''
-    export npm_config_nodedir=${nodejs}
+    runHook postBuild
   '';
 
-  buildPhase = ''
-    # Yarn writes cache directories etc to $HOME.
-    export HOME=$PWD/yarn_home
+  # installPhase = ''
+  #     runHook preInstall
 
-    ln -sf $PWD/node_modules $PWD/deps/lemmy-ui/
-    echo 'export const VERSION = "${version}";' > $PWD/deps/lemmy-ui/src/shared/version.ts
+  #     mkdir -p $out/{bin,lib/${finalAttrs.pname}}
+  #     mv {dist,node_modules} $out/lib/${finalAttrs.pname}
 
-    yarn --offline build:prod
-  '';
+  #     runHook postInstall
 
-  preInstall = ''
+  #  '';
+    preInstall = ''
     mkdir $out
-    cp -R ./deps/lemmy-ui/dist $out
+    cp -R ./dist $out
     cp -R ./node_modules $out
   '';
 
+
   distPhase = "true";
 
   passthru.updateScript = ./update.py;
   passthru.tests.lemmy-ui = nixosTests.lemmy;
-  passthru.commit_sha = src.rev;
+  passthru.commit_sha = finalAttrs.src.rev;
 
   meta = with lib; {
     description = "Building a federated alternative to reddit in rust";
     homepage = "https://join-lemmy.org/";
     license = licenses.agpl3Only;
-    maintainers = with maintainers; [ happysalada billewanick ];
+    maintainers = with maintainers; [ happysalada billewanick georgyo ];
     inherit (nodejs.meta) platforms;
   };
-}
+})