nixVersions.stable: 2.15 -> 2.17
[NixPkgs.git] / nixos / tests / frigate.nix
blob836fe0d063f873791bf45d239f5352422d929e1a
1 import ./make-test-python.nix ({ pkgs, lib, ...} :
4   name = "frigate";
5   meta.maintainers = with lib.maintainers; [ hexa ];
7   nodes = {
8     machine = { config, ... }: {
9       services.frigate = {
10         enable = true;
12         hostname = "localhost";
14         settings = {
15           mqtt.enabled = false;
17           cameras.test = {
18             ffmpeg = {
19               input_args = "-fflags nobuffer -strict experimental -fflags +genpts+discardcorrupt -r 10 -use_wallclock_as_timestamps 1";
20               inputs = [ {
21                 path = "http://127.0.0.1:8080";
22                 roles = [
23                   "record"
24                 ];
25               } ];
26             };
27           };
29           record.enabled = true;
30         };
31       };
33       systemd.services.video-stream = {
34         description = "Start a test stream that frigate can capture";
35         before = [
36           "frigate.service"
37         ];
38         wantedBy = [
39           "multi-user.target"
40         ];
41         serviceConfig = {
42           DynamicUser = true;
43           ExecStart = "${lib.getBin pkgs.ffmpeg-headless}/bin/ffmpeg -re -f lavfi -i smptebars=size=800x600:rate=10 -f mpegts -listen 1 http://0.0.0.0:8080";
44         };
45       };
46     };
47   };
49   testScript = ''
50     start_all()
52     machine.wait_for_unit("frigate.service")
54     machine.wait_for_open_port(5001)
56     machine.succeed("curl http://localhost:5001")
58     machine.wait_for_file("/var/cache/frigate/test-*.mp4")
59   '';