diff options
Diffstat (limited to 'pkgs/by-name/yo/your_spotify/package.nix')
-rw-r--r-- | pkgs/by-name/yo/your_spotify/package.nix | 127 |
1 files changed, 61 insertions, 66 deletions
diff --git a/pkgs/by-name/yo/your_spotify/package.nix b/pkgs/by-name/yo/your_spotify/package.nix index 0296b9d22c028..77864788fa197 100644 --- a/pkgs/by-name/yo/your_spotify/package.nix +++ b/pkgs/by-name/yo/your_spotify/package.nix @@ -1,85 +1,80 @@ { - callPackage, + lib, + stdenv, fetchFromGitHub, fetchYarnDeps, - lib, - makeWrapper, - mkYarnPackage, + yarnConfigHook, + yarnBuildHook, nodejs, - fixup-yarn-lock, - yarn, -}: let + makeWrapper, + callPackage, + nixosTests, +}: + +stdenv.mkDerivation (finalAttrs: { + pname = "your_spotify_server"; version = "1.10.1"; + src = fetchFromGitHub { owner = "Yooooomi"; repo = "your_spotify"; - rev = "refs/tags/${version}"; + rev = "refs/tags/${finalAttrs.version}"; hash = "sha256-e82j2blGxQLWAlBNuAnFvlD9vwMk4/mRI0Vf7vuaPA0="; }; - client = callPackage ./client.nix {inherit src version;}; -in - mkYarnPackage rec { - inherit version src; - pname = "your_spotify_server"; - name = "your_spotify_server-${version}"; - packageJSON = ./package.json; - offlineCache = fetchYarnDeps { - yarnLock = src + "/yarn.lock"; - hash = "sha256-5SgknaRVzgO2Dzc8MhAaM8UERWMv+PrItzevoWHbWnA="; - }; - - configurePhase = '' - runHook preConfigure - - export HOME=$(mktemp -d) - yarn config --offline set yarn-offline-mirror $offlineCache - fixup-yarn-lock yarn.lock - - runHook postConfigure - ''; - buildPhase = '' - runHook preBuild + offlineCache = fetchYarnDeps { + yarnLock = finalAttrs.src + "/yarn.lock"; + hash = "sha256-5SgknaRVzgO2Dzc8MhAaM8UERWMv+PrItzevoWHbWnA="; + }; - yarn install --offline --frozen-lockfile --ignore-platform --ignore-scripts --no-progress --non-interactive - patchShebangs node_modules/ + nativeBuildInputs = [ + makeWrapper + yarnConfigHook + yarnBuildHook + nodejs + ]; - pushd ./apps/server/ - yarn --offline run build - popd + preBuild = '' + pushd ./apps/server/ + ''; + postBuild = '' + 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/ + ''; - rm -r node_modules - export NODE_ENV="production" - yarn install --offline --frozen-lockfile --ignore-platform --ignore-scripts --no-progress --non-interactive - patchShebangs node_modules/ + installPhase = '' + runHook preInstall - runHook postBuild - ''; - nativeBuildInputs = [makeWrapper yarn fixup-yarn-lock]; - installPhase = '' - runHook preInstall + mkdir -p $out/share/your_spotify + cp -r node_modules $out/share/your_spotify/node_modules + cp -r ./apps/server/{lib,package.json} $out + 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" + 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" - mkdir -p $out/share/your_spotify - cp -r node_modules $out/share/your_spotify/node_modules - cp -r ./apps/server/{lib,package.json} $out - 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" - 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" + runHook postInstall + ''; - runHook postInstall - ''; - doDist = false; - passthru = { - inherit client; + passthru = { + client = callPackage ./client.nix { + inherit (finalAttrs) src version offlineCache meta; }; - 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"; + tests = { + inherit (nixosTests) your_spotify; }; - } + }; + + meta = { + homepage = "https://github.com/Yooooomi/your_spotify"; + changelog = "https://github.com/Yooooomi/your_spotify/releases/tag/${finalAttrs.version}"; + description = "Self-hosted application that tracks what you listen and offers you a dashboard to explore statistics about it"; + license = lib.licenses.gpl3Only; + maintainers = with lib.maintainers; [ patrickdag ]; + mainProgram = "your_spotify_server"; + }; +}) |