diff --git a/pkgs/servers/audiobookshelf/default.nix b/pkgs/by-name/au/audiobookshelf/package.nix similarity index 76% rename from pkgs/servers/audiobookshelf/default.nix rename to pkgs/by-name/au/audiobookshelf/package.nix index 52775068fba2..01d49a5fee69 100644 --- a/pkgs/servers/audiobookshelf/default.nix +++ b/pkgs/by-name/au/audiobookshelf/package.nix @@ -15,19 +15,19 @@ let nodejs = nodejs_18; + source = builtins.fromJSON (builtins.readFile ./source.json); pname = "audiobookshelf"; - version = "2.7.1"; src = fetchFromGitHub { owner = "advplyr"; repo = pname; - rev = "v${version}"; - sha256 = "sha256-ROxVAevnxCyND/h1yyXfUeK9v5SEULL8gkR3flTmmW8="; + rev = "refs/tags/v${source.version}"; + inherit (source) hash; }; client = buildNpmPackage { pname = "${pname}-client"; - inherit version; + inherit (source) version; src = runCommand "cp-source" {} '' cp -r ${src}/client $out @@ -36,7 +36,7 @@ let NODE_OPTIONS = "--openssl-legacy-provider"; npmBuildScript = "generate"; - npmDepsHash = "sha256-2t/+IpmgTZglh3SSuYZNUvT1RZCDZGVT2gS57KU1mqA="; + npmDepsHash = source.clientDepsHash; }; wrapper = import ./wrapper.nix { @@ -44,14 +44,15 @@ let }; in buildNpmPackage { - inherit pname version src; + inherit pname src; + inherit (source) version; buildInputs = [ util-linux ]; nativeBuildInputs = [ python3 ]; dontNpmBuild = true; npmInstallFlags = [ "--only-production" ]; - npmDepsHash = "sha256-1VVFGc4RPE0FHQX1PeRnvU3cAq9eRYGfJ/0GzMy7Fh4="; + npmDepsHash = source.depsHash; installPhase = '' mkdir -p $out/opt/client @@ -65,12 +66,14 @@ in buildNpmPackage { 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${version}"; + changelog = "https://github.com/advplyr/audiobookshelf/releases/tag/v${source.version}"; license = licenses.gpl3; - maintainers = [ maintainers.jvanbruegge ]; + maintainers = [ maintainers.jvanbruegge maintainers.adamcstephens ]; platforms = platforms.linux; mainProgram = "audiobookshelf"; }; diff --git a/pkgs/by-name/au/audiobookshelf/source.json b/pkgs/by-name/au/audiobookshelf/source.json new file mode 100644 index 000000000000..74a387587170 --- /dev/null +++ b/pkgs/by-name/au/audiobookshelf/source.json @@ -0,0 +1,9 @@ +{ + "owner": "advplyr", + "repo": "audiobookshelf", + "rev": "90f4833c9e0957f08799af15966d1909516b335e", + "hash": "sha256-m+CwUV3Bu9sHvRKCA1vFXYYRx48bxZ8N3BornO1tLQ0=", + "version": "2.7.2", + "depsHash": "sha256-1623oXtkOp43xQvHI3GbJpEQLvgr5WD5FpfNO+d0RR8=", + "clientDepsHash": "sha256-ugf9C/L5aBTO7gCy561kV06Ihb/mg/ZW916NKngIYXI=" +} diff --git a/pkgs/by-name/au/audiobookshelf/update.nu b/pkgs/by-name/au/audiobookshelf/update.nu new file mode 100755 index 000000000000..25166c9cf1d1 --- /dev/null +++ b/pkgs/by-name/au/audiobookshelf/update.nu @@ -0,0 +1,30 @@ +#!/usr/bin/env nix-shell +#!nix-shell -i nu -p nushell common-updater-scripts prefetch-npm-deps + +def main [] { + let sourceFile = $"(pwd)/pkgs/by-name/au/audiobookshelf/source.json" + let tags = list-git-tags --url=https://github.com/advplyr/audiobookshelf | lines | sort --natural | str replace v '' + + let latest_tag = $tags | last + let current_version = open $sourceFile | get version + + if $latest_tag != $current_version { + let source = nix-prefetch-github advplyr audiobookshelf --rev $"v($latest_tag)" | from json | merge { version: $latest_tag, depsHash: "", clientDepsHash: ""} + $source | save --force $sourceFile + + let srcPath = nix-build $env.PWD -A audiobookshelf.src | complete | get stdout | lines | first + + print $srcPath + ls $srcPath + + $source | merge { + depsHash: (prefetch-npm-deps $"($srcPath)/package-lock.json"), + clientDepsHash: (prefetch-npm-deps $"($srcPath)/client/package-lock.json") + } | save --force $sourceFile + + # appease the editorconfig CI check + echo "\n" | save --append $sourceFile + } + + {before: $current_version, after: $latest_tag} +} diff --git a/pkgs/servers/audiobookshelf/wrapper.nix b/pkgs/by-name/au/audiobookshelf/wrapper.nix similarity index 100% rename from pkgs/servers/audiobookshelf/wrapper.nix rename to pkgs/by-name/au/audiobookshelf/wrapper.nix diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 73c9a39e5247..47928905f27e 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -1721,8 +1721,6 @@ with pkgs; audible-cli = callPackage ../tools/misc/audible-cli { }; - audiobookshelf = callPackage ../servers/audiobookshelf { }; - auditwheel = with python3Packages; toPythonApplication auditwheel; amidst = callPackage ../tools/games/minecraft/amidst { };