From c478678cedb2a7aa306f59902cc700b13f180446 Mon Sep 17 00:00:00 2001 From: Martin Weinelt Date: Fri, 27 Feb 2026 02:23:26 +0100 Subject: [PATCH] nixos/frigate: fix IFD in libavformat soname version detection The combination of creating an environment file in ExecStartPre= and reading it in EnvironmentFile= works, but requires relaxing the existence check on the environment file. --- nixos/modules/services/video/frigate.nix | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/nixos/modules/services/video/frigate.nix b/nixos/modules/services/video/frigate.nix index 65e849c87998..56c50afb0463 100644 --- a/nixos/modules/services/video/frigate.nix +++ b/nixos/modules/services/video/frigate.nix @@ -699,15 +699,6 @@ in environment = { CONFIG_FILE = "/run/frigate/frigate.yml"; HOME = "/var/lib/frigate"; - # Extract libavformat version in the same way Docker scripts in frigate directory do. This - # environment variable changes the flags given to `ffmpeg` improving compatibility. - LIBAVFORMAT_VERSION_MAJOR = lib.strings.trim ( - builtins.readFile ( - pkgs.runCommandLocal "libavformat-major-version" { } '' - ${cfg.settings.ffmpeg.path}/bin/ffmpeg -version | grep -Po "libavformat\W+\K\d+" > $out - '' - ) - ); PYTHONPATH = cfg.package.pythonPath; } // optionalAttrs (cfg.vaapiDriver != null) { @@ -738,7 +729,15 @@ in (pkgs.writeShellScript "frigate-create-writable-config" '' cp --no-preserve=mode ${configFile} /run/frigate/frigate.yml '') + ] + ++ lib.optionals (!config.systemd.services.frigate.environment ? LIBAVFORMAT_VERSION_MAJOR) [ + # Extract libavformat version to enable version-dependent flags in ffmpeg + (pkgs.writeShellScript "frigate-libavformat-major-version" '' + echo "LIBAVFORMAT_VERSION_MAJOR=$(${cfg.settings.ffmpeg.path}/bin/ffmpeg -version | grep -Po "libavformat\W+\K\d+")" > /run/frigate/ffmpeg-env + echo "Detected $(cat /run/frigate/ffmpeg-env)" + '') ]; + EnvironmentFile = [ "-/run/frigate/ffmpeg-env" ]; ExecStart = "${cfg.package.python.interpreter} -m frigate"; Restart = "on-failure"; SyslogIdentifier = "frigate";