at 16.09-beta 53 lines 1.5 kB view raw
1{ stdenv, gcc-arm-embedded, makeWrapper 2, python, pythonPackages 3 4# Extra options 5, device ? "fsij", vid ? "234b", pid ? "0000" 6 7# Version specific options 8, version, src 9, ... 10}: 11 12stdenv.mkDerivation { 13 name = "gnuk-${version}-${device}"; 14 15 inherit src; 16 17 nativeBuildInputs = [ gcc-arm-embedded makeWrapper ]; 18 buildInputs = [ python ] ++ (with pythonPackages; [ pyusb colorama ]); 19 20 configurePhase = '' 21 cd src 22 patchShebangs configure 23 ./configure --vidpid=${vid}:${pid} 24 ''; 25 26 installPhase = '' 27 mkdir -p $out/bin 28 29 find . -name gnuk.bin -exec cp {} $out \; 30 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" 38 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} 44 ''; 45 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 ]; 51 platforms = with platforms; linux; 52 }; 53}