about summary refs log tree commit diff
path: root/nixpkgs/pkgs/by-name/au/audiobookshelf/package.nix
diff options
context:
space:
mode:
Diffstat (limited to 'nixpkgs/pkgs/by-name/au/audiobookshelf/package.nix')
-rw-r--r--nixpkgs/pkgs/by-name/au/audiobookshelf/package.nix80
1 files changed, 80 insertions, 0 deletions
diff --git a/nixpkgs/pkgs/by-name/au/audiobookshelf/package.nix b/nixpkgs/pkgs/by-name/au/audiobookshelf/package.nix
new file mode 100644
index 000000000000..01d49a5fee69
--- /dev/null
+++ b/nixpkgs/pkgs/by-name/au/audiobookshelf/package.nix
@@ -0,0 +1,80 @@
+{
+  lib,
+  stdenv,
+  fetchFromGitHub,
+  runCommand,
+  buildNpmPackage,
+  nodejs_18,
+  tone,
+  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
+    '';
+
+    NODE_OPTIONS = "--openssl-legacy-provider";
+
+    npmBuildScript = "generate";
+    npmDepsHash = source.clientDepsHash;
+  };
+
+  wrapper = import ./wrapper.nix {
+    inherit stdenv ffmpeg-full tone 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";
+  };
+}