1
0
Fork 1
mirror of https://github.com/NixOS/nixpkgs.git synced 2025-06-08 10:48:06 +09:00
nixpkgs/nixos/tests/zigbee2mqtt.nix

44 lines
996 B
Nix

{
lib,
package,
pkgs,
...
}:
let
error =
if lib.versionOlder package.version "2" then
"Inappropriate ioctl for device, cannot set"
else
"No valid USB adapter found";
in
{
name = "zigbee2mqtt-${lib.versions.major package.version}.x";
nodes.machine = {
systemd.services.dummy-serial = {
wantedBy = [
"multi-user.target"
];
serviceConfig = {
ExecStart = "${pkgs.socat}/bin/socat pty,link=/dev/ttyACM0,mode=666 pty,link=/dev/ttyACM1";
};
};
services.zigbee2mqtt = {
enable = true;
inherit package;
};
systemd.services.zigbee2mqtt.serviceConfig.DevicePolicy = lib.mkForce "auto";
};
testScript = ''
machine.wait_for_unit("multi-user.target")
machine.wait_until_fails("systemctl status zigbee2mqtt.service")
machine.succeed(
"journalctl -eu zigbee2mqtt | grep '${error}'"
)
machine.log(machine.succeed("systemd-analyze security zigbee2mqtt.service"))
'';
}