2023-03-30 11:06:31 +00:00
|
|
|
import ./make-test-python.nix ({ pkgs, lib, ...} :
|
|
|
|
|
|
|
|
{
|
|
|
|
name = "frigate";
|
|
|
|
meta.maintainers = with lib.maintainers; [ hexa ];
|
|
|
|
|
|
|
|
nodes = {
|
2024-08-26 14:39:02 +00:00
|
|
|
machine = {
|
2023-03-30 11:06:31 +00:00
|
|
|
services.frigate = {
|
|
|
|
enable = true;
|
|
|
|
|
|
|
|
hostname = "localhost";
|
|
|
|
|
|
|
|
settings = {
|
|
|
|
mqtt.enabled = false;
|
|
|
|
|
|
|
|
cameras.test = {
|
|
|
|
ffmpeg = {
|
|
|
|
input_args = "-fflags nobuffer -strict experimental -fflags +genpts+discardcorrupt -r 10 -use_wallclock_as_timestamps 1";
|
|
|
|
inputs = [ {
|
|
|
|
path = "http://127.0.0.1:8080";
|
|
|
|
roles = [
|
|
|
|
"record"
|
|
|
|
];
|
|
|
|
} ];
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
record.enabled = true;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
systemd.services.video-stream = {
|
|
|
|
description = "Start a test stream that frigate can capture";
|
|
|
|
before = [
|
|
|
|
"frigate.service"
|
|
|
|
];
|
|
|
|
wantedBy = [
|
|
|
|
"multi-user.target"
|
|
|
|
];
|
|
|
|
serviceConfig = {
|
|
|
|
DynamicUser = true;
|
2024-08-22 00:28:25 +00:00
|
|
|
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";
|
2024-02-01 22:09:56 +00:00
|
|
|
Restart = "always";
|
2023-03-30 11:06:31 +00:00
|
|
|
};
|
|
|
|
};
|
2024-08-26 14:39:02 +00:00
|
|
|
|
|
|
|
environment.systemPackages = with pkgs; [ httpie ];
|
2023-03-30 11:06:31 +00:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
testScript = ''
|
|
|
|
start_all()
|
|
|
|
|
2024-08-26 14:39:02 +00:00
|
|
|
# wait until frigate is up
|
2023-03-30 11:06:31 +00:00
|
|
|
machine.wait_for_unit("frigate.service")
|
|
|
|
machine.wait_for_open_port(5001)
|
|
|
|
|
2024-08-26 14:39:02 +00:00
|
|
|
# extract admin password from logs
|
|
|
|
machine.wait_until_succeeds("journalctl -u frigate.service -o cat | grep -q 'Password: '")
|
|
|
|
password = machine.execute("journalctl -u frigate.service -o cat | grep -oP '([a-f0-9]{32})'")[1]
|
|
|
|
|
|
|
|
# login and store session
|
|
|
|
machine.log(machine.succeed(f"http --check-status --session=frigate post http://localhost/api/login user=admin password={password}"))
|
|
|
|
|
|
|
|
# make authenticated api requested
|
|
|
|
machine.log(machine.succeed("http --check-status --session=frigate get http://localhost/api/version"))
|
2024-02-01 22:09:56 +00:00
|
|
|
|
2024-08-26 14:39:02 +00:00
|
|
|
# wait for a recording to appear
|
2024-02-01 22:09:56 +00:00
|
|
|
machine.wait_for_file("/var/cache/frigate/test@*.mp4")
|
2023-03-30 11:06:31 +00:00
|
|
|
'';
|
|
|
|
})
|