vuls: init at 0.27.0
[NixPkgs.git] / nixos / tests / ustreamer.nix
blob1354eb03a32694724b07c5ae8eb5ec2031e722bc
1 import ./make-test-python.nix ({ pkgs, ... }: {
2   name = "ustreamer-vmtest";
3   nodes = {
4     client = {...}: {
5       environment.systemPackages = [ pkgs.curl ];
6     };
7     camera = {config, ...}: let
8       configFile = pkgs.writeText "akvcam-configFile" ''
9         [Cameras]
10         cameras/size = 2
12         cameras/1/type = output
13         cameras/1/mode = mmap, userptr, rw
14         cameras/1/description = Virtual Camera (output device)
15         cameras/1/formats = 2
16         cameras/1/videonr = 7
18         cameras/2/type = capture
19         cameras/2/mode = mmap, rw
20         cameras/2/description = Virtual Camera
21         cameras/2/formats = 1, 2
22         cameras/2/videonr = 9
24         [Connections]
25         connections/size = 1
26         connections/1/connection = 1:2
28         [Formats]
29         formats/size = 2
31         formats/1/format = YUY2
32         formats/1/width = 640
33         formats/1/height = 480
34         formats/1/fps = 30
36         formats/2/format = RGB24, YUY2
37         formats/2/width = 640
38         formats/2/height = 480
39         formats/2/fps = 20/1, 15/2
40       '';
41     in {
42       environment.systemPackages = [ pkgs.ustreamer ];
43       networking.firewall.enable = false;
44       systemd.services.ustreamer = {
45         description = "ustreamer service";
46         wantedBy = ["multi-user.target"];
47         serviceConfig = {
48           DynamicUser = true;
49           ExecStart = "${pkgs.ustreamer}/bin/ustreamer --host=0.0.0.0 --port 8000 --device /dev/video9 --device-timeout=8";
50           PrivateTmp = true;
51           BindReadOnlyPaths = "/dev/video9";
52           SupplementaryGroups = [
53             "video"
54           ];
55           Restart = "always";
56         };
57       };
58       boot.extraModulePackages = [config.boot.kernelPackages.akvcam];
59       boot.kernelModules = ["akvcam"];
60       boot.extraModprobeConfig = ''
61         options akvcam config_file=${configFile}
62       '';
63     };
64   };
66   testScript = ''
67     start_all()
69     camera.wait_for_unit("ustreamer.service")
70     camera.wait_for_open_port(8000)
72     client.wait_for_unit("multi-user.target")
73     client.succeed("curl http://camera:8000")
74   '';