1{
2 lib,
3 stdenv,
4 fetchurl,
5 makeWrapper,
6 temurin-jre-bin-17,
7 bash,
8 suitesparse,
9 nixosTests,
10}:
11
12stdenv.mkDerivation rec {
13 pname = "photonvision";
14 version = "2025.2.1";
15
16 src =
17 {
18 "x86_64-linux" = fetchurl {
19 url = "https://github.com/PhotonVision/photonvision/releases/download/v${version}/photonvision-v${version}-linuxx64.jar";
20 hash = "sha256-yEb6GCt29DjZNDsIqDvF/AiCw3QVMxUFKQM22OlMl7Q=";
21 };
22 "aarch64-linux" = fetchurl {
23 url = "https://github.com/PhotonVision/photonvision/releases/download/v${version}/photonvision-v${version}-linuxarm64.jar";
24 hash = "sha256-mNQk8gaTASsmyJUpLLIbG7QRMjbdSN2LMCXx6j3gbCU=";
25 };
26 }
27 .${stdenv.hostPlatform.system} or (throw "Unsupported system: ${stdenv.hostPlatform.system}");
28
29 dontUnpack = true;
30
31 nativeBuildInputs = [ makeWrapper ];
32
33 installPhase = ''
34 runHook preInstall
35
36 install -D $src $out/lib/photonvision.jar
37
38 makeWrapper ${temurin-jre-bin-17}/bin/java $out/bin/photonvision \
39 --prefix LD_LIBRARY_PATH : ${
40 lib.makeLibraryPath [
41 stdenv.cc.cc
42 suitesparse
43 ]
44 } \
45 --prefix PATH : ${
46 lib.makeBinPath [
47 temurin-jre-bin-17
48 bash.out
49 ]
50 } \
51 --add-flags "-jar $out/lib/photonvision.jar"
52
53 runHook postInstall
54 '';
55
56 passthru.tests = {
57 starts-web-server = nixosTests.photonvision;
58 };
59
60 meta = with lib; {
61 description = "Free, fast, and easy-to-use computer vision solution for the FIRST Robotics Competition";
62 homepage = "https://photonvision.org/";
63 license = licenses.gpl3;
64 maintainers = with maintainers; [ max-niederman ];
65 mainProgram = "photonvision";
66 platforms = [
67 "x86_64-linux"
68 "aarch64-linux"
69 ];
70 };
71}