From cbfb9c30a0607e5bfd1dde8c40705dcfff1f4adc Mon Sep 17 00:00:00 2001 From: Bryan Ramos Date: Thu, 12 Mar 2026 04:05:10 -0400 Subject: [PATCH] frigate init --- src/system/machines/server/system.nix | 1 + src/system/modules/frigate/default.nix | 109 +++++++++++++++++++++++++ 2 files changed, 110 insertions(+) create mode 100644 src/system/modules/frigate/default.nix diff --git a/src/system/machines/server/system.nix b/src/system/machines/server/system.nix index 5f03a94..46c0d59 100644 --- a/src/system/machines/server/system.nix +++ b/src/system/machines/server/system.nix @@ -7,6 +7,7 @@ modules.system = { nginx.enable = true; forgejo.enable = true; + frigate.enable = true; }; users.users = { diff --git a/src/system/modules/frigate/default.nix b/src/system/modules/frigate/default.nix new file mode 100644 index 0000000..cead1e8 --- /dev/null +++ b/src/system/modules/frigate/default.nix @@ -0,0 +1,109 @@ +{ pkgs, lib, config, ... }: + +with lib; +let + cfg = config.modules.system.frigate; + nginx = config.modules.system.nginx; + domain = "ramos.codes"; + +in +{ + options.modules.system.frigate = { + enable = mkEnableOption "Enable Frigate NVR"; + }; + + config = mkIf cfg.enable { + services.frigate = { + enable = true; + hostname = "frigate.${domain}"; + settings = { + web = { + bind_address = "127.0.0.1"; + port = 5000; + }; + mqtt.enabled = false; + cameras = { + "Doorbell" = { + ffmpeg = { + inputs = [ + { + path = "rtsp://admin:ocu?u3Su@192.168.0.134/cam/realmonitor?channel=1&subtype=0"; + roles = [ "record" ]; + } + { + path = "rtsp://admin:ocu?u3Su@192.168.0.134/cam/realmonitor?channel=1&subtype=1"; + roles = [ "detect" ]; + } + ]; + }; + }; + "Living Room" = { + ffmpeg = { + inputs = [ + { + path = "rtsp://admin:ocu?u3Su@192.168.0.181/cam/realmonitor?channel=1&subtype=0"; + roles = [ "record" ]; + } + { + path = "rtsp://admin:ocu?u3Su@192.168.0.181/cam/realmonitor?channel=1&subtype=1"; + roles = [ "detect" ]; + } + ]; + }; + }; + "Kitchen" = { + ffmpeg = { + inputs = [ + { + path = "rtsp://admin:ocu?u3Su@192.168.0.181/cam/realmonitor?channel=2&subtype=0"; + roles = [ "record" ]; + } + { + path = "rtsp://admin:ocu?u3Su@192.168.0.181/cam/realmonitor?channel=2&subtype=1"; + roles = [ "detect" ]; + } + ]; + }; + }; + "Parking Lot" = { + ffmpeg = { + inputs = [ + { + path = "rtsp://admin:ocu?u3Su@192.168.0.60/cam/realmonitor?channel=1&subtype=0"; + roles = [ "record" ]; + } + { + path = "rtsp://admin:ocu?u3Su@192.168.0.60/cam/realmonitor?channel=1&subtype=1"; + roles = [ "detect" ]; + } + ]; + }; + }; + "Porch" = { + ffmpeg = { + inputs = [ + { + path = "rtsp://admin:ocu?u3Su@192.168.0.108/cam/realmonitor?channel=1&subtype=0"; + roles = [ "record" ]; + } + { + path = "rtsp://admin:ocu?u3Su@192.168.0.108/cam/realmonitor?channel=1&subtype=1"; + roles = [ "detect" ]; + } + ]; + }; + }; + }; + }; + }; + + services.nginx.virtualHosts."frigate.${domain}" = mkIf nginx.enable { + useACMEHost = domain; + forceSSL = true; + locations."/" = { + proxyPass = "http://127.0.0.1:5000"; + proxyWebsockets = true; + }; + }; + }; +}