1{ stdenv, requireFile, unzip, makeWrapper, oraclejdk8, autoPatchelfHook
2, pcsclite
3}:
4
5stdenv.mkDerivation rec {
6 name = "${pname}-${version}";
7 pname = "javacard-devkit";
8 version = "2.2.2";
9 uscoreVersion = builtins.replaceStrings ["."] ["_"] version;
10
11 src = requireFile {
12 name = "java_card_kit-${uscoreVersion}-linux.zip";
13 url = "http://www.oracle.com/technetwork/java/javasebusiness/downloads/"
14 + "java-archive-downloads-javame-419430.html#java_card_kit-2.2.2-oth-JPR";
15 sha256 = "1rzkw8izqq73ifvyp937wnjjc40a40drc4zsm0l1s6jyv3d7agb2";
16 };
17
18 nativeBuildInputs = [ unzip oraclejdk8 makeWrapper autoPatchelfHook ];
19 buildInputs = [ pcsclite ];
20
21 zipPrefix = "java_card_kit-${uscoreVersion}";
22
23 sourceRoot = ".";
24 unpackCmd = ''
25 unzip -p "$curSrc" "$zipPrefix/$zipPrefix-rr-bin-linux-do.zip" | jar x
26 '';
27
28 installPhase = ''
29 mkdir -p "$out/share/$pname"
30 cp -rt "$out/share/$pname" api_export_files
31 cp -rt "$out" lib
32
33 for i in bin/*; do
34 case "$i" in
35 *.so) install -vD "$i" "$out/libexec/$pname/$(basename "$i")";;
36 *) target="$out/bin/$(basename "$i")"
37 install -vD "$i" "$target"
38 sed -i -e 's|^$JAVA_HOME/bin/java|''${JAVA:-$JAVA_HOME/bin/java}|' "$target"
39 wrapProgram "$target" \
40 --set JAVA_HOME "$JAVA_HOME" \
41 --prefix CLASSPATH : "$out/share/$pname/api_export_files"
42 ;;
43 esac
44 done
45
46 makeWrapper "$JAVA_HOME/bin/javac" "$out/bin/javacardc" \
47 --prefix CLASSPATH : "$out/lib/api.jar"
48 '';
49
50 meta = {
51 description = "Official development kit by Oracle for programming for the Java Card platform";
52 longDescription = ''
53 This Java Card SDK is the official SDK made available by Oracle for programming for the Java Card platform.
54
55 Instructions for usage:
56
57 First, compile your '.java' (NixOS-specific: you should not need to set the class path -- if you need, it's a bug):
58 javacardc -source 1.5 -target 1.5 [MyJavaFile].java
59 Then, test with 'jcwde' (NixOS-specific: you can change the java version used to run jcwde with eg. JAVA=jdb):
60 CLASSPATH=. jcwde [MyJcwdeConfig].app & sleep 1 && apdutool [MyApdus].apdu
61 Finally, convert the '.class' file into a '.cap':
62 converter -applet [AppletAID] [MyApplet] [myPackage] [PackageAID] [Version]
63 For more details, please refer to the documentation by Oracle
64 '';
65 homepage = http://www.oracle.com/technetwork/java/embedded/javacard/overview/index.html;
66 license = stdenv.lib.licenses.unfree;
67 maintainers = [ stdenv.lib.maintainers.ekleog ];
68 platforms = [ "i686-linux" "x86_64-linux" ];
69 };
70}