about summary refs log tree commit diff
path: root/nixpkgs/pkgs/servers/polaris
diff options
context:
space:
mode:
Diffstat (limited to 'nixpkgs/pkgs/servers/polaris')
-rw-r--r--nixpkgs/pkgs/servers/polaris/default.nix76
-rw-r--r--nixpkgs/pkgs/servers/polaris/web.nix38
2 files changed, 114 insertions, 0 deletions
diff --git a/nixpkgs/pkgs/servers/polaris/default.nix b/nixpkgs/pkgs/servers/polaris/default.nix
new file mode 100644
index 000000000000..35ebd2d66d88
--- /dev/null
+++ b/nixpkgs/pkgs/servers/polaris/default.nix
@@ -0,0 +1,76 @@
+{ lib
+, stdenv
+, fetchFromGitHub
+, rustPlatform
+, nix-update-script
+, polaris-web
+, darwin
+, nixosTests
+}:
+
+rustPlatform.buildRustPackage rec {
+  pname = "polaris";
+  version = "0.14.2";
+
+  src = fetchFromGitHub {
+    owner = "agersant";
+    repo = "polaris";
+    rev = version;
+    hash = "sha256-UC66xRL9GyTPHJ3z0DD/yyI9GlyqelCaHHDyl79ptJg=";
+
+    # The polaris version upstream in Cargo.lock is "0.0.0".
+    # We're unable to simply patch it in the patch phase due to
+    # rustPlatform.buildRustPackage fetching dependencies before applying patches.
+    # If we patch it after fetching dependencies we get an error when
+    # validating consistency between the final build and the prefetched deps.
+    postFetch = ''
+      # 'substituteInPlace' does not support multiline replacements?
+      sed -i $out/Cargo.lock -z \
+        -e 's/\[\[package\]\]\nname = "polaris"\nversion = "0.0.0"/[[package]]\nname = "polaris"\nversion = "'"${version}"'"/g'
+    '';
+  };
+
+  cargoHash = "sha256-+4WN6TTIzVu3Jj0SfPq2jnYh0oWRo/C4qDMeJLrj1kk=";
+
+  buildInputs = lib.optionals stdenv.isDarwin [
+    darwin.Security
+  ];
+
+  # Compile-time environment variables for where to find assets needed at runtime
+  env = {
+    POLARIS_WEB_DIR = "${polaris-web}/share/polaris-web";
+    POLARIS_SWAGGER_DIR = "${placeholder "out"}/share/polaris-swagger";
+  };
+
+  postInstall = ''
+    mkdir -p $out/share
+    cp -a docs/swagger $out/share/polaris-swagger
+  '';
+
+  preCheck = ''
+    # 'Err' value: Os { code: 24, kind: Uncategorized, message: "Too many open files" }
+    ulimit -n 4096
+  '';
+
+  __darwinAllowLocalNetworking = true;
+
+  passthru.tests = nixosTests.polaris;
+  passthru.updateScript = nix-update-script {
+    attrPath = pname;
+  };
+
+  meta = with lib; {
+    description = "Self-host your music collection, and access it from any computer and mobile device";
+    longDescription = ''
+      Polaris is a FOSS music streaming application, designed to let you enjoy your music collection
+      from any computer or mobile device. Polaris works by streaming your music directly from your
+      own computer, without uploading it to a third-party. There are no  kind of premium version.
+      The only requirement is that your computer stays on while it streams your music!
+    '';
+    homepage = "https://github.com/agersant/polaris";
+    license = licenses.mit;
+    maintainers = with maintainers; [ pbsds ];
+    platforms = platforms.unix;
+    mainProgram = "polaris";
+  };
+}
diff --git a/nixpkgs/pkgs/servers/polaris/web.nix b/nixpkgs/pkgs/servers/polaris/web.nix
new file mode 100644
index 000000000000..1834c01a0547
--- /dev/null
+++ b/nixpkgs/pkgs/servers/polaris/web.nix
@@ -0,0 +1,38 @@
+{ lib
+, buildNpmPackage
+, fetchFromGitHub
+}:
+
+buildNpmPackage rec {
+  pname = "polaris-web";
+  version = "69";
+
+  src = fetchFromGitHub {
+    owner = "agersant";
+    repo = "polaris-web";
+    rev = "build-${version}";
+    hash = "sha256-/UmAOunc/79DpZByUrzqNA7q7JNugEceKRZvyTGhtVQ=";
+  };
+
+  npmDepsHash = "sha256-c11CWJB76gX+Bxmqac3VxWjJxQVzYCaaf+pmQQpnOds=";
+
+  env.CYPRESS_INSTALL_BINARY = "0";
+
+  npmBuildScript = "production";
+
+  installPhase = ''
+    runHook preInstall
+
+    mkdir -p $out/share
+    cp -a dist $out/share/polaris-web
+
+    runHook postInstall
+  '';
+
+  meta = with lib; {
+    description = "Web client for Polaris";
+    homepage = "https://github.com/agersant/polaris-web";
+    license = licenses.mit;
+    maintainers = with maintainers; [ pbsds ];
+  };
+}