9 cfg = config.services.photonvision;
13 services.photonvision = {
14 enable = lib.mkEnableOption "PhotonVision";
16 package = lib.mkPackageOption pkgs "photonvision" { };
18 openFirewall = lib.mkOption {
20 Whether to open the required ports in the firewall.
23 type = lib.types.bool;
28 config = lib.mkIf cfg.enable {
29 systemd.services.photonvision = {
30 description = "PhotonVision, the free, fast, and easy-to-use computer vision solution for the FIRST Robotics Competition";
32 wantedBy = [ "multi-user.target" ];
33 after = [ "network.target" ];
36 ExecStart = lib.getExe cfg.package;
38 # ephemeral root directory
39 RuntimeDirectory = "photonvision";
40 RootDirectory = "/run/photonvision";
42 # setup persistent state and logs directories
43 StateDirectory = "photonvision";
44 LogsDirectory = "photonvision";
47 # mount the nix store read-only
50 # the JRE reads the user.home property from /etc/passwd
54 # mount the configuration and logs directories to the host
55 "/var/lib/photonvision:/photonvision_config"
56 "/var/log/photonvision:/photonvision_config/logs"
59 # for PhotonVision's dynamic libraries, which it writes to /tmp
64 networking.firewall = lib.mkIf cfg.openFirewall {
65 allowedTCPPorts = [ 5800 ];
66 allowedTCPPortRanges = [