Skip to content

Commit 5c3df80

Browse files
committed
1 parent b49c546 commit 5c3df80

File tree

4 files changed

+495
-75
lines changed

4 files changed

+495
-75
lines changed

nixos/modules/services/video/frigate.nix

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,9 @@ in
254254
proxy_set_header Cookie $http_cookie;
255255
proxy_set_header X-CSRF-TOKEN "1";
256256
257+
# Header used to validate reverse proxy trust
258+
proxy_set_header X-Proxy-Secret $http_x_proxy_secret;
259+
257260
# Pass headers for common auth proxies
258261
proxy_set_header Remote-User $http_remote_user;
259262
proxy_set_header Remote-Groups $http_remote_groups;
@@ -282,6 +285,8 @@ in
282285
283286
add_header Cache-Control "no-store";
284287
expires off;
288+
289+
keepalive_disable safari;
285290
'';
286291
};
287292
"/stream/" = {
@@ -407,7 +412,7 @@ in
407412
proxyPass = "http://frigate-api";
408413
recommendedProxySettings = true;
409414
extraConfig = nginxAuthRequest + nginxProxySettings + ''
410-
rewrite ^/api/(.*)$ $1 break;
415+
rewrite ^/api/(.*)$ /$1 break;
411416
'';
412417
};
413418
"/api/" = {
@@ -443,7 +448,7 @@ in
443448
location /api/stats {
444449
${nginxAuthRequest}
445450
access_log off;
446-
rewrite ^/api/(.*)$ $1 break;
451+
rewrite ^/api(/.*)$ $1 break;
447452
add_header Cache-Control "no-store";
448453
proxy_pass http://frigate-api;
449454
${nginxProxySettings}
@@ -452,7 +457,7 @@ in
452457
location /api/version {
453458
${nginxAuthRequest}
454459
access_log off;
455-
rewrite ^/api/(.*)$ $1 break;
460+
rewrite ^/api(/.*)$ $1 break;
456461
add_header Cache-Control "no-store";
457462
proxy_pass http://frigate-api;
458463
${nginxProxySettings}
@@ -560,7 +565,7 @@ in
560565
"multi-user.target"
561566
];
562567
environment = {
563-
CONFIG_FILE = format.generate "frigate.yml" filteredConfig;
568+
CONFIG_FILE = "/run/frigate/frigate.yml";
564569
HOME = "/var/lib/frigate";
565570
PYTHONPATH = cfg.package.pythonPath;
566571
} // optionalAttrs (cfg.vaapiDriver != null) {
@@ -578,11 +583,17 @@ in
578583
] ++ optionals (!stdenv.hostPlatform.isAarch64) [
579584
# not available on aarch64-linux
580585
intel-gpu-tools
586+
rocmPackages.rocminfo
581587
];
582588
serviceConfig = {
583-
ExecStartPre = pkgs.writeShellScript "frigate-clear-cache" ''
584-
rm --recursive --force /var/cache/frigate/*
585-
'';
589+
ExecStartPre = [
590+
(pkgs.writeShellScript "frigate-clear-cache" ''
591+
rm --recursive --force /var/cache/frigate/*
592+
'')
593+
(pkgs.writeShellScript "frigate-create-writable-config" ''
594+
cp --no-preserve=mode "${format.generate "frigate.yml" filteredConfig}" /run/frigate/frigate.yml
595+
'')
596+
];
586597
ExecStart = "${cfg.package.python.interpreter} -m frigate";
587598
Restart = "on-failure";
588599
SyslogIdentifier = "frigate";

0 commit comments

Comments
 (0)