From bb5f5a242d2f698a83c045d7cc24068b72dccc25 Mon Sep 17 00:00:00 2001 From: mc-fucker Date: Mon, 8 Aug 2022 20:35:38 +0200 Subject: [PATCH] added custom package dir --- modules/ombi.nix | 2 +- packages/ombi/default.nix | 55 +++++++++++++++++++++++++++++++++++++++ packages/ombi/update.sh | 39 +++++++++++++++++++++++++++ 3 files changed, 95 insertions(+), 1 deletion(-) create mode 100644 packages/ombi/default.nix create mode 100755 packages/ombi/update.sh diff --git a/modules/ombi.nix b/modules/ombi.nix index cb47a69..dfb7c12 100644 --- a/modules/ombi.nix +++ b/modules/ombi.nix @@ -5,7 +5,7 @@ in { nixpkgs.config.packageOverrides = pkgs: { - ombi = pkgs.callPackage /root/ombi {}; + ombi = pkgs.callPackage ../packages/ombi {}; }; services.ombi.enable = true; diff --git a/packages/ombi/default.nix b/packages/ombi/default.nix new file mode 100644 index 0000000..14ae8ac --- /dev/null +++ b/packages/ombi/default.nix @@ -0,0 +1,55 @@ +{ lib, stdenv, fetchurl, makeWrapper, autoPatchelfHook, fixDarwinDylibNames, zlib, krb5, openssl, icu, nixosTests }: + +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 = "07zgmylrms4b0wpsxrcw5lkbk3sd4g97naks3wxsg4zb8r7lspzf"; + arm64-linux_hash = "0xp27x0dy7c89b33vsvdyqdqn329xrgdkfh1jb6616xqajj459ah"; + x64-osx_hash = "1di0npjxr0zpixk0yzms0v7han2xsinqm9lma253011kq2gbhjy5"; + }."${arch}-${os}_hash"; + +in stdenv.mkDerivation rec { + pname = "ombi"; + version = "4.22.5"; + + sourceRoot = "."; + + src = fetchurl { + url = "https://github.com/Ombi-app/Ombi/releases/download/v${version}/${os}-${arch}.tar.gz"; + sha256 = hash; + }; + + nativeBuildInputs = [ makeWrapper autoPatchelfHook ] + ++ lib.optional stdenv.hostPlatform.isDarwin fixDarwinDylibNames; + + propagatedBuildInputs = [ stdenv.cc.cc zlib krb5 ]; + + installPhase = '' + mkdir -p $out/{bin,share/${pname}-${version}} + cp -r * $out/share/${pname}-${version} + + makeWrapper $out/share/${pname}-${version}/Ombi $out/bin/Ombi \ + --prefix LD_LIBRARY_PATH : ${lib.makeLibraryPath [ openssl icu ]} \ + --run "cd $out/share/${pname}-${version}" + ''; + + passthru = { + updateScript = ./update.sh; + tests.smoke-test = nixosTests.ombi; + }; + + 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/packages/ombi/update.sh b/packages/ombi/update.sh new file mode 100755 index 0000000..50028d8 --- /dev/null +++ b/packages/ombi/update.sh @@ -0,0 +1,39 @@ +#!/usr/bin/env nix-shell +#!nix-shell -i bash -p curl gnused nix-prefetch jq + +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 $url)" + + sed -i "s|$hashKey = \"[a-zA-Z0-9\/+-=]*\";|$hashKey = \"$hash\";|g" "$dirname/default.nix" +} + +updateVersion() +{ + sed -i "s/version = \"[0-9.]*\";/version = \"$1\";/g" "$dirname/default.nix" +} + +oldversion="$(grep -Po '(?<=version = ").*(?=";)' default.nix)" +echo "$oldversion" +newversion="$(curl -s -H "Accept: application/vnd.github.v3+json" https://api.github.com/repos/Ombi-App/Ombi/releases | jq -r ".[0].tag_name" | sed "s/^v//")" +echo "$newversion" +version="$newversion" + +if [[ "$oldversion" == "$newversion" ]]; then + echo "Ombi is up 2 date: Version $oldversion" + exit 0 +fi + +updateVersion $newversion + +updateHash $newversion x64 linux +updateHash $newversion arm64 linux +updateHash $newversion x64 osx