diff options
author | Jan van Brügge <supermanitu@gmail.com> | 2023-01-29 01:20:37 +0000 |
---|---|---|
committer | Jan van Brügge <supermanitu@gmail.com> | 2023-02-17 18:19:10 +0000 |
commit | c37e12ca1ac8c1ab374a9b586a444116f4e33be6 (patch) | |
tree | a6be893aa5f54fc93fc30f82d04a632eb549380e /pkgs/servers/audiobookshelf | |
parent | da9be96e07ec05a6ea484295cf58af80ac6e36d3 (diff) |
audiobookshelf: init at 2.2.15
Diffstat (limited to 'pkgs/servers/audiobookshelf')
-rw-r--r-- | pkgs/servers/audiobookshelf/default.nix | 62 | ||||
-rw-r--r-- | pkgs/servers/audiobookshelf/wrapper.nix | 61 |
2 files changed, 123 insertions, 0 deletions
diff --git a/pkgs/servers/audiobookshelf/default.nix b/pkgs/servers/audiobookshelf/default.nix new file mode 100644 index 0000000000000..fb569fc54bec7 --- /dev/null +++ b/pkgs/servers/audiobookshelf/default.nix @@ -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; + }; +} diff --git a/pkgs/servers/audiobookshelf/wrapper.nix b/pkgs/servers/audiobookshelf/wrapper.nix new file mode 100644 index 0000000000000..cbe7e3ebd9710 --- /dev/null +++ b/pkgs/servers/audiobookshelf/wrapper.nix @@ -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" \'' |