1 { lib, stdenv, gcc-arm-embedded, binutils-arm-embedded, makeWrapper
5 , device ? "fsij", vid ? "234b", pid ? "0000"
7 # Version specific options
13 pname = "gnuk-${device}";
17 nativeBuildInputs = [ gcc-arm-embedded binutils-arm-embedded makeWrapper ];
18 buildInputs = with python3Packages; [ python 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"
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}
47 homepage = "https://www.fsij.org/doc-gnuk/";
48 description = "An implementation of USB cryptographic token for gpg";
49 license = licenses.gpl3;
50 platforms = with platforms; linux;