config/modules/services/frigate/default.nix

137 lines
3.7 KiB
Nix
Raw Normal View History

2025-02-11 20:00:40 +00:00
{
lib,
2025-02-12 15:55:19 +00:00
#pkgs,
2025-02-11 20:00:40 +00:00
config,
...
}:
let
cfg = config.mj.services.frigate;
in
{
options.mj.services.frigate = with lib.types; {
enable = lib.mkEnableOption "enable frigate";
secretsEnv = lib.mkOption { type = path; };
};
config = lib.mkIf cfg.enable {
2025-02-13 15:43:38 +00:00
systemd.services = {
frigate = {
preStart = "ln -sf $CREDENTIALS_DIRECTORY/secrets.env /run/frigate/secrets.env";
serviceConfig = {
EnvironmentFile = [ "-/run/frigate/secrets.env" ];
RuntimeDirectory = "frigate";
LoadCredential = [ "secrets.env:${cfg.secretsEnv}" ];
};
};
go2rtc = {
preStart = "ln -sf $CREDENTIALS_DIRECTORY/secrets.env /run/go2rtc/secrets.env";
serviceConfig = {
EnvironmentFile = [ "-/run/go2rtc/secrets.env" ];
RuntimeDirectory = "go2rtc";
LoadCredential = [ "secrets.env:${cfg.secretsEnv}" ];
};
};
};
services.go2rtc = {
enable = true;
settings = {
2025-02-16 19:37:44 +00:00
# https://github.com/AlexxIT/go2rtc/issues/831
2025-02-16 19:30:02 +00:00
#log = {
# format = "text";
# level = "trace";
#};
2025-02-13 15:43:38 +00:00
streams = {
2025-02-16 20:31:02 +00:00
"vno4-dome-panorama-orig" = [
2025-02-16 07:18:43 +00:00
"ffmpeg:rtsp://frigate:\${FRIGATE_RTSP_PASSWORD}@192.168.188.10/cam/realmonitor?channel=1&subtype=2"
2025-02-13 19:42:21 +00:00
];
2025-02-16 20:31:02 +00:00
"vno4-dome-panorama-high" = [
"ffmpeg:rtsp://localhost:8554/vno4-dome-panorama-orig#hardware=vaapi#video=h264"
];
2025-02-13 19:42:21 +00:00
"vno4-dome-panorama-low" = [
2025-02-16 20:31:02 +00:00
"ffmpeg:rtsp://localhost:8554/vno4-dome-panorama-orig#hardware=vaapi#video=h264#width=1280#framerate=5"
2025-02-13 19:42:21 +00:00
];
2025-02-16 20:31:02 +00:00
"vno4-dome-ptz-orig" = [
2025-02-13 19:42:21 +00:00
"ffmpeg:rtsp://frigate:\${FRIGATE_RTSP_PASSWORD}@192.168.188.10/cam/realmonitor?channel=2&subtype=0"
];
2025-02-16 20:31:02 +00:00
"vno4-dome-ptz-high" = [
"ffmpeg:rtsp://localhost:8554/vno4-dome-ptz-orig#hardware=vaapi#video=h264"
];
2025-02-13 15:43:38 +00:00
"vno4-dome-ptz-low" = [
2025-02-16 20:31:02 +00:00
"ffmpeg:rtsp://localhost:8554/vno4-dome-ptz-orig#hardware=vaapi#video=h264#width=1280#framerate=5"
2025-02-13 15:43:38 +00:00
];
};
2025-02-11 20:00:40 +00:00
};
};
services.frigate = {
enable = true;
hostname = "r1.jakstys.lt";
settings = {
detect = {
enabled = true;
};
2025-02-13 07:31:57 +00:00
2025-02-11 20:00:40 +00:00
detectors = {
coral = {
type = "edgetpu";
device = "usb";
enabled = true;
};
};
record = {
enabled = true;
retain = {
days = 7;
mode = "all";
};
};
cameras = {
vno4-dome-panorama = {
2025-02-11 20:50:37 +00:00
enabled = true;
2025-02-11 20:00:40 +00:00
ffmpeg = {
hwaccel_args = "preset-vaapi";
output_args = {
2025-02-16 19:37:44 +00:00
record = "preset-record-generic";
2025-02-11 20:00:40 +00:00
};
inputs = [
{
2025-02-13 19:53:43 +00:00
path = "rtsp://localhost:8554/vno4-dome-panorama-high";
2025-02-16 19:37:44 +00:00
roles = [ "record" ];
2025-02-11 20:00:40 +00:00
}
{
path = "rtsp://localhost:8554/vno4-dome-panorama-low";
2025-02-11 20:00:40 +00:00
roles = [ "detect" ];
}
];
};
};
vno4-dome-ptz = {
enabled = true;
ffmpeg = {
output_args = {
2025-02-13 15:43:38 +00:00
record = "preset-record-generic-audio-copy";
2025-02-11 20:00:40 +00:00
};
inputs = [
{
2025-02-13 19:49:16 +00:00
path = "rtsp://localhost:8554/vno4-dome-ptz-high";
2025-02-11 20:00:40 +00:00
roles = [
"record"
2025-02-16 19:37:44 +00:00
"audio"
2025-02-11 20:00:40 +00:00
];
}
{
path = "rtsp://localhost:8554/vno4-dome-ptz-low";
2025-02-11 20:00:40 +00:00
roles = [ "detect" ];
}
];
};
};
};
};
};
};
}