2020-05-29 06:06:01 +00:00
|
|
|
{ config, pkgs, lib, ... }:
|
|
|
|
|
|
|
|
with lib;
|
|
|
|
|
|
|
|
let
|
|
|
|
cfg = config.services.bazarr;
|
|
|
|
in
|
|
|
|
{
|
|
|
|
options = {
|
|
|
|
services.bazarr = {
|
|
|
|
enable = mkEnableOption "bazarr, a subtitle manager for Sonarr and Radarr";
|
|
|
|
|
|
|
|
openFirewall = mkOption {
|
|
|
|
type = types.bool;
|
|
|
|
default = false;
|
2022-08-12 12:06:08 +00:00
|
|
|
description = lib.mdDoc "Open ports in the firewall for the bazarr web interface.";
|
2020-05-29 06:06:01 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
listenPort = mkOption {
|
|
|
|
type = types.port;
|
|
|
|
default = 6767;
|
2022-08-12 12:06:08 +00:00
|
|
|
description = lib.mdDoc "Port on which the bazarr web interface should listen";
|
2020-05-29 06:06:01 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
user = mkOption {
|
|
|
|
type = types.str;
|
|
|
|
default = "bazarr";
|
2022-08-12 12:06:08 +00:00
|
|
|
description = lib.mdDoc "User account under which bazarr runs.";
|
2020-05-29 06:06:01 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
group = mkOption {
|
|
|
|
type = types.str;
|
|
|
|
default = "bazarr";
|
2022-08-12 12:06:08 +00:00
|
|
|
description = lib.mdDoc "Group under which bazarr runs.";
|
2020-05-29 06:06:01 +00:00
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
config = mkIf cfg.enable {
|
|
|
|
systemd.services.bazarr = {
|
|
|
|
description = "bazarr";
|
|
|
|
after = [ "network.target" ];
|
|
|
|
wantedBy = [ "multi-user.target" ];
|
|
|
|
|
|
|
|
serviceConfig = rec {
|
|
|
|
Type = "simple";
|
|
|
|
User = cfg.user;
|
|
|
|
Group = cfg.group;
|
|
|
|
StateDirectory = "bazarr";
|
|
|
|
SyslogIdentifier = "bazarr";
|
|
|
|
ExecStart = pkgs.writeShellScript "start-bazarr" ''
|
|
|
|
${pkgs.bazarr}/bin/bazarr \
|
|
|
|
--config '/var/lib/${StateDirectory}' \
|
|
|
|
--port ${toString cfg.listenPort} \
|
|
|
|
--no-update True
|
|
|
|
'';
|
|
|
|
Restart = "on-failure";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
networking.firewall = mkIf cfg.openFirewall {
|
|
|
|
allowedTCPPorts = [ cfg.listenPort ];
|
|
|
|
};
|
|
|
|
|
|
|
|
users.users = mkIf (cfg.user == "bazarr") {
|
|
|
|
bazarr = {
|
2021-04-15 00:37:46 +00:00
|
|
|
isSystemUser = true;
|
2020-05-29 06:06:01 +00:00
|
|
|
group = cfg.group;
|
|
|
|
home = "/var/lib/${config.systemd.services.bazarr.serviceConfig.StateDirectory}";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
users.groups = mkIf (cfg.group == "bazarr") {
|
|
|
|
bazarr = {};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|