From acd597689b8fa6dff31a7b38369a18afc78724ee Mon Sep 17 00:00:00 2001 From: ulic-youthlic Date: Thu, 3 Apr 2025 02:00:12 +0800 Subject: [PATCH] add owncast module, and enable it for Tytonidae --- nixos/configurations/Tytonidae/default.nix | 1 + nixos/modules/programs/default.nix | 1 + nixos/modules/programs/owncast.nix | 31 ++++++++++++++++++++++ 3 files changed, 33 insertions(+) create mode 100644 nixos/modules/programs/owncast.nix diff --git a/nixos/configurations/Tytonidae/default.nix b/nixos/configurations/Tytonidae/default.nix index bb89824..3e96b57 100644 --- a/nixos/configurations/Tytonidae/default.nix +++ b/nixos/configurations/Tytonidae/default.nix @@ -41,6 +41,7 @@ nix-ld.enable = true; juicity.client.enable = true; asusd.enable = true; + owncast.enable = true; }; gui.enabled = "niri"; }; diff --git a/nixos/modules/programs/default.nix b/nixos/modules/programs/default.nix index c24b76d..54f4520 100644 --- a/nixos/modules/programs/default.nix +++ b/nixos/modules/programs/default.nix @@ -22,5 +22,6 @@ ./miniflux.nix ./guix.nix ./asusd.nix + ./owncast.nix ]; } diff --git a/nixos/modules/programs/owncast.nix b/nixos/modules/programs/owncast.nix new file mode 100644 index 0000000..dc25db2 --- /dev/null +++ b/nixos/modules/programs/owncast.nix @@ -0,0 +1,31 @@ +{ lib, config, ... }: +let + cfg = config.youthlic.programs.owncast; +in +{ + options = { + youthlic.programs.owncast = { + enable = lib.mkEnableOption "owncast"; + }; + }; + config = lib.mkMerge [ + (lib.mkIf cfg.enable { + services.owncast = { + enable = true; + listen = "0.0.0.0"; + port = 8486; + rtmp-port = 1935; + openFirewall = true; + }; + }) + (lib.mkIf (cfg.enable && config.youthlic.programs.caddy.enable) { + services.caddy.virtualHosts = { + "owncast.${config.youthlic.programs.caddy.baseDomain}" = { + extraConfig = '' + reverse_proxy 127.0.0.1:8486 + ''; + }; + }; + }) + ]; +}