Unverified Commit ce76a683 authored by Elis Hirwing's avatar Elis Hirwing Committed by GitHub
Browse files

Merge pull request #203487 from jocelynthode/init-readarr

readarr: init at 0.1.4.1596
parents e54425c4 e7f54823
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -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).

+1 −0
Original line number Diff line number Diff line
@@ -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
+88 −0
Original line number Diff line number Diff line
{ 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 = { };
    };
  };
}
+1 −0
Original line number Diff line number Diff line
@@ -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 −0
Original line number Diff line number Diff line
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/")
  '';
})
Loading