audiobookshelf: init at 2.2.15

This commit is contained in:
Jan van Brügge 2023-01-29 01:20:37 +00:00
parent da9be96e07
commit c37e12ca1a
No known key found for this signature in database
GPG key ID: 88E0BF7B7A546481
3 changed files with 125 additions and 0 deletions

View file

@ -0,0 +1,62 @@
{ lib, stdenv, pkgs, fetchFromGitHub, runCommand, buildNpmPackage, nodejs-16_x, tone, ffmpeg-full, util-linux, libwebp }:
let
nodejs = nodejs-16_x;
pname = "audiobookshelf";
version = "2.2.15";
src = fetchFromGitHub {
owner = "advplyr";
repo = pname;
rev = "v${version}";
sha256 = "sha256-BrIXbembbcfSPOPknoY2Vn9I85eHyOQLDCMsFOMORgM=";
};
client = buildNpmPackage {
pname = "${pname}-client";
inherit version;
src = runCommand "cp-source" {} ''
cp -r ${src}/client $out
'';
NODE_OPTIONS = "--openssl-legacy-provider";
npmBuildScript = "generate";
npmDepsHash = "sha256-eyZdeBsZ5XBoO/4djXZzOOr/h9kDSUULbqgdOZJNNCg=";
};
wrapper = import ./wrapper.nix {
inherit stdenv ffmpeg-full tone pname nodejs;
};
in buildNpmPackage {
inherit pname version src;
buildInputs = [ util-linux ];
dontNpmBuild = true;
npmInstallFlags = "--only-production";
npmDepsHash = "sha256-KbewULna+0mftIcdO5Z4A5rOrheBndpgzjkE1Jytfr4=";
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}
'';
meta = with lib; {
homepage = "https://www.audiobookshelf.org/";
description = "Self-hosted audiobook and podcast server";
license = licenses.gpl3;
maintainers = [ maintainers.jvanbruegge ];
platforms = platforms.linux;
};
}

View file

@ -0,0 +1,61 @@
{ stdenv, ffmpeg-full, tone, pname, nodejs }: ''
#!${stdenv.shell}
port=8000
host=0.0.0.0
config=$(pwd)/config
metadata=$(pwd)/metadata
LONGOPTS=host:,port:,config:,metadata:,help
args=$(getopt -l "$LONGOPTS" -o h -- "$@")
eval set -- "$args"
while [ $# -ge 1 ]; do
case "$1" in
--)
# No more options left.
shift
break
;;
--host)
host="$2"
shift
;;
--port)
port="$2"
shift
;;
--config)
if [[ "''${2:0:1}" = "/" ]]; then
config="$2"
else
config="$(pwd)/$2"
fi
shift
;;
--metadata)
if [[ "''${2:0:1}" = "/" ]]; then
metadata="$2"
else
metadata="$(pwd)/$2"
fi
shift
;;
--help|-h)
echo "Usage: audiobookshelf [--host <host>] [--port <port>] [--metadata <dir>] [--config <dir>]"
shift
;;
esac
shift
done
NODE_ENV=production \
SOURCE=nixpkgs \
FFMPEG_PATH=${ffmpeg-full}/bin/ffmpeg \
FFPROBE_PATH=${ffmpeg-full}/bin/ffprobe \
TONE_PATH=${tone}/bin/tone \
CONFIG_PATH="$config" \
METADATA_PATH="$metadata" \
PORT="$port" \
HOST="$host" \''

View file

@ -1339,6 +1339,8 @@ with pkgs;
audible-cli = callPackage ../tools/misc/audible-cli { };
audiobookshelf = callPackage ../servers/audiobookshelf { };
auditwheel = callPackage ../tools/package-management/auditwheel { };
amidst = callPackage ../tools/games/minecraft/amidst { };