From 39b2cccebdbb9815915d4bee12c731e89931f212 Mon Sep 17 00:00:00 2001 From: Simonas Kazlauskas Date: Mon, 19 Oct 2026 01:36:36 +0300 Subject: [PATCH] nixos/frigate: retain the runtime state file Some of the runtime knobs cannot be replicated well with file-based configuration. A prime example of this is soft-disabling a camera (I have my 3D printer camera in frigate, why are you looking at me like that :sweat_smile:) In short, `camera.enabled: false` in config will hard-disable the camera instead and it cannot be re-enabled either via UI or MQTT. The UI/MQTT toggle, however does remember the camera state across restarts and will restore it when it starts back up, making it a soft-disable mechanism. This state is stored in the file next to the config without a way to move it. We also can't use a Bind mount or symlink for this file, because frigate utilizes the atomic-move pattern to atomically modify this file, which doesn't work with bind mounts and will overwrite the symlink. --- nixos/modules/services/video/frigate.nix | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/nixos/modules/services/video/frigate.nix b/nixos/modules/services/video/frigate.nix index ecea71abbc36..69595edac8f8 100644 --- a/nixos/modules/services/video/frigate.nix +++ b/nixos/modules/services/video/frigate.nix @@ -733,7 +733,10 @@ in "multi-user.target" ]; environment = { - CONFIG_FILE = "/run/frigate/frigate.yml"; + # Frigate keeps some of its persistent runtime state in a file next to the configuration, + # so the config must also live in persistent storage (even though we overwrite it on every + # startup.) + CONFIG_FILE = "/var/lib/frigate/frigate.yml"; HOME = "/var/lib/frigate"; PYTHONPATH = cfg.package.pythonPath; } @@ -762,7 +765,7 @@ in ${lib.getExe pkgs.findutils} /var/cache/frigate -not -path '/var/cache/frigate/model_cache/*' -type f -delete '') (pkgs.writeShellScript "frigate-create-writable-config" '' - cp --no-preserve=mode ${configFile} /run/frigate/frigate.yml + cp --no-preserve=mode ${configFile} "$CONFIG_FILE" '') ] ++ lib.optionals (!config.systemd.services.frigate.environment ? LIBAVFORMAT_VERSION_MAJOR) [