|
1 | | -import ./make-test-python.nix ( |
2 | | - { pkgs, lib, ... }: |
| 1 | +{ |
| 2 | + pkgs, |
| 3 | + lib, |
| 4 | + ... |
| 5 | +}: |
3 | 6 |
|
4 | | - { |
5 | | - name = "frigate"; |
6 | | - meta.maintainers = with lib.maintainers; [ hexa ]; |
| 7 | +{ |
| 8 | + name = "frigate"; |
| 9 | + meta = { inherit (pkgs.frigate.meta) maintainers; }; |
7 | 10 |
|
8 | | - nodes = { |
9 | | - machine = { |
10 | | - services.frigate = { |
11 | | - enable = true; |
| 11 | + nodes = { |
| 12 | + machine = { |
| 13 | + services.frigate = { |
| 14 | + enable = true; |
12 | 15 |
|
13 | | - hostname = "localhost"; |
| 16 | + hostname = "localhost"; |
14 | 17 |
|
15 | | - settings = { |
16 | | - mqtt.enabled = false; |
| 18 | + settings = { |
| 19 | + mqtt.enabled = false; |
17 | 20 |
|
18 | | - cameras.test = { |
19 | | - ffmpeg = { |
20 | | - input_args = "-fflags nobuffer -strict experimental -fflags +genpts+discardcorrupt -r 10 -use_wallclock_as_timestamps 1"; |
21 | | - inputs = [ |
22 | | - { |
23 | | - path = "http://127.0.0.1:8080"; |
24 | | - roles = [ |
25 | | - "record" |
26 | | - ]; |
27 | | - } |
28 | | - ]; |
29 | | - }; |
| 21 | + cameras.test = { |
| 22 | + ffmpeg = { |
| 23 | + input_args = "-fflags nobuffer -strict experimental -fflags +genpts+discardcorrupt -r 10 -use_wallclock_as_timestamps 1"; |
| 24 | + inputs = [ |
| 25 | + { |
| 26 | + path = "http://127.0.0.1:8080"; |
| 27 | + roles = [ |
| 28 | + "record" |
| 29 | + ]; |
| 30 | + } |
| 31 | + ]; |
30 | 32 | }; |
31 | | - |
32 | | - record.enabled = true; |
33 | 33 | }; |
34 | | - }; |
35 | 34 |
|
36 | | - systemd.services.video-stream = { |
37 | | - description = "Start a test stream that frigate can capture"; |
38 | | - before = [ |
39 | | - "frigate.service" |
40 | | - ]; |
41 | | - wantedBy = [ |
42 | | - "multi-user.target" |
43 | | - ]; |
44 | | - serviceConfig = { |
45 | | - DynamicUser = true; |
46 | | - ExecStart = "${lib.getExe pkgs.ffmpeg-headless} -re -f lavfi -i smptebars=size=1280x720:rate=5 -f mpegts -listen 1 http://0.0.0.0:8080"; |
47 | | - Restart = "always"; |
48 | | - }; |
| 35 | + record.enabled = true; |
49 | 36 | }; |
| 37 | + }; |
50 | 38 |
|
51 | | - environment.systemPackages = with pkgs; [ httpie ]; |
| 39 | + systemd.services.video-stream = { |
| 40 | + description = "Start a test stream that frigate can capture"; |
| 41 | + before = [ |
| 42 | + "frigate.service" |
| 43 | + ]; |
| 44 | + wantedBy = [ |
| 45 | + "multi-user.target" |
| 46 | + ]; |
| 47 | + serviceConfig = { |
| 48 | + DynamicUser = true; |
| 49 | + ExecStart = "${lib.getExe pkgs.ffmpeg-headless} -re -f lavfi -i smptebars=size=1280x720:rate=5 -f mpegts -listen 1 http://0.0.0.0:8080"; |
| 50 | + Restart = "always"; |
| 51 | + }; |
52 | 52 | }; |
| 53 | + |
| 54 | + environment.systemPackages = with pkgs; [ httpie ]; |
53 | 55 | }; |
| 56 | + }; |
54 | 57 |
|
55 | | - testScript = '' |
56 | | - start_all() |
| 58 | + testScript = '' |
| 59 | + start_all() |
57 | 60 |
|
58 | | - # wait until frigate is up |
59 | | - machine.wait_for_unit("frigate.service") |
60 | | - machine.wait_for_open_port(5001) |
| 61 | + # wait until frigate is up |
| 62 | + machine.wait_for_unit("frigate.service") |
| 63 | + machine.wait_for_open_port(5001) |
61 | 64 |
|
62 | | - # extract admin password from logs |
63 | | - machine.wait_until_succeeds("journalctl -u frigate.service -o cat | grep -q 'Password: '") |
64 | | - password = machine.execute("journalctl -u frigate.service -o cat | grep -oP '([a-f0-9]{32})'")[1] |
| 65 | + # extract admin password from logs |
| 66 | + machine.wait_until_succeeds("journalctl -u frigate.service -o cat | grep -q 'Password: '") |
| 67 | + password = machine.execute("journalctl -u frigate.service -o cat | grep -oP '([a-f0-9]{32})'")[1] |
65 | 68 |
|
66 | | - # login and store session |
67 | | - machine.log(machine.succeed(f"http --check-status --session=frigate post http://localhost/api/login user=admin password={password}")) |
| 69 | + # login and store session |
| 70 | + machine.log(machine.succeed(f"http --check-status --session=frigate post http://localhost/api/login user=admin password={password}")) |
68 | 71 |
|
69 | | - # make authenticated api request |
70 | | - machine.log(machine.succeed("http --check-status --session=frigate get http://localhost/api/version")) |
| 72 | + # make authenticated api request |
| 73 | + machine.log(machine.succeed("http --check-status --session=frigate get http://localhost/api/version")) |
71 | 74 |
|
72 | | - # make unauthenticated api request |
73 | | - machine.log(machine.succeed("http --check-status get http://localhost:5000/api/version")) |
| 75 | + # make unauthenticated api request |
| 76 | + machine.log(machine.succeed("http --check-status get http://localhost:5000/api/version")) |
74 | 77 |
|
75 | | - # wait for a recording to appear |
76 | | - machine.wait_for_file("/var/cache/frigate/test@*.mp4") |
77 | | - ''; |
78 | | - } |
79 | | -) |
| 78 | + # wait for a recording to appear |
| 79 | + machine.wait_for_file("/var/cache/frigate/test@*.mp4") |
| 80 | + ''; |
| 81 | +} |
0 commit comments