mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-12-12 16:53:21 +00:00
ef176dcf7e
conversions were done using https://github.com/pennae/nix-doc-munge using (probably) rev f34e145 running nix-doc-munge nixos/**/*.nix nix-doc-munge --import nixos/**/*.nix the tool ensures that only changes that could affect the generated manual *but don't* are committed, other changes require manual review and are discarded.
78 lines
1.9 KiB
Nix
78 lines
1.9 KiB
Nix
{ config, pkgs, lib, ... }:
|
|
|
|
with lib;
|
|
|
|
let
|
|
cfg = config.services.bazarr;
|
|
in
|
|
{
|
|
options = {
|
|
services.bazarr = {
|
|
enable = mkEnableOption (lib.mdDoc "bazarr, a subtitle manager for Sonarr and Radarr");
|
|
|
|
openFirewall = mkOption {
|
|
type = types.bool;
|
|
default = false;
|
|
description = lib.mdDoc "Open ports in the firewall for the bazarr web interface.";
|
|
};
|
|
|
|
listenPort = mkOption {
|
|
type = types.port;
|
|
default = 6767;
|
|
description = lib.mdDoc "Port on which the bazarr web interface should listen";
|
|
};
|
|
|
|
user = mkOption {
|
|
type = types.str;
|
|
default = "bazarr";
|
|
description = lib.mdDoc "User account under which bazarr runs.";
|
|
};
|
|
|
|
group = mkOption {
|
|
type = types.str;
|
|
default = "bazarr";
|
|
description = lib.mdDoc "Group under which bazarr runs.";
|
|
};
|
|
};
|
|
};
|
|
|
|
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 = {
|
|
isSystemUser = true;
|
|
group = cfg.group;
|
|
home = "/var/lib/${config.systemd.services.bazarr.serviceConfig.StateDirectory}";
|
|
};
|
|
};
|
|
|
|
users.groups = mkIf (cfg.group == "bazarr") {
|
|
bazarr = {};
|
|
};
|
|
};
|
|
}
|