@@ -0,0 +1,52 @@
1+{ stdenv, gcc-arm-embedded, makeWrapper
2+, python, pythonPackages
5+, device ? "fsij", vid ? "234b", pid ? "0000"
7+# Version specific options
13+ name = "gnuk-${version}-${device}";
17+ nativeBuildInputs = [ gcc-arm-embedded makeWrapper ];
18+ buildInputs = [ python ] ++ (with pythonPackages; [ pyusb colorama ]);
22+ patchShebangs configure
23+ ./configure --vidpid=${vid}:${pid}
29+ find . -name gnuk.bin -exec cp {} $out \;
31+ #sed -i 's,Exception as e,IOError as e,' ../tool/stlinkv2.py
32+ sed -i ../tool/stlinkv2.py \
33+ -e "1a import array" \
34+ -e "s,\(data_received =\) (),\1 array.array('B'),g" \
35+ -e "s,\(data_received\) = data_received + \(.*\),\1.extend(\2),g"
36+ cp ../tool/stlinkv2.py $out/bin/stlinkv2
37+ wrapProgram $out/bin/stlinkv2 --prefix PYTHONPATH : "$PYTHONPATH"
39+ # Some useful helpers
40+ echo "#! ${stdenv.shell} -e" | tee $out/bin/{unlock,flash}
41+ echo "$out/bin/stlinkv2 -u \$@" >> $out/bin/unlock
42+ echo "$out/bin/stlinkv2 -b \$@ $out/gnuk.bin" >> $out/bin/flash
43+ chmod +x $out/bin/{unlock,flash}
46+ meta = with stdenv.lib; {
47+ homepage = http://www.fsij.org/pages/gnuk;
48+ description = "an implementation of USB cryptographic token for gpg";
49+ license = licenses.gpl3;
50+ maintainers = with maintainers; [ wkennington ];