2021-09-26 12:46:18 +00:00
|
|
|
{ lib, pkgs, config, ... }:
|
|
|
|
let cfg = config.services.owncast;
|
|
|
|
in {
|
|
|
|
|
|
|
|
options.services.owncast = {
|
|
|
|
|
2024-09-19 14:19:46 +00:00
|
|
|
enable = lib.mkEnableOption "owncast, a video live streaming solution";
|
2021-09-26 12:46:18 +00:00
|
|
|
|
2024-09-19 14:19:46 +00:00
|
|
|
dataDir = lib.mkOption {
|
|
|
|
type = lib.types.str;
|
2021-09-26 12:46:18 +00:00
|
|
|
default = "/var/lib/owncast";
|
2024-04-21 15:54:59 +00:00
|
|
|
description = ''
|
2021-09-26 12:46:18 +00:00
|
|
|
The directory where owncast stores its data files. If left as the default value this directory will automatically be created before the owncast server starts, otherwise the sysadmin is responsible for ensuring the directory exists with appropriate ownership and permissions.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
2024-09-19 14:19:46 +00:00
|
|
|
openFirewall = lib.mkOption {
|
|
|
|
type = lib.types.bool;
|
2021-09-26 12:46:18 +00:00
|
|
|
default = false;
|
2024-04-21 15:54:59 +00:00
|
|
|
description = ''
|
2021-09-26 12:46:18 +00:00
|
|
|
Open the appropriate ports in the firewall for owncast.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
2024-09-19 14:19:46 +00:00
|
|
|
user = lib.mkOption {
|
|
|
|
type = lib.types.str;
|
2021-09-26 12:46:18 +00:00
|
|
|
default = "owncast";
|
2024-04-21 15:54:59 +00:00
|
|
|
description = "User account under which owncast runs.";
|
2021-09-26 12:46:18 +00:00
|
|
|
};
|
|
|
|
|
2024-09-19 14:19:46 +00:00
|
|
|
group = lib.mkOption {
|
|
|
|
type = lib.types.str;
|
2021-09-26 12:46:18 +00:00
|
|
|
default = "owncast";
|
2024-04-21 15:54:59 +00:00
|
|
|
description = "Group under which owncast runs.";
|
2021-09-26 12:46:18 +00:00
|
|
|
};
|
|
|
|
|
2024-09-19 14:19:46 +00:00
|
|
|
listen = lib.mkOption {
|
|
|
|
type = lib.types.str;
|
2021-09-26 12:46:18 +00:00
|
|
|
default = "127.0.0.1";
|
|
|
|
example = "0.0.0.0";
|
2024-04-21 15:54:59 +00:00
|
|
|
description = "The IP address to bind the owncast web server to.";
|
2021-09-26 12:46:18 +00:00
|
|
|
};
|
|
|
|
|
2024-09-19 14:19:46 +00:00
|
|
|
port = lib.mkOption {
|
|
|
|
type = lib.types.port;
|
2021-09-26 12:46:18 +00:00
|
|
|
default = 8080;
|
2024-04-21 15:54:59 +00:00
|
|
|
description = ''
|
2021-09-26 12:46:18 +00:00
|
|
|
TCP port where owncast web-gui listens.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
2024-09-19 14:19:46 +00:00
|
|
|
rtmp-port = lib.mkOption {
|
|
|
|
type = lib.types.port;
|
2021-09-26 12:46:18 +00:00
|
|
|
default = 1935;
|
2024-04-21 15:54:59 +00:00
|
|
|
description = ''
|
2021-09-26 12:46:18 +00:00
|
|
|
TCP port where owncast rtmp service listens.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
};
|
|
|
|
|
2024-09-19 14:19:46 +00:00
|
|
|
config = lib.mkIf cfg.enable {
|
2021-09-26 12:46:18 +00:00
|
|
|
|
|
|
|
systemd.services.owncast = {
|
|
|
|
description = "A self-hosted live video and web chat server";
|
|
|
|
wantedBy = [ "multi-user.target" ];
|
|
|
|
|
2024-09-19 14:19:46 +00:00
|
|
|
serviceConfig = lib.mkMerge [
|
2021-09-26 12:46:18 +00:00
|
|
|
{
|
|
|
|
User = cfg.user;
|
|
|
|
Group = cfg.group;
|
|
|
|
WorkingDirectory = cfg.dataDir;
|
|
|
|
ExecStart = "${pkgs.owncast}/bin/owncast -webserverport ${toString cfg.port} -rtmpport ${toString cfg.rtmp-port} -webserverip ${cfg.listen}";
|
|
|
|
Restart = "on-failure";
|
|
|
|
}
|
2024-09-19 14:19:46 +00:00
|
|
|
(lib.mkIf (cfg.dataDir == "/var/lib/owncast") {
|
2021-09-26 12:46:18 +00:00
|
|
|
StateDirectory = "owncast";
|
|
|
|
})
|
|
|
|
];
|
|
|
|
};
|
|
|
|
|
2024-09-19 14:19:46 +00:00
|
|
|
users.users = lib.mkIf (cfg.user == "owncast") {
|
2021-09-26 12:46:18 +00:00
|
|
|
owncast = {
|
|
|
|
isSystemUser = true;
|
|
|
|
group = cfg.group;
|
|
|
|
description = "owncast system user";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2024-09-19 14:19:46 +00:00
|
|
|
users.groups = lib.mkIf (cfg.group == "owncast") { owncast = { }; };
|
2021-09-26 12:46:18 +00:00
|
|
|
|
|
|
|
networking.firewall =
|
2024-09-19 14:19:46 +00:00
|
|
|
lib.mkIf cfg.openFirewall { allowedTCPPorts = [ cfg.rtmp-port ] ++ lib.optional (cfg.listen != "127.0.0.1") cfg.port; };
|
2021-09-26 12:46:18 +00:00
|
|
|
|
|
|
|
};
|
|
|
|
meta = { maintainers = with lib.maintainers; [ MayNiklas ]; };
|
|
|
|
}
|