about summary refs log tree commit diff
path: root/pkgs/servers/polaris/web.nix
diff options
context:
space:
mode:
authorPeder Bergebakken Sundt <pbsds@hotmail.com>2022-06-17 20:03:34 +0200
committerYt <happysalada@proton.me>2022-07-08 12:27:48 -0400
commit50ba995a1c1a1a6403d3bd45f99d09d02492ff56 (patch)
tree8f40ad30ee7c22a6c92761351cc6822c7b1163c3 /pkgs/servers/polaris/web.nix
parent97039777aa04b646510e3351a6b72e12e3215115 (diff)
polaris: init at 0.13.5
Polaris is a self-hosted music streaming server, with a
web and android frontend. The web frontend is included.
https://github.com/agersant/polaris

Polaris-web uses an odd versioning schema: 'build-X'. We reuse
the upstream tags. Polaris CI releases automatically bundle the
latest available version of polaris-web, however 'polaris' has seen
no release since april 2021, while polaris-web has had 5 version
bumps since. Currently we package the version of polaris-web
bundled with polaris on github. Once the newer versions are tested
we might upgrade.
Diffstat (limited to 'pkgs/servers/polaris/web.nix')
-rw-r--r--pkgs/servers/polaris/web.nix79
1 files changed, 79 insertions, 0 deletions
diff --git a/pkgs/servers/polaris/web.nix b/pkgs/servers/polaris/web.nix
new file mode 100644
index 0000000000000..b8a97e625d213
--- /dev/null
+++ b/pkgs/servers/polaris/web.nix
@@ -0,0 +1,79 @@
+{ lib
+, stdenv
+, pkgs
+, fetchFromGitHub
+, nodejs
+, cypress
+}:
+
+stdenv.mkDerivation rec {
+  pname = "polaris-web";
+  version = "build-50";
+
+  src = fetchFromGitHub {
+    owner = "agersant";
+    repo = "polaris-web";
+    rev = "${version}";
+    sha256 = "Xe+eAlWIDJR4CH1KCQaVlMAunpEikrmD96B5cqFWYYM=";
+  };
+
+  nativeBuildInputs = [
+    nodejs
+  ];
+
+  buildPhase =
+    let
+      nodeDependencies = (import ./node-composition.nix {
+        inherit pkgs nodejs;
+        inherit (stdenv.hostPlatform) system;
+      }).nodeDependencies.override (old: {
+        # access to path '/nix/store/...-source' is forbidden in restricted mode
+        src = src;
+        dontNpmInstall = true;
+
+        # ERROR: .../.bin/node-gyp-build: /usr/bin/env: bad interpreter: No such file or directory
+        # https://github.com/svanderburg/node2nix/issues/275
+        # There are multiple instances of it, hence the globstar
+        preRebuild = ''
+          shopt -s globstar
+          sed -i -e "s|#!/usr/bin/env node|#! ${pkgs.nodejs}/bin/node|" \
+            node_modules/**/node-gyp-build/bin.js \
+        '';
+
+        buildInputs = [ cypress ];
+        # prevent downloading cypress, use the executable in path instead
+        CYPRESS_INSTALL_BINARY = "0";
+
+      });
+    in
+    ''
+      runHook preBuild
+
+      export PATH="${nodeDependencies}/bin:${nodejs}/bin:$PATH"
+
+      ln -s ${nodeDependencies}/lib/node_modules .
+      npm run production
+
+      runHook postBuild
+    '';
+
+
+  installPhase = ''
+    runHook preInstall
+
+    mkdir -p $out/share
+    cp -a dist $out/share/polaris-web
+
+    runHook postInstall
+  '';
+
+  passthru.updateScript = ./update-web.sh;
+
+  meta = with lib; {
+    description = "Web client for Polaris";
+    homepage = "https://github.com/agersant/polaris-web";
+    license = licenses.mit;
+    maintainers = with maintainers; [ pbsds ];
+    platforms = platforms.unix;
+  };
+}