about summary refs log tree commit diff
path: root/pkgs/servers/gotify/ui.nix
diff options
context:
space:
mode:
Diffstat (limited to 'pkgs/servers/gotify/ui.nix')
-rw-r--r--pkgs/servers/gotify/ui.nix72
1 files changed, 26 insertions, 46 deletions
diff --git a/pkgs/servers/gotify/ui.nix b/pkgs/servers/gotify/ui.nix
index 2933a6ca474b3..811fa41540ab3 100644
--- a/pkgs/servers/gotify/ui.nix
+++ b/pkgs/servers/gotify/ui.nix
@@ -1,67 +1,47 @@
-{ yarn2nix-moretea
-, fetchFromGitHub, applyPatches
+{ stdenv
+, yarn
+, fixup_yarn_lock
+, nodejs-slim
+, fetchFromGitHub
 , fetchYarnDeps
+, gotify-server
 }:
 
-yarn2nix-moretea.mkYarnPackage rec {
+stdenv.mkDerivation rec {
   pname = "gotify-ui";
+  inherit (gotify-server) version;
 
-  packageJSON = ./package.json;
+  src = gotify-server.src + "/ui";
 
   offlineCache = fetchYarnDeps {
     yarnLock = "${src}/yarn.lock";
     hash = "sha256-ejHzo6NHCMlNiYePWvfMY9Blb58pj3UQ5PFI0V84flI=";
   };
 
-  version = import ./version.nix;
+  nativeBuildInputs = [ yarn fixup_yarn_lock nodejs-slim ];
 
-  src_all = applyPatches {
-    src = fetchFromGitHub {
-      owner = "gotify";
-      repo = "server";
-      rev = "v${version}";
-      sha256 = import ./source-sha.nix;
-    };
-    postPatch = ''
-      substituteInPlace ui/yarn.lock \
-        --replace \
-          "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001237.tgz" \
-          "https___registry.npmjs.org_caniuse_lite___caniuse_lite_1.0.30001237.tgz"
-    '';
-  };
-  src = "${src_all}/ui";
+  postPatch = ''
+    export HOME=$NIX_BUILD_TOP/fake_home
+    yarn config --offline set yarn-offline-mirror $offlineCache
+    fixup_yarn_lock yarn.lock
+    yarn install --offline --frozen-lockfile --ignore-scripts --no-progress --non-interactive
+    patchShebangs node_modules/
+  '';
 
   buildPhase = ''
-    export HOME=$(mktemp -d)
-    export WRITABLE_NODE_MODULES="$(pwd)/tmp"
-    export NODE_OPTIONS=--openssl-legacy-provider
-    mkdir -p "$WRITABLE_NODE_MODULES"
+    runHook preBuild
 
-    # react-scripts requires a writable node_modules/.cache, so we have to copy the symlink's contents back
-    # into `node_modules/`.
-    # See https://github.com/facebook/create-react-app/issues/11263
-    cd deps/gotify-ui
-    node_modules="$(readlink node_modules)"
-    rm node_modules
-    mkdir -p "$WRITABLE_NODE_MODULES"/.cache
-    cp -r $node_modules/* "$WRITABLE_NODE_MODULES"
+    export NODE_OPTIONS=--openssl-legacy-provider
+    yarn --offline build
 
-    # In `node_modules/.bin` are relative symlinks that would be broken after copying them over,
-    # so we take care of them here.
-    mkdir -p "$WRITABLE_NODE_MODULES"/.bin
-    for x in "$node_modules"/.bin/*; do
-      ln -sfv "$node_modules"/.bin/"$(readlink "$x")" "$WRITABLE_NODE_MODULES"/.bin/"$(basename "$x")"
-    done
+    runHook postBuild
+  '';
 
-    ln -sfv "$WRITABLE_NODE_MODULES" node_modules
-    cd ../..
+  installPhase = ''
+    runHook preInstall
 
-    yarn build
+    mv build $out
 
-    cd deps/gotify-ui
-    rm -rf node_modules
-    ln -sf $node_modules node_modules
-    cd ../..
+    runHook postInstall
   '';
-
 }