From 283a7184415f8b679d1eecf12b5fdf4e265d52c5 Mon Sep 17 00:00:00 2001 From: Martin Weinelt Date: Fri, 29 Aug 2025 15:45:07 +0200 Subject: [PATCH 1/2] frigate: pin joserfc at 1.1.0 Breaking changes in newer versions break frigate at runtime as visible in the nixos test. --- pkgs/by-name/fr/frigate/package.nix | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/pkgs/by-name/fr/frigate/package.nix b/pkgs/by-name/fr/frigate/package.nix index 3c6c9d9b3660..27f584f6a7bc 100644 --- a/pkgs/by-name/fr/frigate/package.nix +++ b/pkgs/by-name/fr/frigate/package.nix @@ -27,7 +27,20 @@ let inherit version src; }; - python = python312Packages.python; + python = python312Packages.python.override { + packageOverrides = self: super: { + joserfc = super.joserfc.overridePythonAttrs (oldAttrs: { + version = "1.1.0"; + src = fetchFromGitHub { + owner = "authlib"; + repo = "joserfc"; + tag = version; + hash = "sha256-95xtUzzIxxvDtpHX/5uCHnTQTB8Fc08DZGUOR/SdKLs="; + }; + }); + }; + }; + python3Packages = python.pkgs; # Tensorflow audio model # https://github.com/blakeblackshear/frigate/blob/v0.15.0/docker/main/Dockerfile#L125 @@ -56,7 +69,7 @@ let hash = "sha256-5Cj2vEiWR8Z9d2xBmVoLZuNRv4UOuxHSGZQWTJorXUQ="; }; in -python312Packages.buildPythonApplication rec { +python3Packages.buildPythonApplication rec { pname = "frigate"; inherit version; format = "other"; @@ -109,7 +122,7 @@ python312Packages.buildPythonApplication rec { dontBuild = true; - dependencies = with python312Packages; [ + dependencies = with python3Packages; [ # docker/main/requirements.txt scikit-build # docker/main/requirements-wheel.txt @@ -191,7 +204,7 @@ python312Packages.buildPythonApplication rec { runHook postInstall ''; - nativeCheckInputs = with python312Packages; [ + nativeCheckInputs = with python3Packages; [ pytestCheckHook ]; @@ -213,7 +226,7 @@ python312Packages.buildPythonApplication rec { passthru = { web = frigate-web; inherit python; - pythonPath = (python312Packages.makePythonPath dependencies) + ":${frigate}/${python.sitePackages}"; + pythonPath = (python3Packages.makePythonPath dependencies) + ":${frigate}/${python.sitePackages}"; tests = { inherit (nixosTests) frigate; }; From 6c4b1800989fcd82bca51f7ba8a72439cfe84c3c Mon Sep 17 00:00:00 2001 From: Martin Weinelt Date: Fri, 29 Aug 2025 15:45:50 +0200 Subject: [PATCH 2/2] frigate: centralize the ffmpeg flavor selection in the module In 0.16.0 frigate added a config option to pass an ffmpeg build for the ffmpeg and ffprobe executables. Previously we unconditionally patched in ffmpeg-headless, which has now been changed to use the `ffmpeg.path` provided build, so that we don't bloat the closure with multiple ffmpegs or don't require overriding the package to select another version. In contrast to the upstream configuration we only accept packages and not the "default" string, because that would have complicated the logic needlessly. --- nixos/modules/services/video/frigate.nix | 11 ++++++++ pkgs/by-name/fr/frigate/ffmpeg.patch | 34 +++++++++++++++--------- pkgs/by-name/fr/frigate/package.nix | 8 ++---- 3 files changed, 34 insertions(+), 19 deletions(-) diff --git a/nixos/modules/services/video/frigate.nix b/nixos/modules/services/video/frigate.nix index 6dc6bab6c036..5d8d92b5cae8 100644 --- a/nixos/modules/services/video/frigate.nix +++ b/nixos/modules/services/video/frigate.nix @@ -231,6 +231,17 @@ in }; }; + ffmpeg = { + path = mkOption { + type = coercedTo package toString str; + default = pkgs.ffmpeg-headless; + example = literalExpression "pkgs.ffmpeg-full"; + description = '' + Package providing the ffmpeg and ffprobe executables below the bin/ directory. + ''; + }; + }; + mqtt = { enabled = mkEnableOption "MQTT support"; diff --git a/pkgs/by-name/fr/frigate/ffmpeg.patch b/pkgs/by-name/fr/frigate/ffmpeg.patch index 78721dd6d3a4..9a91f6ed74b6 100644 --- a/pkgs/by-name/fr/frigate/ffmpeg.patch +++ b/pkgs/by-name/fr/frigate/ffmpeg.patch @@ -1,30 +1,39 @@ diff --git a/frigate/config/camera/ffmpeg.py b/frigate/config/camera/ffmpeg.py -index 04bbfac7..4390a571 100644 +index 04bbfac7..396bcc4b 100644 --- a/frigate/config/camera/ffmpeg.py +++ b/frigate/config/camera/ffmpeg.py -@@ -70,18 +70,14 @@ class FfmpegConfig(FrigateBaseModel): +@@ -1,4 +1,5 @@ + from enum import Enum ++from os.path import join + from typing import Union + + from pydantic import Field, field_validator +@@ -69,21 +70,11 @@ class FfmpegConfig(FrigateBaseModel): + @property def ffmpeg_path(self) -> str: - if self.path == "default": +- if self.path == "default": - return f"/usr/lib/ffmpeg/{DEFAULT_FFMPEG_VERSION}/bin/ffmpeg" - elif self.path in INCLUDED_FFMPEG_VERSIONS: - return f"/usr/lib/ffmpeg/{self.path}/bin/ffmpeg" -+ return "@ffmpeg@" - else: - return f"{self.path}/bin/ffmpeg" +- else: +- return f"{self.path}/bin/ffmpeg" ++ return join(self.path, "bin/ffmpeg") @property def ffprobe_path(self) -> str: - if self.path == "default": +- if self.path == "default": - return f"/usr/lib/ffmpeg/{DEFAULT_FFMPEG_VERSION}/bin/ffprobe" - elif self.path in INCLUDED_FFMPEG_VERSIONS: - return f"/usr/lib/ffmpeg/{self.path}/bin/ffprobe" -+ return "@ffprobe@" - else: - return f"{self.path}/bin/ffprobe" +- else: +- return f"{self.path}/bin/ffprobe" ++ return join(self.path, "bin/ffprobe") + + class CameraRoleEnum(str, Enum): diff --git a/frigate/record/export.py b/frigate/record/export.py -index 0d3f96da..09cadbcd 100644 +index 0d3f96da..463bcff4 100644 --- a/frigate/record/export.py +++ b/frigate/record/export.py @@ -126,7 +126,7 @@ class RecordingExporter(threading.Thread): @@ -32,8 +41,7 @@ index 0d3f96da..09cadbcd 100644 seconds = int(diff % 60) ffmpeg_cmd = [ - "/usr/lib/ffmpeg/7.0/bin/ffmpeg", # hardcode path for exports thumbnail due to missing libwebp support -+ "@ffmpeg@", # hardcode path for exports thumbnail due to missing libwebp support ++ FfmpegConfig.ffmpeg_path, # hardcode path for exports thumbnail due to missing libwebp support "-hide_banner", "-loglevel", "warning", -~ diff --git a/pkgs/by-name/fr/frigate/package.nix b/pkgs/by-name/fr/frigate/package.nix index 27f584f6a7bc..f6a4fb5f6db2 100644 --- a/pkgs/by-name/fr/frigate/package.nix +++ b/pkgs/by-name/fr/frigate/package.nix @@ -2,7 +2,6 @@ lib, stdenv, callPackage, - replaceVars, python312Packages, fetchFromGitHub, fetchurl, @@ -78,11 +77,7 @@ python3Packages.buildPythonApplication rec { patches = [ ./constants.patch - - (replaceVars ./ffmpeg.patch { - ffmpeg = lib.getExe ffmpeg-headless; - ffprobe = lib.getExe' ffmpeg-headless "ffprobe"; - }) + ./ffmpeg.patch ]; postPatch = '' @@ -205,6 +200,7 @@ python3Packages.buildPythonApplication rec { ''; nativeCheckInputs = with python3Packages; [ + ffmpeg-headless pytestCheckHook ];