nix-config/pkgs/your_spotify.nix

80 lines
2.5 KiB
Nix
Raw Normal View History

2024-02-29 20:57:46 +01:00
{
callPackage,
2024-02-29 20:57:46 +01:00
fetchFromGitHub,
fetchYarnDeps,
lib,
2024-02-29 20:57:46 +01:00
makeWrapper,
mkYarnPackage,
2024-02-29 20:57:46 +01:00
nodejs,
2024-03-06 13:04:44 +01:00
prefetch-yarn-deps,
yarn,
2024-02-29 20:57:46 +01:00
}: let
version = "1.10.1";
2024-03-04 21:10:01 +01:00
src = fetchFromGitHub {
2024-02-29 20:57:46 +01:00
owner = "Yooooomi";
repo = "your_spotify";
rev = "refs/tags/${version}";
hash = "sha256-e82j2blGxQLWAlBNuAnFvlD9vwMk4/mRI0Vf7vuaPA0=";
2024-02-29 20:57:46 +01:00
};
2024-03-04 21:10:01 +01:00
client = callPackage ./your_spotify_client.nix {inherit src version;};
2024-02-29 20:57:46 +01:00
in
mkYarnPackage rec {
2024-03-04 21:10:01 +01:00
inherit version src;
pname = "your_spotify_server";
name = "your_spotify_server-${version}";
2024-02-29 20:57:46 +01:00
offlineCache = fetchYarnDeps {
yarnLock = src + "/yarn.lock";
hash = "sha256-5SgknaRVzgO2Dzc8MhAaM8UERWMv+PrItzevoWHbWnA=";
2024-02-29 20:57:46 +01:00
};
2024-03-06 13:04:44 +01:00
configurePhase = ''
runHook preConfigure
export HOME=$(mktemp -d)
yarn config --offline set yarn-offline-mirror $offlineCache
fixup-yarn-lock yarn.lock
runHook postConfigure
'';
2024-02-29 20:57:46 +01:00
buildPhase = ''
runHook preBuild
yarn install --offline --frozen-lockfile --ignore-platform --ignore-scripts --no-progress --non-interactive
patchShebangs node_modules/
2024-03-06 13:04:44 +01:00
pushd ./apps/server/
yarn --offline run build
2024-02-29 20:57:46 +01:00
popd
rm -r node_modules
export NODE_ENV="production"
yarn install --offline --frozen-lockfile --ignore-platform --ignore-scripts --no-progress --non-interactive
patchShebangs node_modules/
2024-02-29 20:57:46 +01:00
runHook postBuild
'';
2024-03-06 13:04:44 +01:00
nativeBuildInputs = [makeWrapper yarn prefetch-yarn-deps];
2024-02-29 20:57:46 +01:00
installPhase = ''
mkdir -p $out/share/your_spotify
cp -r node_modules $out/share/your_spotify/node_modules
2024-03-06 13:04:44 +01:00
cp -r ./apps/server/{lib,package.json} $out
2024-02-29 20:57:46 +01:00
mkdir -p $out/bin
makeWrapper ${lib.escapeShellArg (lib.getExe nodejs)} "$out/bin/your_spotify_migrate" \
--add-flags "$out/lib/migrations.js" --set NODE_PATH "$out/share/your_spotify/node_modules"
2024-02-29 20:57:46 +01:00
makeWrapper ${lib.escapeShellArg (lib.getExe nodejs)} "$out/bin/your_spotify_server" \
--add-flags "$out/lib/index.js" --set NODE_PATH "$out/share/your_spotify/node_modules"
2024-02-29 20:57:46 +01:00
'';
doDist = false;
2024-03-01 12:58:02 +01:00
passthru = {
inherit client;
};
meta = with lib; {
homepage = "https://github.com/Yooooomi/your_spotify";
changelog = "https://github.com/Yooooomi/your_spotify/releases/tag/${version}";
description = "Self-hosted application that tracks what you listen and offers you a dashboard to explore statistics about it";
license = licenses.gpl3Only;
maintainers = with maintainers; [patrickdag];
mainProgram = "your_spotify_server";
};
2024-02-29 20:57:46 +01:00
}