jellyseerr: fix update script

This commit is contained in:
Camille M. (genesis) 2024-06-18 23:57:03 +02:00
parent c339c066b8
commit c01bd02dd4
3 changed files with 35 additions and 58 deletions

View File

@ -1,36 +1,32 @@
{ lib
, fetchFromGitHub
, makeWrapper
, mkYarnPackage
, nodejs
, fetchYarnDeps
, python3
{
lib,
mkYarnPackage,
fetchFromGitHub,
fetchYarnDeps,
makeWrapper,
nodejs,
python3,
sqlite,
}:
let
pin = lib.importJSON ./pin.json;
in
mkYarnPackage rec {
pname = "jellyseerr";
inherit (pin) version;
version = "1.8.1";
src = fetchFromGitHub {
owner = "Fallenbagel";
repo = "jellyseerr";
rev = "v${version}";
hash = pin.srcHash;
hash = "sha256-B8Hnpi4XwK0WrHRgj7OSVUh49oRH9SVEHdzGbnDa8p8=";
};
packageJSON = ./package.json;
offlineCache = fetchYarnDeps {
yarnLock = "${src}/yarn.lock";
sha256 = pin.yarnSha256;
hash = "sha256-ME19kHlVw0Q5oCytYQCUj4Ek0+712NkqB6eozOtF6/k=";
};
doDist = false;
nativeBuildInputs = [
nodejs
makeWrapper
@ -38,16 +34,23 @@ mkYarnPackage rec {
# Fixes "SQLite package has not been found installed" at launch
pkgConfig.sqlite3 = {
nativeBuildInputs = [ nodejs.pkgs.node-pre-gyp python3 ];
nativeBuildInputs = [
nodejs.pkgs.node-pre-gyp
python3
sqlite
];
postInstall = ''
export CPPFLAGS="-I${nodejs}/include/node"
node-pre-gyp install --prefer-offline --build-from-source --nodedir=${nodejs}/include/node
node-pre-gyp install --prefer-offline --build-from-source --nodedir=${nodejs}/include/node --sqlite=${sqlite.dev}
rm -r build-tmp-napi-v6
'';
};
pkgConfig.bcrypt = {
nativeBuildInputs = [ nodejs.pkgs.node-pre-gyp python3 ];
nativeBuildInputs = [
nodejs.pkgs.node-pre-gyp
python3
];
postInstall = ''
export CPPFLAGS="-I${nodejs}/include/node"
node-pre-gyp install --prefer-offline --build-from-source --nodedir=${nodejs}/include/node
@ -72,6 +75,8 @@ mkYarnPackage rec {
--set NODE_ENV production
'';
doDist = false;
passthru.updateScript = ./update.sh;
meta = with lib; {

View File

@ -1,5 +0,0 @@
{
"version": "1.8.1",
"srcHash": "sha256-B8Hnpi4XwK0WrHRgj7OSVUh49oRH9SVEHdzGbnDa8p8=",
"yarnSha256": "ME19kHlVw0Q5oCytYQCUj4Ek0+712NkqB6eozOtF6/k="
}

View File

@ -1,39 +1,16 @@
#!/usr/bin/env nix-shell
#!nix-shell -i bash -p nix curl jq prefetch-yarn-deps nix-prefetch-github
#!nix-shell -i bash -p curl jq common-updater-scripts nix prefetch-yarn-deps
set -euo pipefail
set -eu -o pipefail
if [[ "$#" -gt 1 || "$1" == -* ]]; then
echo "Regenerates packaging data for jellyseerr."
echo "Usage: $0 [git release tag]"
exit 1
fi
version=${1:-$(curl -s https://api.github.com/repos/Fallenbagel/jellyseerr/releases/latest | jq --raw-output '.tag_name[1:]')}
update-source-version jellyseerr $version
tag="$1"
nix_file=$(nix-instantiate --eval --strict -A "jellyseerr.meta.position" | sed -re 's/^"(.*):[0-9]+"$/\1/')
nix_dir=$(dirname $nix_file)
cp $(nix-instantiate --eval --expr 'with import ./default.nix { }; "${jellyseerr.src}/package.json"' | sed 's/"//g') $nix_dir
if [ -z "$tag" ]; then
tag="$(
curl "https://api.github.com/repos/Fallenbagel/jellyseerr/releases?per_page=1" |
jq -r '.[0].tag_name'
)"
fi
src="https://raw.githubusercontent.com/Fallenbagel/jellyseerr/$tag"
src_hash=$(nix-prefetch-github Fallenbagel jellyseerr --rev ${tag} | jq -r .sha256)
tmpdir=$(mktemp -d)
trap 'rm -rf "$tmpdir"' EXIT
pushd $tmpdir
curl -O "$src/yarn.lock"
yarn_sha256=$(prefetch-yarn-deps yarn.lock)
popd
curl -O "$src/package.json"
cat > pin.json << EOF
{
"version": "$(echo $tag | grep -P '(\d|\.)+' -o)",
"srcHash": "sha256-$src_hash",
"yarnSha256": "$yarn_sha256"
}
EOF
old_yarn_hash=$(nix-instantiate --eval --strict -A "jellyseerr.offlineCache.outputHash" | tr -d '"' | sed -re 's|[+]|\\&|g')
lock_file=$(nix-instantiate --eval --expr 'with import ./default.nix { }; "${jellyseerr.src}/yarn.lock"' | sed 's/"//g')
new_yarn_hash=$(nix hash to-sri --type sha256 $(prefetch-yarn-deps $lock_file))
sed -i "$nix_file" -re "s|\"$old_yarn_hash\"|\"$new_yarn_hash\"|"