a dotfile but it's really big
1{
2 lib,
3 buildNpmPackage,
4 fetchFromGitHub,
5 nodejs,
6 makeWrapper,
7 bashNonInteractive,
8 ...
9}:
10buildNpmPackage rec {
11 pname = "multi-scrobbler";
12 version = "0.10.8";
13
14 src = fetchFromGitHub {
15 owner = "FoxxMD";
16 repo = "multi-scrobbler";
17 rev = version;
18 hash = "sha256-knHOAE5reDN7fVmA2guQFG49jiQobzLpFlm6N1TioSI=";
19 };
20
21 npmDepsHash = "sha256-4do1Hm6c82v0I2N7eO700k4rOBjLOx373QKKuhi5/uU=";
22
23 nativeBuildInputs = [
24 makeWrapper
25 bashNonInteractive
26 ];
27
28 inherit nodejs;
29
30 buildPhase = ''
31 runHook preBuild
32
33 npm run build:backend
34 npm run build:frontend
35
36 runHook postBuild
37 '';
38
39 installPhase = ''
40 runHook preInstall
41
42 npm prune --production
43
44 mkdir -p $out/bin $out/share/multi-scrobbler
45 cp -r * $out/share/multi-scrobbler/
46
47 runHook postInstall
48 '';
49
50 postInstall = ''
51 # Copy tsconfig for ts-json-schema-generator to find at runtime
52 # The app expects tsconfig.json to be in the working directory under src/backend/
53 # We'll preserve the source directory structure
54 mkdir -p $out/share/multi-scrobbler/src/backend
55 cp src/backend/tsconfig.json $out/share/multi-scrobbler/src/backend/
56
57 # Create wrapper with working directory set to the source install location
58 makeWrapper ${nodejs}/bin/node $out/bin/multi-scrobbler \
59 --add-flags "$out/share/multi-scrobbler/node_modules/tsx/dist/cli.mjs" \
60 --add-flags "$out/share/multi-scrobbler/src/backend/index.ts" \
61 --chdir "$out/share/multi-scrobbler"
62 '';
63
64 meta = with lib; {
65 description = "Scrobble plays from multiple sources to multiple clients";
66 homepage = "https://github.com/FoxxMD/multi-scrobbler";
67 license = licenses.mit;
68 mainProgram = "multi-scrobbler";
69 };
70}