diff --git a/maintainers/maintainer-list.nix b/maintainers/maintainer-list.nix index b890c8aec0e..c1029e4ef1c 100644 --- a/maintainers/maintainer-list.nix +++ b/maintainers/maintainer-list.nix @@ -10392,6 +10392,12 @@ githubId = 1322287; name = "William O'Hanley"; }; + woky = { + email = "pampu.andrei@pm.me"; + github = "andreisergiu98"; + githubId = 11740700; + name = "Andrei Pampu"; + }; wolfangaukang = { email = "liquid.query960@4wrd.cc"; github = "wolfangaukang"; diff --git a/nixos/modules/module-list.nix b/nixos/modules/module-list.nix index fa8d78c7d88..eaf046b160f 100644 --- a/nixos/modules/module-list.nix +++ b/nixos/modules/module-list.nix @@ -515,6 +515,7 @@ ./services/misc/nzbget.nix ./services/misc/nzbhydra2.nix ./services/misc/octoprint.nix + ./services/misc/ombi.nix ./services/misc/osrm.nix ./services/misc/packagekit.nix ./services/misc/paperless.nix diff --git a/nixos/modules/services/misc/ombi.nix b/nixos/modules/services/misc/ombi.nix new file mode 100644 index 00000000000..83f433e0be4 --- /dev/null +++ b/nixos/modules/services/misc/ombi.nix @@ -0,0 +1,80 @@ +{ config, pkgs, lib, ... }: + +with lib; + +let cfg = config.services.ombi; + +in { + options = { + services.ombi = { + enable = mkEnableOption '' + Ombi. + Optionally see + on how to set up a reverse proxy + ''; + + dataDir = mkOption { + type = types.str; + default = "/var/lib/ombi"; + description = "The directory where Ombi stores its data files."; + }; + + port = mkOption { + type = types.port; + default = 5000; + description = "The port for the Ombi web interface."; + }; + + openFirewall = mkOption { + type = types.bool; + default = false; + description = "Open ports in the firewall for the Ombi web interface."; + }; + + user = mkOption { + type = types.str; + default = "ombi"; + description = "User account under which Ombi runs."; + }; + + group = mkOption { + type = types.str; + default = "ombi"; + description = "Group under which Ombi runs."; + }; + }; + }; + + config = mkIf cfg.enable { + systemd.tmpfiles.rules = [ + "d '${cfg.dataDir}' 0700 ${cfg.user} ${cfg.group} - -" + ]; + + systemd.services.ombi = { + description = "Ombi"; + after = [ "network.target" ]; + wantedBy = [ "multi-user.target" ]; + + serviceConfig = { + Type = "simple"; + User = cfg.user; + Group = cfg.group; + ExecStart = "${pkgs.ombi}/bin/Ombi --storage '${cfg.dataDir}' --host 'http://*:${toString cfg.port}'"; + Restart = "on-failure"; + }; + }; + + networking.firewall = mkIf cfg.openFirewall { + allowedTCPPorts = [ cfg.port ]; + }; + + users.users = mkIf (cfg.user == "ombi") { + ombi = { + group = cfg.group; + home = cfg.dataDir; + }; + }; + + users.groups = mkIf (cfg.group == "ombi") { ombi = { }; }; + }; +} diff --git a/nixos/tests/all-tests.nix b/nixos/tests/all-tests.nix index 4c3435451ad..62188ddf9e8 100644 --- a/nixos/tests/all-tests.nix +++ b/nixos/tests/all-tests.nix @@ -290,6 +290,7 @@ in nzbget = handleTest ./nzbget.nix {}; nzbhydra2 = handleTest ./nzbhydra2.nix {}; oh-my-zsh = handleTest ./oh-my-zsh.nix {}; + ombi = handleTest ./ombi.nix {}; openarena = handleTest ./openarena.nix {}; openldap = handleTest ./openldap.nix {}; opensmtpd = handleTest ./opensmtpd.nix {}; diff --git a/nixos/tests/ombi.nix b/nixos/tests/ombi.nix new file mode 100644 index 00000000000..bfca86af817 --- /dev/null +++ b/nixos/tests/ombi.nix @@ -0,0 +1,18 @@ +import ./make-test-python.nix ({ lib, ... }: + +with lib; + +{ + name = "ombi"; + meta.maintainers = with maintainers; [ woky ]; + + nodes.machine = + { pkgs, ... }: + { services.ombi.enable = true; }; + + testScript = '' + machine.wait_for_unit("ombi.service") + machine.wait_for_open_port("5000") + machine.succeed("curl --fail http://localhost:5000/") + ''; +}) diff --git a/pkgs/servers/ombi/default.nix b/pkgs/servers/ombi/default.nix new file mode 100644 index 00000000000..bbad311edda --- /dev/null +++ b/pkgs/servers/ombi/default.nix @@ -0,0 +1,66 @@ +{ lib, stdenv, fetchurl, makeWrapper, patchelf, openssl, libunwind, zlib, krb5, 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 = "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; + 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/pkgs/servers/ombi/update.sh b/pkgs/servers/ombi/update.sh new file mode 100755 index 00000000000..fb2549bb746 --- /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 c41779f4645..beafbb6d475 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -6963,6 +6963,8 @@ in inherit (darwin.apple_sdk.frameworks) CoreFoundation; }; + ombi = callPackage ../servers/ombi { }; + omping = callPackage ../applications/networking/omping { }; onefetch = callPackage ../tools/misc/onefetch {