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