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.
This commit is contained in:
Peder Bergebakken Sundt 2022-06-17 20:03:34 +02:00 committed by Yt
parent 97039777aa
commit 50ba995a1c
7 changed files with 10029 additions and 0 deletions

View File

@ -0,0 +1,56 @@
{ lib
, stdenv
, fetchFromGitHub
, rustPlatform
, polaris-web
}:
rustPlatform.buildRustPackage rec {
pname = "polaris";
version = "0.13.5";
src = fetchFromGitHub {
owner = "agersant";
repo = "polaris";
rev = "${version}";
sha256 = "sp1KDTzKvcGtuqL37fFnVgcnkIsmj5ZQji72BeyiFQE=";
# 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'
'';
};
cargoSha256 = "sha256-0VHrlUoyYu+UTUQUioftBDlQJfLd/axz6bGJs+YXSmE=";
# Compile-time environment variables for where to find assets needed at runtime
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
'';
passthru.updateScript = ./update.sh;
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;
};
}

View File

@ -0,0 +1,17 @@
# This file has been generated by node2nix 1.11.1. Do not edit!
{pkgs ? import <nixpkgs> {
inherit system;
}, system ? builtins.currentSystem, nodejs ? pkgs."nodejs-12_x"}:
let
nodeEnv = import ../../development/node-packages/node-env.nix {
inherit (pkgs) stdenv lib python2 runCommand writeTextFile writeShellScript;
inherit pkgs nodejs;
libtool = if pkgs.stdenv.isDarwin then pkgs.darwin.cctools else null;
};
in
import ./node-packages.nix {
inherit (pkgs) fetchurl nix-gitignore stdenv lib fetchgit;
inherit nodeEnv;
}

9824
pkgs/servers/polaris/node-packages.nix generated Normal file

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,31 @@
#!/usr/bin/env nix-shell
#!nix-shell -i bash -p common-updater-scripts nodePackages.node2nix curl jq gnused nix coreutils
set -euo pipefail
pushd .
cd "$(dirname "${BASH_SOURCE[0]}")"/../../..
latestVersion="$(curl -s "https://api.github.com/repos/agersant/polaris-web/releases?per_page=1" | jq -r ".[0].tag_name")"
currentVersion=$(nix-instantiate --eval -E "with import ./. {}; polaris-web.version or (lib.getVersion polaris-web)" | tr -d '"')
if [[ "$currentVersion" == "$latestVersion" ]]; then
echo "polaris-web is up-to-date: $currentVersion"
exit 0
fi
update-source-version polaris-web "$latestVersion"
store_src="$(nix-build . -A polaris-web.src --no-out-link)"
popd
cd "$(dirname "${BASH_SOURCE[0]}")"
node2nix \
--nodejs-12 \
--development \
--node-env ../../development/node-packages/node-env.nix \
--input "$store_src"/package.json \
--lock "$store_src"/package-lock.json \
--output ./node-packages.nix \
--composition ./node-composition.nix

18
pkgs/servers/polaris/update.sh Executable file
View File

@ -0,0 +1,18 @@
#!/usr/bin/env nix-shell
#!nix-shell -i bash -p common-updater-scripts curl jq nix coreutils
set -euo pipefail
cd "$(dirname "${BASH_SOURCE[0]}")"/../../..
# update github tag and hash
latestVersion="$(curl -s "https://api.github.com/repos/agersant/polaris/releases?per_page=1" | jq -r ".[0].tag_name")"
currentVersion=$(nix-instantiate --eval -E "with import ./. {}; polaris.version or (lib.getVersion polaris)" | tr -d '"')
if [[ "$currentVersion" == "$latestVersion" ]]; then
echo "polaris is up-to-date: $currentVersion"
exit 0
fi
update-source-version polaris "$latestVersion"

View File

@ -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;
};
}

View File

@ -9706,6 +9706,10 @@ with pkgs;
wxGTK30-gtk3 = wxGTK30-gtk3.override { withWebKit = true; };
};
polaris = callPackage ../servers/polaris { };
polaris-web = callPackage ../servers/polaris/web.nix { };
polipo = callPackage ../servers/polipo { };
polkit_gnome = callPackage ../tools/security/polkit-gnome { };