nixpkgs/nixos/modules/services/misc/bazarr.nix

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

94 lines
2.2 KiB
Nix
Raw Permalink Normal View History

2020-05-10 12:54:09 +02:00
{
config,
pkgs,
lib,
...
}:
let
cfg = config.services.bazarr;
in
{
options = {
services.bazarr = {
enable = lib.mkEnableOption "bazarr, a subtitle manager for Sonarr and Radarr";
2020-05-10 12:54:09 +02:00
package = lib.mkPackageOption pkgs "bazarr" { };
2025-05-19 16:34:25 -04:00
dataDir = lib.mkOption {
type = lib.types.str;
default = "/var/lib/bazarr";
description = "The directory where Bazarr stores its data files.";
};
openFirewall = lib.mkOption {
type = lib.types.bool;
2020-05-10 12:54:09 +02:00
default = false;
description = "Open ports in the firewall for the bazarr web interface.";
};
listenPort = lib.mkOption {
type = lib.types.port;
2020-05-10 12:54:09 +02:00
default = 6767;
description = "Port on which the bazarr web interface should listen";
};
user = lib.mkOption {
type = lib.types.str;
2020-05-10 12:54:09 +02:00
default = "bazarr";
description = "User account under which bazarr runs.";
};
group = lib.mkOption {
type = lib.types.str;
2020-05-10 12:54:09 +02:00
default = "bazarr";
description = "Group under which bazarr runs.";
};
};
};
config = lib.mkIf cfg.enable {
2025-05-19 16:34:25 -04:00
systemd.tmpfiles.settings."10-bazarr".${cfg.dataDir}.d = {
inherit (cfg) user group;
mode = "0700";
};
2020-05-10 12:54:09 +02:00
systemd.services.bazarr = {
2024-10-24 00:36:09 +02:00
description = "Bazarr";
2020-05-10 12:54:09 +02:00
after = [ "network.target" ];
wantedBy = [ "multi-user.target" ];
2025-05-19 16:34:25 -04:00
serviceConfig = {
2020-05-10 12:54:09 +02:00
Type = "simple";
User = cfg.user;
Group = cfg.group;
SyslogIdentifier = "bazarr";
ExecStart = pkgs.writeShellScript "start-bazarr" ''
${cfg.package}/bin/bazarr \
2025-05-19 16:34:25 -04:00
--config '${cfg.dataDir}' \
2020-05-10 12:54:09 +02:00
--port ${toString cfg.listenPort} \
--no-update True
'';
Restart = "on-failure";
KillSignal = "SIGINT";
SuccessExitStatus = "0 156";
2020-05-10 12:54:09 +02:00
};
};
networking.firewall = lib.mkIf cfg.openFirewall {
2020-05-10 12:54:09 +02:00
allowedTCPPorts = [ cfg.listenPort ];
};
users.users = lib.mkIf (cfg.user == "bazarr") {
2020-05-10 12:54:09 +02:00
bazarr = {
isSystemUser = true;
2020-05-10 12:54:09 +02:00
group = cfg.group;
2025-05-19 16:34:25 -04:00
home = cfg.dataDir;
2020-05-10 12:54:09 +02:00
};
};
users.groups = lib.mkIf (cfg.group == "bazarr") {
2020-05-10 12:54:09 +02:00
bazarr = { };
};
};
}