1 { config, pkgs, lib, ... }:
3 cfg = config.services.bazarr;
8 enable = lib.mkEnableOption "bazarr, a subtitle manager for Sonarr and Radarr";
10 package = lib.mkPackageOption pkgs "bazarr" { };
12 openFirewall = lib.mkOption {
13 type = lib.types.bool;
15 description = "Open ports in the firewall for the bazarr web interface.";
18 listenPort = lib.mkOption {
19 type = lib.types.port;
21 description = "Port on which the bazarr web interface should listen";
27 description = "User account under which bazarr runs.";
30 group = lib.mkOption {
33 description = "Group under which bazarr runs.";
38 config = lib.mkIf cfg.enable {
39 systemd.services.bazarr = {
40 description = "Bazarr";
41 after = [ "network.target" ];
42 wantedBy = [ "multi-user.target" ];
48 StateDirectory = "bazarr";
49 SyslogIdentifier = "bazarr";
50 ExecStart = pkgs.writeShellScript "start-bazarr" ''
51 ${cfg.package}/bin/bazarr \
52 --config '/var/lib/${StateDirectory}' \
53 --port ${toString cfg.listenPort} \
56 Restart = "on-failure";
57 KillSignal = "SIGINT";
58 SuccessExitStatus = "0 156";
62 networking.firewall = lib.mkIf cfg.openFirewall {
63 allowedTCPPorts = [ cfg.listenPort ];
66 users.users = lib.mkIf (cfg.user == "bazarr") {
70 home = "/var/lib/${config.systemd.services.bazarr.serviceConfig.StateDirectory}";
74 users.groups = lib.mkIf (cfg.group == "bazarr") {