1 { config, pkgs, lib, ... }:
3 cfg = config.services.bazarr;
8 enable = lib.mkEnableOption "bazarr, a subtitle manager for Sonarr and Radarr";
10 openFirewall = lib.mkOption {
11 type = lib.types.bool;
13 description = "Open ports in the firewall for the bazarr web interface.";
16 listenPort = lib.mkOption {
17 type = lib.types.port;
19 description = "Port on which the bazarr web interface should listen";
25 description = "User account under which bazarr runs.";
28 group = lib.mkOption {
31 description = "Group under which bazarr runs.";
36 config = lib.mkIf cfg.enable {
37 systemd.services.bazarr = {
38 description = "bazarr";
39 after = [ "network.target" ];
40 wantedBy = [ "multi-user.target" ];
46 StateDirectory = "bazarr";
47 SyslogIdentifier = "bazarr";
48 ExecStart = pkgs.writeShellScript "start-bazarr" ''
49 ${pkgs.bazarr}/bin/bazarr \
50 --config '/var/lib/${StateDirectory}' \
51 --port ${toString cfg.listenPort} \
54 Restart = "on-failure";
58 networking.firewall = lib.mkIf cfg.openFirewall {
59 allowedTCPPorts = [ cfg.listenPort ];
62 users.users = lib.mkIf (cfg.user == "bazarr") {
66 home = "/var/lib/${config.systemd.services.bazarr.serviceConfig.StateDirectory}";
70 users.groups = lib.mkIf (cfg.group == "bazarr") {