13 src = fetchFromGitHub {
14 name = "frigate-${version}-source";
15 owner = "blakeblackshear";
17 rev = "refs/tags/v${version}";
18 hash = "sha256-PfUlo9ua4SVcQJTfmSVoEXHH1MUJ8A/w3kJHFpEzll8=";
21 frigate-web = callPackage ./web.nix {
25 python = python312.override {
27 packageOverrides = self: super: {
28 paho-mqtt = super.paho-mqtt_2;
32 # Tensorflow Lite models
33 # https://github.com/blakeblackshear/frigate/blob/v0.13.0/docker/main/Dockerfile#L96-L97
34 tflite_cpu_model = fetchurl {
35 url = "https://github.com/google-coral/test_data/raw/release-frogfish/ssdlite_mobiledet_coco_qat_postprocess.tflite";
36 hash = "sha256-kLszpjTgQZFMwYGapd+ZgY5sOWxNLblSwP16nP/Eck8=";
38 tflite_edgetpu_model = fetchurl {
39 url = "https://github.com/google-coral/test_data/raw/release-frogfish/ssdlite_mobiledet_coco_qat_postprocess_edgetpu.tflite";
40 hash = "sha256-Siviu7YU5XbVbcuRT6UnUr8PE0EVEnENNV2X+qGzVkE=";
44 # https://github.com/blakeblackshear/frigate/blob/v0.13.0/docker/main/Dockerfile#L101
45 openvino_model = fetchurl {
46 url = "https://github.com/openvinotoolkit/open_model_zoo/raw/master/data/dataset_classes/coco_91cl_bkgr.txt";
47 hash = "sha256-5Cj2vEiWR8Z9d2xBmVoLZuNRv4UOuxHSGZQWTJorXUQ=";
50 python.pkgs.buildPythonApplication rec {
58 echo 'VERSION = "${version}"' > frigate/version.py
60 substituteInPlace frigate/app.py \
61 --replace-fail "Router(migrate_db)" 'Router(migrate_db, "${placeholder "out"}/share/frigate/migrations")'
63 substituteInPlace frigate/const.py \
64 --replace-fail "/media/frigate" "/var/lib/frigate" \
65 --replace-fail "/tmp/cache" "/var/cache/frigate" \
66 --replace-fail "/config" "/var/lib/frigate" \
67 --replace-fail "{CONFIG_DIR}/model_cache" "/var/cache/frigate/model_cache"
69 substituteInPlace frigate/comms/{config,detections,events}_updater.py frigate/comms/inter_process.py \
70 --replace-fail "ipc:///tmp/cache" "ipc:///run/frigate"
72 substituteInPlace frigate/detectors/detector_config.py \
73 --replace-fail "/labelmap.txt" "${placeholder "out"}/share/frigate/labelmap.txt"
75 # work around onvif-zeep idiosyncrasy
76 substituteInPlace frigate/ptz/onvif.py \
77 --replace-fail dist-packages site-packages
79 substituteInPlace frigate/config.py \
80 --replace-fail "/cpu_model.tflite" "${tflite_cpu_model}" \
81 --replace-fail "/edgetpu_model.tflite" "${tflite_edgetpu_model}"
83 substituteInPlace frigate/test/test_config.py \
84 --replace-fail "(MODEL_CACHE_DIR" "('/build/model_cache'" \
85 --replace-fail "/config/model_cache" "/build/model_cache"
90 propagatedBuildInputs = with python.pkgs; [
91 # docker/main/requirements.txt
93 # docker/main/requirements-wheel.txt
130 mkdir -p $out/${python.sitePackages}/frigate
131 cp -R frigate/* $out/${python.sitePackages}/frigate/
133 mkdir -p $out/share/frigate
134 cp -R {migrations,labelmap.txt} $out/share/frigate/
136 cp --no-preserve=mode ${openvino_model} $out/share/frigate/coco_91cl_bkgr.txt
137 sed -i 's/truck/car/g' $out/share/frigate/coco_91cl_bkgr.txt
142 nativeCheckInputs = with python.pkgs; [
147 # Test needs network access
154 pythonPath =(python.pkgs.makePythonPath propagatedBuildInputs) + ":${frigate}/${python.sitePackages}";
156 inherit (nixosTests) frigate;
161 changelog = "https://github.com/blakeblackshear/frigate/releases/tag/v${version}";
162 description = "NVR with realtime local object detection for IP cameras";
164 A complete and local NVR designed for Home Assistant with AI
165 object detection. Uses OpenCV and Tensorflow to perform realtime
166 object detection locally for IP cameras.
168 homepage = "https://github.com/blakeblackshear/frigate";
169 license = licenses.mit;
170 maintainers = with maintainers; [ hexa ];