Skip to content

Commit

Permalink
nixos/frigate: allow configuring a libva driver
Browse files Browse the repository at this point in the history
In my testing this helped steer VA-API towards the correct card and also
made it show GPU statistics in performance monitoring.
  • Loading branch information
mweinelt committed Nov 22, 2024
1 parent dbcddf4 commit f4530dd
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions nixos/modules/services/video/frigate.nix
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,27 @@ in
'';
};

vaapiDriver = mkOption {
type = nullOr (enum [ "i965" "iHD" "nouveau" "vdpau" "nvidia" "radeonsi" ]);
default = null;
example = "radeonsi";
description = ''
Force usage of a particular VA-API driver for video acceleration. Use together with `settings.ffmpeg.hwaccel_args`.
Setting this *is not required* for VA-API to work, but it can help steer VA-API towards the correct card if you have multiple.
:::{.note}
For VA-API to work you must enable {option}`hardware.graphics.enable` (sufficient for AMDGPU) and pass for example
`pkgs.intel-media-driver` (required for Intel 5th Gen. and newer) into {option}`hardware.graphics.extraPackages`.
:::
See also:
- https://docs.frigate.video/configuration/hardware_acceleration
- https://docs.frigate.video/configuration/ffmpeg_presets#hwaccel-presets
'';
};

settings = mkOption {
type = submodule {
freeformType = format.type;
Expand Down Expand Up @@ -542,6 +563,8 @@ in
CONFIG_FILE = format.generate "frigate.yml" filteredConfig;
HOME = "/var/lib/frigate";
PYTHONPATH = cfg.package.pythonPath;
} // optionalAttrs (cfg.vaapiDriver != null) {
LIBVA_DRIVER_NAME = cfg.vaapiDriver;
} // optionalAttrs withCoral {
LD_LIBRARY_PATH = makeLibraryPath (with pkgs; [ libedgetpu ]);
};
Expand All @@ -568,6 +591,8 @@ in
Group = "frigate";
SupplementaryGroups = [ "render" ] ++ optionals withCoral [ "coral" ];

AmbientCapabilities = optionals (elem cfg.vaapiDriver [ "i965" "iHD" ]) [ "CAP_PERFMON" ]; # for intel_gpu_top

UMask = "0027";

StateDirectory = "frigate";
Expand Down

0 comments on commit f4530dd

Please sign in to comment.