Merge pull request #203487 from jocelynthode/init-readarr

readarr: init at 0.1.4.1596

authored by

Elis Hirwing and committed by
GitHub
ce76a683 e54425c4

+208
+1
nixos/doc/manual/release-notes/rl-2305.section.md
··· 33 33 - [Cloudlog](https://www.magicbug.co.uk/cloudlog/), a web-based Amateur Radio logging application. Available as [services.cloudlog](#opt-services.cloudlog.enable). 34 34 35 35 - [fzf](https://github.com/junegunn/fzf), a command line fuzzyfinder. Available as [programs.fzf](#opt-programs.fzf.fuzzyCompletion). 36 + - [readarr](https://github.com/Readarr/Readarr), Book Manager and Automation (Sonarr for Ebooks). Available as [services.readarr](options.html#opt-services.readarr.enable). 36 37 37 38 - [gemstash](https://github.com/rubygems/gemstash), a RubyGems.org cache and private gem server. Available as [services.gemstash](#opt-services.gemstash.enable). 38 39
+1
nixos/modules/module-list.nix
··· 665 665 ./services/misc/prowlarr.nix 666 666 ./services/misc/pykms.nix 667 667 ./services/misc/radarr.nix 668 + ./services/misc/readarr.nix 668 669 ./services/misc/redmine.nix 669 670 ./services/misc/ripple-data-api.nix 670 671 ./services/misc/rippled.nix
+88
nixos/modules/services/misc/readarr.nix
··· 1 + { config, pkgs, lib, ... }: 2 + 3 + with lib; 4 + 5 + let 6 + cfg = config.services.readarr; 7 + in 8 + { 9 + options = { 10 + services.readarr = { 11 + enable = mkEnableOption (lib.mdDoc "Readarr"); 12 + 13 + dataDir = mkOption { 14 + type = types.str; 15 + default = "/var/lib/readarr/"; 16 + description = lib.mdDoc "The directory where Readarr stores its data files."; 17 + }; 18 + 19 + package = mkOption { 20 + type = types.package; 21 + default = pkgs.readarr; 22 + defaultText = literalExpression "pkgs.readarr"; 23 + description = lib.mdDoc "The Readarr package to use"; 24 + }; 25 + 26 + openFirewall = mkOption { 27 + type = types.bool; 28 + default = false; 29 + description = lib.mdDoc '' 30 + Open ports in the firewall for Readarr 31 + ''; 32 + }; 33 + 34 + user = mkOption { 35 + type = types.str; 36 + default = "readarr"; 37 + description = lib.mdDoc '' 38 + User account under which Readarr runs. 39 + ''; 40 + }; 41 + 42 + group = mkOption { 43 + type = types.str; 44 + default = "readarr"; 45 + description = lib.mdDoc '' 46 + Group under which Readarr runs. 47 + ''; 48 + }; 49 + }; 50 + }; 51 + 52 + config = mkIf cfg.enable { 53 + systemd.tmpfiles.rules = [ 54 + "d '${cfg.dataDir}' 0700 ${cfg.user} ${cfg.group} - -" 55 + ]; 56 + 57 + systemd.services.readarr = { 58 + description = "Readarr"; 59 + after = [ "network.target" ]; 60 + wantedBy = [ "multi-user.target" ]; 61 + 62 + serviceConfig = { 63 + Type = "simple"; 64 + User = cfg.user; 65 + Group = cfg.group; 66 + ExecStart = "${cfg.package}/bin/Readarr -nobrowser -data='${cfg.dataDir}'"; 67 + Restart = "on-failure"; 68 + }; 69 + }; 70 + 71 + networking.firewall = mkIf cfg.openFirewall { 72 + allowedTCPPorts = [ 8787 ]; 73 + }; 74 + 75 + users.users = mkIf (cfg.user == "readarr") { 76 + readarr = { 77 + description = "Readarr service"; 78 + home = cfg.dataDir; 79 + group = cfg.group; 80 + isSystemUser = true; 81 + }; 82 + }; 83 + 84 + users.groups = mkIf (cfg.group == "readarr") { 85 + readarr = { }; 86 + }; 87 + }; 88 + }
+1
nixos/tests/all-tests.nix
··· 585 585 radarr = handleTest ./radarr.nix {}; 586 586 radicale = handleTest ./radicale.nix {}; 587 587 rasdaemon = handleTest ./rasdaemon.nix {}; 588 + readarr = handleTest ./readarr.nix {}; 588 589 redis = handleTest ./redis.nix {}; 589 590 redmine = handleTest ./redmine.nix {}; 590 591 restartByActivationScript = handleTest ./restart-by-activation-script.nix {};
+18
nixos/tests/readarr.nix
··· 1 + import ./make-test-python.nix ({ lib, ... }: 2 + 3 + with lib; 4 + 5 + { 6 + name = "readarr"; 7 + meta.maintainers = with maintainers; [ jocelynthode ]; 8 + 9 + nodes.machine = 10 + { pkgs, ... }: 11 + { services.readarr.enable = true; }; 12 + 13 + testScript = '' 14 + machine.wait_for_unit("readarr.service") 15 + machine.wait_for_open_port(8787) 16 + machine.succeed("curl --fail http://localhost:8787/") 17 + ''; 18 + })
+53
pkgs/servers/readarr/default.nix
··· 1 + { lib, stdenv, fetchurl, libmediainfo, sqlite, curl, makeWrapper, icu, dotnet-runtime, openssl, nixosTests }: 2 + 3 + let 4 + os = if stdenv.isDarwin then "osx" else "linux"; 5 + arch = { 6 + x86_64-linux = "x64"; 7 + aarch64-linux = "arm64"; 8 + x86_64-darwin = "x64"; 9 + }."${stdenv.hostPlatform.system}" or (throw "Unsupported system: ${stdenv.hostPlatform.system}"); 10 + hash = { 11 + x64-linux_hash = "sha256-ABk2wxNse8dcFWEMpaXnsALz171/1JQaAFzmpz36we0="; 12 + arm64-linux_hash = "sha256-c1eVCPE8RH9u99hYJZBiNBpanBv3WeSTVaD+Gq1yxUk="; 13 + x64-osx_hash = "sha256-9UEi8YbpZ1baZ9lnG7SJcYnvJRgP7BsqcIt9Z3UdDv8="; 14 + }."${arch}-${os}_hash"; 15 + in stdenv.mkDerivation rec { 16 + pname = "readarr"; 17 + version = "0.1.4.1596"; 18 + 19 + src = fetchurl { 20 + url = "https://github.com/Readarr/Readarr/releases/download/v${version}/Readarr.develop.${version}.${os}-core-${arch}.tar.gz"; 21 + sha256 = hash; 22 + }; 23 + 24 + nativeBuildInputs = [ makeWrapper ]; 25 + 26 + installPhase = '' 27 + runHook preInstall 28 + 29 + mkdir -p $out/{bin,share/${pname}-${version}} 30 + cp -r * $out/share/${pname}-${version}/. 31 + makeWrapper "${dotnet-runtime}/bin/dotnet" $out/bin/Readarr \ 32 + --add-flags "$out/share/${pname}-${version}/Readarr.dll" \ 33 + --prefix LD_LIBRARY_PATH : ${lib.makeLibraryPath [ curl sqlite libmediainfo icu openssl ]} 34 + 35 + runHook postInstall 36 + ''; 37 + 38 + 39 + passthru = { 40 + updateScript = ./update.sh; 41 + tests.smoke-test = nixosTests.readarr; 42 + }; 43 + 44 + meta = with lib; { 45 + description = "A Usenet/BitTorrent ebook downloader"; 46 + homepage = "https://readarr.com"; 47 + license = licenses.gpl3; 48 + maintainers = [ maintainers.jocelynthode ]; 49 + sourceProvenance = with lib.sourceTypes; [ binaryBytecode ]; 50 + platforms = [ "x86_64-linux" "aarch64-linux" "x86_64-darwin" ]; 51 + }; 52 + } 53 +
+44
pkgs/servers/readarr/update.sh
··· 1 + #!/usr/bin/env nix-shell 2 + #!nix-shell -i bash -p curl gnused nix-prefetch jq 3 + 4 + set -e 5 + 6 + dirname="$(dirname "$0")" 7 + 8 + updateHash() 9 + { 10 + version=$1 11 + arch=$2 12 + os=$3 13 + 14 + hashKey="${arch}-${os}_hash" 15 + 16 + url="https://github.com/Readarr/Readarr/releases/download/v$version/Readarr.develop.$version.$os-core-$arch.tar.gz" 17 + hash=$(nix-prefetch-url --type sha256 $url) 18 + sriHash="$(nix hash to-sri --type sha256 $hash)" 19 + 20 + sed -i "s|$hashKey = \"[a-zA-Z0-9\/+-=]*\";|$hashKey = \"$sriHash\";|g" "$dirname/default.nix" 21 + } 22 + 23 + updateVersion() 24 + { 25 + sed -i "s/version = \"[0-9.]*\";/version = \"$1\";/g" "$dirname/default.nix" 26 + } 27 + 28 + currentVersion=$(cd $dirname && nix eval --raw -f ../../.. readarr.version) 29 + 30 + # We cannot use the latest releases as in the past Readarr released old version with v2.0 and then went back to 0.1 31 + latestTag=$(curl https://api.github.com/repos/Readarr/Readarr/releases | jq -r ".[0].tag_name") 32 + latestVersion="$(expr $latestTag : 'v\(.*\)')" 33 + 34 + if [[ "$currentVersion" == "$latestVersion" ]]; then 35 + echo "Readarr is up-to-date: ${currentVersion}" 36 + exit 0 37 + fi 38 + 39 + updateVersion $latestVersion 40 + 41 + updateHash $latestVersion x64 linux 42 + updateHash $latestVersion arm64 linux 43 + updateHash $latestVersion x64 osx 44 +
+2
pkgs/top-level/all-packages.nix
··· 11546 11546 11547 11547 react-native-debugger = callPackage ../development/tools/react-native-debugger { }; 11548 11548 11549 + readarr = callPackage ../servers/readarr { }; 11550 + 11549 11551 read-edid = callPackage ../os-specific/linux/read-edid { }; 11550 11552 11551 11553 readstat = callPackage ../applications/science/math/readstat { };