about summary refs log tree commit diff
path: root/pkgs/servers/ombi
diff options
context:
space:
mode:
authorAndrei Pampu <pampu.s.andrei@gmail.com>2021-03-29 17:46:01 +0300
committerAndrei Pampu <pampu.s.andrei@gmail.com>2021-04-01 10:34:40 +0300
commit0cda2e2cb27bc9e9c66e28b273687db88149bb7a (patch)
tree0cfe7c4be26efbcf9c8dcbb901e5807d0cf5c8ec /pkgs/servers/ombi
parentcfd56a4c0432a53de0e68883514d8b1826e43102 (diff)
ombi: init at 4.0.1292
Diffstat (limited to 'pkgs/servers/ombi')
-rw-r--r--pkgs/servers/ombi/default.nix65
-rwxr-xr-xpkgs/servers/ombi/update.sh42
2 files changed, 107 insertions, 0 deletions
diff --git a/pkgs/servers/ombi/default.nix b/pkgs/servers/ombi/default.nix
new file mode 100644
index 0000000000000..5429e73e6970b
--- /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 0000000000000..fb2549bb74686
--- /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