nixpkgs/nixos/modules/services/video/photonvision.nix
Silvan Mosberger 4f0dadbf38 treewide: format all inactive Nix files
After final improvements to the official formatter implementation,
this commit now performs the first treewide reformat of Nix files using it.
This is part of the implementation of RFC 166.

Only "inactive" files are reformatted, meaning only files that
aren't being touched by any PR with activity in the past 2 months.
This is to avoid conflicts for PRs that might soon be merged.
Later we can do a full treewide reformat to get the rest,
which should not cause as many conflicts.

A CI check has already been running for some time to ensure that new and
already-formatted files are formatted, so the files being reformatted here
should also stay formatted.

This commit was automatically created and can be verified using

    nix-build a08b3a4d19.tar.gz \
      --argstr baseRev b32a094368
    result/bin/apply-formatting $NIXPKGS_PATH
2024-12-10 20:26:33 +01:00

75 lines
1.8 KiB
Nix

{
config,
pkgs,
lib,
...
}:
let
cfg = config.services.photonvision;
in
{
options = {
services.photonvision = {
enable = lib.mkEnableOption "PhotonVision";
package = lib.mkPackageOption pkgs "photonvision" { };
openFirewall = lib.mkOption {
description = ''
Whether to open the required ports in the firewall.
'';
default = false;
type = lib.types.bool;
};
};
};
config = lib.mkIf cfg.enable {
systemd.services.photonvision = {
description = "PhotonVision, the free, fast, and easy-to-use computer vision solution for the FIRST Robotics Competition";
wantedBy = [ "multi-user.target" ];
after = [ "network.target" ];
serviceConfig = {
ExecStart = lib.getExe cfg.package;
# ephemeral root directory
RuntimeDirectory = "photonvision";
RootDirectory = "/run/photonvision";
# setup persistent state and logs directories
StateDirectory = "photonvision";
LogsDirectory = "photonvision";
BindReadOnlyPaths = [
# mount the nix store read-only
"/nix/store"
# the JRE reads the user.home property from /etc/passwd
"/etc/passwd"
];
BindPaths = [
# mount the configuration and logs directories to the host
"/var/lib/photonvision:/photonvision_config"
"/var/log/photonvision:/photonvision_config/logs"
];
# for PhotonVision's dynamic libraries, which it writes to /tmp
PrivateTmp = true;
};
};
networking.firewall = lib.mkIf cfg.openFirewall {
allowedTCPPorts = [ 5800 ];
allowedTCPPortRanges = [
{
from = 1180;
to = 1190;
}
];
};
};
}