blob: 29c0d5adad6654cdcb2922d1eb02f82555f302c6 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
|
{
lib,
stdenv,
fetchFromGitHub,
runCommand,
buildNpmPackage,
nodejs_18,
ffmpeg-full,
util-linux,
python3,
getopt
}:
let
nodejs = nodejs_18;
source = builtins.fromJSON (builtins.readFile ./source.json);
pname = "audiobookshelf";
src = fetchFromGitHub {
owner = "advplyr";
repo = pname;
rev = "refs/tags/v${source.version}";
inherit (source) hash;
};
client = buildNpmPackage {
pname = "${pname}-client";
inherit (source) version;
src = runCommand "cp-source" {} ''
cp -r ${src}/client $out
'';
# don't download the Cypress binary
CYPRESS_INSTALL_BINARY = 0;
NODE_OPTIONS = "--openssl-legacy-provider";
npmBuildScript = "generate";
npmDepsHash = source.clientDepsHash;
};
wrapper = import ./wrapper.nix {
inherit stdenv ffmpeg-full pname nodejs getopt;
};
in buildNpmPackage {
inherit pname src;
inherit (source) version;
buildInputs = [ util-linux ];
nativeBuildInputs = [ python3 ];
dontNpmBuild = true;
npmInstallFlags = [ "--only-production" ];
npmDepsHash = source.depsHash;
installPhase = ''
mkdir -p $out/opt/client
cp -r index.js server package* node_modules $out/opt/
cp -r ${client}/lib/node_modules/${pname}-client/dist $out/opt/client/dist
mkdir $out/bin
echo '${wrapper}' > $out/bin/${pname}
echo " exec ${nodejs}/bin/node $out/opt/index.js" >> $out/bin/${pname}
chmod +x $out/bin/${pname}
'';
passthru.updateScript = ./update.nu;
meta = with lib; {
homepage = "https://www.audiobookshelf.org/";
description = "Self-hosted audiobook and podcast server";
changelog = "https://github.com/advplyr/audiobookshelf/releases/tag/v${source.version}";
license = licenses.gpl3;
maintainers = [ maintainers.jvanbruegge maintainers.adamcstephens ];
platforms = platforms.linux;
mainProgram = "audiobookshelf";
};
}
|