1 { config, pkgs, lib, ... }:
4 cfg = config.services.photonvision;
8 services.photonvision = {
9 enable = lib.mkEnableOption "PhotonVision";
11 package = lib.mkPackageOption pkgs "photonvision" {};
13 openFirewall = lib.mkOption {
15 Whether to open the required ports in the firewall.
18 type = lib.types.bool;
23 config = lib.mkIf cfg.enable {
24 systemd.services.photonvision = {
25 description = "PhotonVision, the free, fast, and easy-to-use computer vision solution for the FIRST Robotics Competition";
27 wantedBy = [ "multi-user.target" ];
28 after = [ "network.target" ];
31 ExecStart = lib.getExe cfg.package;
33 # ephemeral root directory
34 RuntimeDirectory = "photonvision";
35 RootDirectory = "/run/photonvision";
37 # setup persistent state and logs directories
38 StateDirectory = "photonvision";
39 LogsDirectory = "photonvision";
42 # mount the nix store read-only
45 # the JRE reads the user.home property from /etc/passwd
49 # mount the configuration and logs directories to the host
50 "/var/lib/photonvision:/photonvision_config"
51 "/var/log/photonvision:/photonvision_config/logs"
54 # for PhotonVision's dynamic libraries, which it writes to /tmp
59 networking.firewall = lib.mkIf cfg.openFirewall {
60 allowedTCPPorts = [ 5800 ];
61 allowedTCPPortRanges = [{ from = 1180; to = 1190; }];