diff --git a/pkgs/servers/ombi/default.nix b/pkgs/servers/ombi/default.nix new file mode 100644 index 000000000000..5429e73e6970 --- /dev/null +++ b/pkgs/servers/ombi/default.nix @@ -0,0 +1,65 @@ +{ lib, stdenv, fetchurl, makeWrapper, patchelf, openssl, libunwind, zlib, krb5, icu }: + +let + os = if stdenv.isDarwin then "osx" else "linux"; + arch = { + x86_64-linux = "x64"; + aarch64-linux = "arm64"; + x86_64-darwin = "x64"; + }."${stdenv.hostPlatform.system}" or (throw + "Unsupported system: ${stdenv.hostPlatform.system}"); + + hash = { + x64-linux_hash = "sha256-Cuvz9Mhwpg8RIaiSXib+QW00DM66qPRQulrchRL2BSk="; + arm64-linux_hash = "sha256-uyVwa73moHWMZScNNSOU17lALuK3PC/cvTZPJ9qg7JQ="; + x64-osx_hash = "sha256-FGXLsfEuCW94D786LJ/wvA9TakOn5sG2M1rDXPQicYw="; + }."${arch}-${os}_hash"; + + rpath = lib.makeLibraryPath [ + stdenv.cc.cc openssl libunwind zlib krb5 icu + ]; + + dynamicLinker = stdenv.cc.bintools.dynamicLinker; + +in stdenv.mkDerivation rec { + pname = "ombi"; + version = "4.0.1292"; + + sourceRoot = "."; + + src = fetchurl { + url = "https://github.com/Ombi-app/Ombi/releases/download/v${version}/${os}-${arch}.tar.gz"; + sha256 = hash; + }; + + buildInputs = [ makeWrapper patchelf ]; + + installPhase = '' + mkdir -p $out/{bin,share/${pname}-${version}} + cp -r * $out/share/${pname}-${version} + + makeWrapper $out/share/${pname}-${version}/Ombi $out/bin/Ombi \ + --run "cd $out/share/${pname}-${version}" + ''; + + dontPatchELF = true; + postFixup = '' + patchelf --set-interpreter "${dynamicLinker}" \ + --set-rpath "$ORIGIN:${rpath}" $out/share/${pname}-${version}/Ombi + + find $out -type f -name "*.so" -exec \ + patchelf --set-rpath '$ORIGIN:${rpath}' {} ';' + ''; + + passthru = { + updateScript = ./update.sh; + }; + + meta = with lib; { + description = "Self-hosted web application that automatically gives your shared Plex or Emby users the ability to request content by themselves"; + homepage = "https://ombi.io/"; + license = licenses.gpl2Only; + maintainers = with maintainers; [ woky ]; + platforms = [ "x86_64-linux" "aarch64-linux" "x86_64-darwin" ]; + }; +} diff --git a/pkgs/servers/ombi/update.sh b/pkgs/servers/ombi/update.sh new file mode 100755 index 000000000000..fb2549bb7468 --- /dev/null +++ b/pkgs/servers/ombi/update.sh @@ -0,0 +1,42 @@ +#!/usr/bin/env nix-shell +#!nix-shell -i bash -p curl gnused nix-prefetch jq + +set -e + +dirname="$(dirname "$0")" + +updateHash() +{ + version=$1 + arch=$2 + os=$3 + + hashKey="${arch}-${os}_hash" + + url="https://github.com/Ombi-app/Ombi/releases/download/v$version/$os-$arch.tar.gz" + hash=$(nix-prefetch-url --type sha256 $url) + sriHash="$(nix to-sri --type sha256 $hash)" + + sed -i "s|$hashKey = \"[a-zA-Z0-9\/+-=]*\";|$hashKey = \"$sriHash\";|g" "$dirname/default.nix" +} + +updateVersion() +{ + sed -i "s/version = \"[0-9.]*\";/version = \"$1\";/g" "$dirname/default.nix" +} + +currentVersion=$(cd $dirname && nix eval --raw '(with import ../../.. {}; ombi.version)') + +latestTag=$(curl https://api.github.com/repos/Ombi-App/Ombi/tags | jq -r '.[] | .name' | sort --version-sort | tail -1) +latestVersion="$(expr $latestTag : 'v\(.*\)')" + +if [[ "$currentVersion" == "$latestVersion" ]]; then + echo "Ombi is up-to-date: ${currentVersion}" + exit 0 +fi + +updateVersion $latestVersion + +updateHash $latestVersion x64 linux +updateHash $latestVersion arm64 linux +updateHash $latestVersion x64 osx diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index fbd03d2edf3a..3ac20cc8c7e8 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -6927,6 +6927,8 @@ in inherit (darwin.apple_sdk.frameworks) CoreFoundation; }; + ombi = callPackage ../servers/ombi { }; + omping = callPackage ../applications/networking/omping { }; onefetch = callPackage ../tools/misc/onefetch {