summaryrefslogtreecommitdiffstats
path: root/pkgs/by-name/ph/photonvision/package.nix
blob: a4640d73370768d6eabc2ed362017d5f175b2cb5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
{
  lib,
  stdenv,
  fetchurl,
  makeWrapper,
  temurin-jre-bin-17,
  bash,
  suitesparse,
  nixosTests,
}:

stdenv.mkDerivation (finalAttrs: {
  pname = "photonvision";
  version = "2025.2.1";

  src =
    {
      "x86_64-linux" = fetchurl {
        url = "https://github.com/PhotonVision/photonvision/releases/download/v${finalAttrs.version}/photonvision-v${finalAttrs.version}-linuxx64.jar";
        hash = "sha256-yEb6GCt29DjZNDsIqDvF/AiCw3QVMxUFKQM22OlMl7Q=";
      };
      "aarch64-linux" = fetchurl {
        url = "https://github.com/PhotonVision/photonvision/releases/download/v${finalAttrs.version}/photonvision-v${finalAttrs.version}-linuxarm64.jar";
        hash = "sha256-YG9wyh+MCsv/RBdiFvgrF6Fw/6AnN7OEi4ofkMptfT0=";
      };
    }
    .${stdenv.hostPlatform.system} or (throw "Unsupported system: ${stdenv.hostPlatform.system}");

  dontUnpack = true;

  nativeBuildInputs = [ makeWrapper ];

  installPhase = ''
    runHook preInstall

    install -D $src $out/lib/photonvision.jar

    makeWrapper ${temurin-jre-bin-17}/bin/java $out/bin/photonvision \
      --prefix LD_LIBRARY_PATH : ${
        lib.makeLibraryPath [
          stdenv.cc.cc
          suitesparse
        ]
      } \
      --prefix PATH : ${
        lib.makeBinPath [
          temurin-jre-bin-17
          bash.out
        ]
      } \
      --add-flags "-jar $out/lib/photonvision.jar"

    runHook postInstall
  '';

  passthru.tests = {
    starts-web-server = nixosTests.photonvision;
  };

  meta = {
    description = "Free, fast, and easy-to-use computer vision solution for the FIRST Robotics Competition";
    homepage = "https://photonvision.org/";
    license = lib.licenses.gpl3;
    maintainers = with lib.maintainers; [ max-niederman ];
    mainProgram = "photonvision";
    platforms = [
      "x86_64-linux"
      "aarch64-linux"
    ];
  };
})