Merge: zmap: 4.2.0 -> 4.3.1 (#364578)
[NixPkgs.git] / pkgs / by-name / yo / your_spotify / package.nix
blob78c1b96700f942071b3ae991f8c1a7c5441d3632
2   lib,
3   stdenv,
4   fetchFromGitHub,
5   fetchYarnDeps,
6   yarnConfigHook,
7   yarnBuildHook,
8   nodejs,
9   makeWrapper,
10   callPackage,
11   nixosTests,
12   nix-update-script,
15 stdenv.mkDerivation (finalAttrs: {
16   pname = "your_spotify_server";
17   version = "1.11.0";
19   src = fetchFromGitHub {
20     owner = "Yooooomi";
21     repo = "your_spotify";
22     rev = "refs/tags/${finalAttrs.version}";
23     hash = "sha256-BytHkvm0gfMnsKe2gDTARWYIHBpfAfIisf2p4bmrpMA=";
24   };
26   offlineCache = fetchYarnDeps {
27     yarnLock = finalAttrs.src + "/yarn.lock";
28     hash = "sha256-D7rL3hxidLaChCwn5umQAnWr4cTVQ1iwDs5+gIDgBGI=";
29   };
31   nativeBuildInputs = [
32     makeWrapper
33     yarnConfigHook
34     yarnBuildHook
35     nodejs
36   ];
38   preBuild = ''
39     pushd ./apps/server/
40   '';
41   postBuild = ''
42     popd
43     rm -r node_modules
44     export NODE_ENV="production"
45     yarn install --offline --frozen-lockfile --ignore-platform --ignore-scripts --no-progress --non-interactive
46     patchShebangs node_modules/
47   '';
49   installPhase = ''
50     runHook preInstall
52     mkdir -p $out/share/your_spotify
53     cp -r node_modules $out/share/your_spotify/node_modules
54     cp -r ./apps/server/{lib,package.json} $out
55     mkdir -p $out/bin
56     makeWrapper ${lib.escapeShellArg (lib.getExe nodejs)} "$out/bin/your_spotify_migrate" \
57       --add-flags "$out/lib/migrations.js" --set NODE_PATH "$out/share/your_spotify/node_modules"
58     makeWrapper ${lib.escapeShellArg (lib.getExe nodejs)} "$out/bin/your_spotify_server" \
59       --add-flags "$out/lib/index.js" --set NODE_PATH "$out/share/your_spotify/node_modules"
61     runHook postInstall
62   '';
64   passthru = {
65     client = callPackage ./client.nix {
66       inherit (finalAttrs)
67         src
68         version
69         offlineCache
70         meta
71         ;
72     };
73     tests = {
74       inherit (nixosTests) your_spotify;
75     };
76     updateScript = nix-update-script { };
77   };
79   meta = {
80     homepage = "https://github.com/Yooooomi/your_spotify";
81     changelog = "https://github.com/Yooooomi/your_spotify/releases/tag/${finalAttrs.version}";
82     description = "Self-hosted application that tracks what you listen and offers you a dashboard to explore statistics about it";
83     license = lib.licenses.gpl3Only;
84     maintainers = with lib.maintainers; [ patrickdag ];
85     mainProgram = "your_spotify_server";
86   };