Merge pull request #203487 from jocelynthode/init-readarr

readarr: init at 0.1.4.1596
This commit is contained in:
Elis Hirwing 2023-03-13 06:56:35 +01:00 committed by GitHub
commit ce76a6838c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 208 additions and 0 deletions

View file

@ -33,6 +33,7 @@ In addition to numerous new and upgraded packages, this release has the followin
- [Cloudlog](https://www.magicbug.co.uk/cloudlog/), a web-based Amateur Radio logging application. Available as [services.cloudlog](#opt-services.cloudlog.enable).
- [fzf](https://github.com/junegunn/fzf), a command line fuzzyfinder. Available as [programs.fzf](#opt-programs.fzf.fuzzyCompletion).
- [readarr](https://github.com/Readarr/Readarr), Book Manager and Automation (Sonarr for Ebooks). Available as [services.readarr](options.html#opt-services.readarr.enable).
- [gemstash](https://github.com/rubygems/gemstash), a RubyGems.org cache and private gem server. Available as [services.gemstash](#opt-services.gemstash.enable).

View file

@ -665,6 +665,7 @@
./services/misc/prowlarr.nix
./services/misc/pykms.nix
./services/misc/radarr.nix
./services/misc/readarr.nix
./services/misc/redmine.nix
./services/misc/ripple-data-api.nix
./services/misc/rippled.nix

View file

@ -0,0 +1,88 @@
{ config, pkgs, lib, ... }:
with lib;
let
cfg = config.services.readarr;
in
{
options = {
services.readarr = {
enable = mkEnableOption (lib.mdDoc "Readarr");
dataDir = mkOption {
type = types.str;
default = "/var/lib/readarr/";
description = lib.mdDoc "The directory where Readarr stores its data files.";
};
package = mkOption {
type = types.package;
default = pkgs.readarr;
defaultText = literalExpression "pkgs.readarr";
description = lib.mdDoc "The Readarr package to use";
};
openFirewall = mkOption {
type = types.bool;
default = false;
description = lib.mdDoc ''
Open ports in the firewall for Readarr
'';
};
user = mkOption {
type = types.str;
default = "readarr";
description = lib.mdDoc ''
User account under which Readarr runs.
'';
};
group = mkOption {
type = types.str;
default = "readarr";
description = lib.mdDoc ''
Group under which Readarr runs.
'';
};
};
};
config = mkIf cfg.enable {
systemd.tmpfiles.rules = [
"d '${cfg.dataDir}' 0700 ${cfg.user} ${cfg.group} - -"
];
systemd.services.readarr = {
description = "Readarr";
after = [ "network.target" ];
wantedBy = [ "multi-user.target" ];
serviceConfig = {
Type = "simple";
User = cfg.user;
Group = cfg.group;
ExecStart = "${cfg.package}/bin/Readarr -nobrowser -data='${cfg.dataDir}'";
Restart = "on-failure";
};
};
networking.firewall = mkIf cfg.openFirewall {
allowedTCPPorts = [ 8787 ];
};
users.users = mkIf (cfg.user == "readarr") {
readarr = {
description = "Readarr service";
home = cfg.dataDir;
group = cfg.group;
isSystemUser = true;
};
};
users.groups = mkIf (cfg.group == "readarr") {
readarr = { };
};
};
}

View file

@ -585,6 +585,7 @@ in {
radarr = handleTest ./radarr.nix {};
radicale = handleTest ./radicale.nix {};
rasdaemon = handleTest ./rasdaemon.nix {};
readarr = handleTest ./readarr.nix {};
redis = handleTest ./redis.nix {};
redmine = handleTest ./redmine.nix {};
restartByActivationScript = handleTest ./restart-by-activation-script.nix {};

18
nixos/tests/readarr.nix Normal file
View file

@ -0,0 +1,18 @@
import ./make-test-python.nix ({ lib, ... }:
with lib;
{
name = "readarr";
meta.maintainers = with maintainers; [ jocelynthode ];
nodes.machine =
{ pkgs, ... }:
{ services.readarr.enable = true; };
testScript = ''
machine.wait_for_unit("readarr.service")
machine.wait_for_open_port(8787)
machine.succeed("curl --fail http://localhost:8787/")
'';
})

View file

@ -0,0 +1,53 @@
{ lib, stdenv, fetchurl, libmediainfo, sqlite, curl, makeWrapper, icu, dotnet-runtime, openssl, 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-ABk2wxNse8dcFWEMpaXnsALz171/1JQaAFzmpz36we0=";
arm64-linux_hash = "sha256-c1eVCPE8RH9u99hYJZBiNBpanBv3WeSTVaD+Gq1yxUk=";
x64-osx_hash = "sha256-9UEi8YbpZ1baZ9lnG7SJcYnvJRgP7BsqcIt9Z3UdDv8=";
}."${arch}-${os}_hash";
in stdenv.mkDerivation rec {
pname = "readarr";
version = "0.1.4.1596";
src = fetchurl {
url = "https://github.com/Readarr/Readarr/releases/download/v${version}/Readarr.develop.${version}.${os}-core-${arch}.tar.gz";
sha256 = hash;
};
nativeBuildInputs = [ makeWrapper ];
installPhase = ''
runHook preInstall
mkdir -p $out/{bin,share/${pname}-${version}}
cp -r * $out/share/${pname}-${version}/.
makeWrapper "${dotnet-runtime}/bin/dotnet" $out/bin/Readarr \
--add-flags "$out/share/${pname}-${version}/Readarr.dll" \
--prefix LD_LIBRARY_PATH : ${lib.makeLibraryPath [ curl sqlite libmediainfo icu openssl ]}
runHook postInstall
'';
passthru = {
updateScript = ./update.sh;
tests.smoke-test = nixosTests.readarr;
};
meta = with lib; {
description = "A Usenet/BitTorrent ebook downloader";
homepage = "https://readarr.com";
license = licenses.gpl3;
maintainers = [ maintainers.jocelynthode ];
sourceProvenance = with lib.sourceTypes; [ binaryBytecode ];
platforms = [ "x86_64-linux" "aarch64-linux" "x86_64-darwin" ];
};
}

44
pkgs/servers/readarr/update.sh Executable file
View file

@ -0,0 +1,44 @@
#!/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/Readarr/Readarr/releases/download/v$version/Readarr.develop.$version.$os-core-$arch.tar.gz"
hash=$(nix-prefetch-url --type sha256 $url)
sriHash="$(nix hash 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 -f ../../.. readarr.version)
# We cannot use the latest releases as in the past Readarr released old version with v2.0 and then went back to 0.1
latestTag=$(curl https://api.github.com/repos/Readarr/Readarr/releases | jq -r ".[0].tag_name")
latestVersion="$(expr $latestTag : 'v\(.*\)')"
if [[ "$currentVersion" == "$latestVersion" ]]; then
echo "Readarr is up-to-date: ${currentVersion}"
exit 0
fi
updateVersion $latestVersion
updateHash $latestVersion x64 linux
updateHash $latestVersion arm64 linux
updateHash $latestVersion x64 osx

View file

@ -11546,6 +11546,8 @@ with pkgs;
react-native-debugger = callPackage ../development/tools/react-native-debugger { };
readarr = callPackage ../servers/readarr { };
read-edid = callPackage ../os-specific/linux/read-edid { };
readstat = callPackage ../applications/science/math/readstat { };