lol
1{ lib, stdenv, fetchFromGitHub, jdk8, maven, makeWrapper, jre8_headless, pcsclite }:
2
3let jdk = jdk8; jre_headless = jre8_headless; in
4# TODO: This is quite a bit of duplicated logic with gephi. Factor it out?
5stdenv.mkDerivation rec {
6 pname = "global-platform-pro";
7 version = "18.09.14";
8 GPPRO_VERSION = "18.09.14-0-gb439b52"; # git describe --tags --always --long --dirty
9
10 src = fetchFromGitHub {
11 owner = "martinpaljak";
12 repo = "GlobalPlatformPro";
13 rev = version;
14 sha256 = "1vws6cbgm3mrwc2xz9j1y262vw21x3hjc9m7rqc4hn3m7gjpwsvg";
15 };
16
17 deps = stdenv.mkDerivation {
18 name = "${pname}-${version}-deps";
19 inherit src;
20 nativeBuildInputs = [ jdk maven ];
21 installPhase = ''
22 # Download the dependencies
23 while ! mvn package "-Dmaven.repo.local=$out/.m2" -Dmaven.wagon.rto=5000; do
24 echo "timeout, restart maven to continue downloading"
25 done
26
27 # And keep only *.{pom,jar,sha1,nbm} and delete all ephemeral files
28 # with lastModified timestamps inside
29 find "$out/.m2" -type f \
30 -regex '.+\(\.lastUpdated\|resolver-status\.properties\|_remote\.repositories\)' \
31 -delete
32 '';
33 outputHashAlgo = "sha256";
34 outputHashMode = "recursive";
35 outputHash = "1qwgvz6l5wia8q5824c9f3iwyapfskljhqf1z09fw6jjj1jy3b15";
36 };
37
38 nativeBuildInputs = [ jdk maven makeWrapper ];
39
40 buildPhase = ''
41 cp -dpR "${deps}/.m2" ./
42 chmod -R +w .m2
43 mvn package --offline -Dmaven.repo.local="$(pwd)/.m2"
44 '';
45
46 installPhase = ''
47 mkdir -p "$out/lib/java" "$out/share/java"
48 cp target/gp.jar "$out/share/java"
49 makeWrapper "${jre_headless}/bin/java" "$out/bin/gp" \
50 --add-flags "-jar '$out/share/java/gp.jar'" \
51 --prefix LD_LIBRARY_PATH : "${pcsclite.out}/lib"
52 '';
53
54 meta = with lib; {
55 description = "Command-line utility for managing applets and keys on Java Cards";
56 longDescription = ''
57 This command-line utility can be used to manage applets and keys
58 on Java Cards. It is made available as the `gp` executable.
59
60 The executable requires the PC/SC daemon running for correct execution.
61 If you run NixOS, it can be enabled with `services.pcscd.enable = true;`.
62 '';
63 homepage = "https://github.com/martinpaljak/GlobalPlatformPro";
64 sourceProvenance = with sourceTypes; [
65 fromSource
66 binaryBytecode # deps
67 ];
68 license = with licenses; [ lgpl3 ];
69 maintainers = with maintainers; [ ekleog ];
70 mainProgram = "gp";
71 platforms = platforms.all;
72 };
73}