2021-01-11 08:54:33 +01:00
|
|
|
{ lib, stdenv, gcc-arm-embedded, binutils-arm-embedded, makeWrapper
|
2021-03-25 15:44:20 +01:00
|
|
|
, python2Packages
|
2015-04-30 06:29:26 +02:00
|
|
|
|
|
|
|
# Extra options
|
|
|
|
, device ? "fsij", vid ? "234b", pid ? "0000"
|
|
|
|
|
|
|
|
# Version specific options
|
|
|
|
, version, src
|
|
|
|
, ...
|
|
|
|
}:
|
|
|
|
|
|
|
|
stdenv.mkDerivation {
|
|
|
|
name = "gnuk-${version}-${device}";
|
|
|
|
|
|
|
|
inherit src;
|
|
|
|
|
2018-10-12 22:21:26 +02:00
|
|
|
nativeBuildInputs = [ gcc-arm-embedded binutils-arm-embedded makeWrapper ];
|
2021-03-25 15:44:20 +01:00
|
|
|
buildInputs = with python2Packages; [ python pyusb colorama ];
|
2015-04-30 06:29:26 +02:00
|
|
|
|
|
|
|
configurePhase = ''
|
|
|
|
cd src
|
|
|
|
patchShebangs configure
|
|
|
|
./configure --vidpid=${vid}:${pid}
|
|
|
|
'';
|
|
|
|
|
|
|
|
installPhase = ''
|
|
|
|
mkdir -p $out/bin
|
|
|
|
|
|
|
|
find . -name gnuk.bin -exec cp {} $out \;
|
|
|
|
|
|
|
|
#sed -i 's,Exception as e,IOError as e,' ../tool/stlinkv2.py
|
|
|
|
sed -i ../tool/stlinkv2.py \
|
|
|
|
-e "1a import array" \
|
|
|
|
-e "s,\(data_received =\) (),\1 array.array('B'),g" \
|
|
|
|
-e "s,\(data_received\) = data_received + \(.*\),\1.extend(\2),g"
|
|
|
|
cp ../tool/stlinkv2.py $out/bin/stlinkv2
|
|
|
|
wrapProgram $out/bin/stlinkv2 --prefix PYTHONPATH : "$PYTHONPATH"
|
|
|
|
|
|
|
|
# Some useful helpers
|
|
|
|
echo "#! ${stdenv.shell} -e" | tee $out/bin/{unlock,flash}
|
|
|
|
echo "$out/bin/stlinkv2 -u \$@" >> $out/bin/unlock
|
|
|
|
echo "$out/bin/stlinkv2 -b \$@ $out/gnuk.bin" >> $out/bin/flash
|
|
|
|
chmod +x $out/bin/{unlock,flash}
|
|
|
|
'';
|
|
|
|
|
2021-01-11 08:54:33 +01:00
|
|
|
meta = with lib; {
|
2020-04-01 03:11:51 +02:00
|
|
|
homepage = "http://www.fsij.org/pages/gnuk";
|
2016-06-20 12:53:46 +02:00
|
|
|
description = "An implementation of USB cryptographic token for gpg";
|
2015-04-30 06:29:26 +02:00
|
|
|
license = licenses.gpl3;
|
2016-08-02 19:50:55 +02:00
|
|
|
platforms = with platforms; linux;
|
2015-04-30 06:29:26 +02:00
|
|
|
};
|
|
|
|
}
|