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 3c6c9d9b3660..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, @@ -27,7 +26,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 +68,7 @@ let hash = "sha256-5Cj2vEiWR8Z9d2xBmVoLZuNRv4UOuxHSGZQWTJorXUQ="; }; in -python312Packages.buildPythonApplication rec { +python3Packages.buildPythonApplication rec { pname = "frigate"; inherit version; format = "other"; @@ -65,11 +77,7 @@ python312Packages.buildPythonApplication rec { patches = [ ./constants.patch - - (replaceVars ./ffmpeg.patch { - ffmpeg = lib.getExe ffmpeg-headless; - ffprobe = lib.getExe' ffmpeg-headless "ffprobe"; - }) + ./ffmpeg.patch ]; postPatch = '' @@ -109,7 +117,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 +199,8 @@ python312Packages.buildPythonApplication rec { runHook postInstall ''; - nativeCheckInputs = with python312Packages; [ + nativeCheckInputs = with python3Packages; [ + ffmpeg-headless pytestCheckHook ]; @@ -213,7 +222,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; };