14 src = fetchFromGitHub {
15 #name = "frigate-${version}-source";
16 owner = "blakeblackshear";
18 rev = "refs/tags/v${version}";
19 hash = "sha256-kNvYsHoObi6b9KT/LYhTGK4uJ/uAHnYhyoQkiXIA/s8=";
22 frigate-web = callPackage ./web.nix {
26 python = python3.override {
27 packageOverrides = self: super: {
31 # Tensorflow Lite models
32 # https://github.com/blakeblackshear/frigate/blob/v0.12.0/Dockerfile#L88-L91
33 tflite_cpu_model = fetchurl {
34 url = "https://github.com/google-coral/test_data/raw/release-frogfish/ssdlite_mobiledet_coco_qat_postprocess.tflite";
35 hash = "sha256-kLszpjTgQZFMwYGapd+ZgY5sOWxNLblSwP16nP/Eck8=";
37 tflite_edgetpu_model = fetchurl {
38 url = "https://github.com/google-coral/test_data/raw/release-frogfish/ssdlite_mobiledet_coco_qat_postprocess_edgetpu.tflite";
39 hash = "sha256-Siviu7YU5XbVbcuRT6UnUr8PE0EVEnENNV2X+qGzVkE=";
43 # https://github.com/blakeblackshear/frigate/blob/v0.12.0/Dockerfile#L92-L95
44 openvino_model = fetchurl {
45 url = "https://github.com/openvinotoolkit/open_model_zoo/raw/master/data/dataset_classes/coco_91cl_bkgr.txt";
46 hash = "sha256-5Cj2vEiWR8Z9d2xBmVoLZuNRv4UOuxHSGZQWTJorXUQ=";
49 python.pkgs.buildPythonApplication rec {
59 url = "https://github.com/blakeblackshear/frigate/commit/cb73d0cd392990448811c7212bc5f09be411fc69.patch";
60 hash = "sha256-Spt7eRosmTN8zyJ2uVme5HPVy2TKgBtvbQ6tp6PaNac=";
65 echo 'VERSION = "${version}"' > frigate/version.py
67 substituteInPlace frigate/app.py \
68 --replace "Router(migrate_db)" 'Router(migrate_db, "${placeholder "out"}/share/frigate/migrations")'
70 substituteInPlace frigate/const.py \
71 --replace "/media/frigate" "/var/lib/frigate" \
72 --replace "/tmp/cache" "/var/cache/frigate/"
74 substituteInPlace frigate/http.py \
75 --replace "/opt/frigate" "${placeholder "out"}/${python.sitePackages}" \
76 --replace "/tmp/cache/" "/var/cache/frigate/"
78 substituteInPlace frigate/output.py \
79 --replace "/opt/frigate" "${placeholder "out"}/${python.sitePackages}"
81 substituteInPlace frigate/record.py \
82 --replace "/tmp/cache" "/var/cache/frigate"
84 substituteInPlace frigate/detectors/detector_config.py \
85 --replace "/labelmap.txt" "${placeholder "out"}/share/frigate/labelmap.txt"
87 substituteInPlace frigate/detectors/plugins/edgetpu_tfl.py \
88 --replace "/edgetpu_model.tflite" "${tflite_edgetpu_model}"
90 substituteInPlace frigate/detectors/plugins/cpu_tfl.py \
91 --replace "/cpu_model.tflite" "${tflite_cpu_model}"
93 substituteInPlace frigate/ffmpeg_presets.py --replace \
94 '"-timeout" if os.path.exists(BTBN_PATH) else "-stimeout"' \
100 propagatedBuildInputs = with python.pkgs; [
103 # requirements-wheel.txt
129 mkdir -p $out/${python.sitePackages}/frigate
130 cp -R frigate/* $out/${python.sitePackages}/frigate/
132 mkdir -p $out/share/frigate
133 cp -R {migrations,labelmap.txt} $out/share/frigate/
135 cp --no-preserve=mode ${openvino_model} $out/share/frigate/coco_91cl_bkgr.txt
136 sed -i 's/truck/car/g' $out/share/frigate/coco_91cl_bkgr.txt
141 checkInputs = with python.pkgs; [
148 pythonPath =(python.pkgs.makePythonPath propagatedBuildInputs) + ":${frigate}/${python.sitePackages}";
150 inherit (nixosTests) frigate;
155 changelog = "https://github.com/blakeblackshear/frigate/releases/tag/v${version}";
156 description = "NVR with realtime local object detection for IP cameras";
158 A complete and local NVR designed for Home Assistant with AI
159 object detection. Uses OpenCV and Tensorflow to perform realtime
160 object detection locally for IP cameras.
162 homepage = "https://github.com/blakeblackshear/frigate";
163 license = licenses.mit;
164 maintainers = with maintainers; [ hexa ];