1 { lib, pkgs, config, ... }:
2 let cfg = config.services.owncast;
5 options.services.owncast = {
7 enable = lib.mkEnableOption "owncast, a video live streaming solution";
9 dataDir = lib.mkOption {
11 default = "/var/lib/owncast";
13 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.
17 openFirewall = lib.mkOption {
18 type = lib.types.bool;
21 Open the appropriate ports in the firewall for owncast.
28 description = "User account under which owncast runs.";
31 group = lib.mkOption {
34 description = "Group under which owncast runs.";
37 listen = lib.mkOption {
39 default = "127.0.0.1";
41 description = "The IP address to bind the owncast web server to.";
45 type = lib.types.port;
48 TCP port where owncast web-gui listens.
52 rtmp-port = lib.mkOption {
53 type = lib.types.port;
56 TCP port where owncast rtmp service listens.
62 config = lib.mkIf cfg.enable {
64 systemd.services.owncast = {
65 description = "A self-hosted live video and web chat server";
66 wantedBy = [ "multi-user.target" ];
68 serviceConfig = lib.mkMerge [
72 WorkingDirectory = cfg.dataDir;
73 ExecStart = "${pkgs.owncast}/bin/owncast -webserverport ${toString cfg.port} -rtmpport ${toString cfg.rtmp-port} -webserverip ${cfg.listen}";
74 Restart = "on-failure";
76 (lib.mkIf (cfg.dataDir == "/var/lib/owncast") {
77 StateDirectory = "owncast";
82 users.users = lib.mkIf (cfg.user == "owncast") {
86 description = "owncast system user";
90 users.groups = lib.mkIf (cfg.group == "owncast") { owncast = { }; };
93 lib.mkIf cfg.openFirewall { allowedTCPPorts = [ cfg.rtmp-port ] ++ lib.optional (cfg.listen != "127.0.0.1") cfg.port; };
96 meta = { maintainers = with lib.maintainers; [ MayNiklas ]; };