nixpkgs mirror (for testing)
github.com/NixOS/nixpkgs
nix
1{ lib, stdenv, pkgs, fetchFromGitHub, runCommand, buildNpmPackage, nodejs_18, tone, ffmpeg-full, util-linux, libwebp }:
2
3let
4 nodejs = nodejs_18;
5
6 pname = "audiobookshelf";
7 version = "2.2.20";
8
9 src = fetchFromGitHub {
10 owner = "advplyr";
11 repo = pname;
12 rev = "v${version}";
13 sha256 = "sha256-nQHWmBMPBPgIe1YQi8wFmZGnwHcmYFxzfWPxyTo16zk=";
14 };
15
16 client = buildNpmPackage {
17 pname = "${pname}-client";
18 inherit version;
19
20 src = runCommand "cp-source" {} ''
21 cp -r ${src}/client $out
22 '';
23
24 NODE_OPTIONS = "--openssl-legacy-provider";
25
26 npmBuildScript = "generate";
27 npmDepsHash = "sha256-gCeLDYuC8uK8lEWTPCxr9NlOS6ADP+1oukYR7/xZ0aA=";
28 };
29
30 wrapper = import ./wrapper.nix {
31 inherit stdenv ffmpeg-full tone pname nodejs;
32 };
33
34in buildNpmPackage {
35 inherit pname version src;
36
37 buildInputs = [ util-linux ];
38
39 dontNpmBuild = true;
40 npmInstallFlags = [ "--only-production" ];
41 npmDepsHash = "sha256-LYvI+7KXXXyH6UuWEc2YdqoSdvljclLr8LlG7Cm2Pv8=";
42
43 installPhase = ''
44 mkdir -p $out/opt/client
45 cp -r index.js server package* node_modules $out/opt/
46 cp -r ${client}/lib/node_modules/${pname}-client/dist $out/opt/client/dist
47 mkdir $out/bin
48
49 echo '${wrapper}' > $out/bin/${pname}
50 echo " exec ${nodejs}/bin/node $out/opt/index.js" >> $out/bin/${pname}
51
52 chmod +x $out/bin/${pname}
53 '';
54
55 meta = with lib; {
56 homepage = "https://www.audiobookshelf.org/";
57 description = "Self-hosted audiobook and podcast server";
58 license = licenses.gpl3;
59 maintainers = [ maintainers.jvanbruegge ];
60 platforms = platforms.linux;
61 };
62}