1 { config, pkgs, lib, ... }:
6 cfg = config.services.bazarr;
11 enable = mkEnableOption (lib.mdDoc "bazarr, a subtitle manager for Sonarr and Radarr");
13 openFirewall = mkOption {
16 description = lib.mdDoc "Open ports in the firewall for the bazarr web interface.";
19 listenPort = mkOption {
22 description = lib.mdDoc "Port on which the bazarr web interface should listen";
28 description = lib.mdDoc "User account under which bazarr runs.";
34 description = lib.mdDoc "Group under which bazarr runs.";
39 config = mkIf cfg.enable {
40 systemd.services.bazarr = {
41 description = "bazarr";
42 after = [ "network.target" ];
43 wantedBy = [ "multi-user.target" ];
49 StateDirectory = "bazarr";
50 SyslogIdentifier = "bazarr";
51 ExecStart = pkgs.writeShellScript "start-bazarr" ''
52 ${pkgs.bazarr}/bin/bazarr \
53 --config '/var/lib/${StateDirectory}' \
54 --port ${toString cfg.listenPort} \
57 Restart = "on-failure";
61 networking.firewall = mkIf cfg.openFirewall {
62 allowedTCPPorts = [ cfg.listenPort ];
65 users.users = mkIf (cfg.user == "bazarr") {
69 home = "/var/lib/${config.systemd.services.bazarr.serviceConfig.StateDirectory}";
73 users.groups = mkIf (cfg.group == "bazarr") {