2024-10-31 15:40:02 +00:00
|
|
|
{
|
|
|
|
lib,
|
|
|
|
stdenv,
|
2024-10-31 15:41:26 +00:00
|
|
|
fetchFromGitLab,
|
2024-10-31 15:40:02 +00:00
|
|
|
gcc-arm-embedded,
|
|
|
|
binutils-arm-embedded,
|
|
|
|
makeWrapper,
|
|
|
|
python3Packages,
|
2024-10-31 14:52:18 +00:00
|
|
|
|
2024-10-31 15:42:01 +00:00
|
|
|
# Default FSIJ IDs
|
2024-10-31 15:40:02 +00:00
|
|
|
vid ? "234b",
|
|
|
|
pid ? "0000",
|
2024-10-31 14:52:18 +00:00
|
|
|
}:
|
|
|
|
|
2024-10-31 15:41:26 +00:00
|
|
|
stdenv.mkDerivation (finalAttrs: {
|
2024-10-31 14:52:18 +00:00
|
|
|
pname = "gnuk";
|
2024-10-31 15:41:26 +00:00
|
|
|
version = "2.2";
|
2015-04-30 04:29:26 +00:00
|
|
|
|
2024-10-31 15:41:26 +00:00
|
|
|
src = fetchFromGitLab {
|
|
|
|
domain = "salsa.debian.org";
|
|
|
|
owner = "gnuk-team";
|
|
|
|
repo = "gnuk/gnuk";
|
|
|
|
rev = "release/${finalAttrs.version}";
|
|
|
|
hash = "sha256-qY/dwkcPJiPx/+inSxH7w7a0v3cWUQDX+NYJwUjnkMY=";
|
|
|
|
fetchSubmodules = true;
|
2015-04-30 04:29:26 +00:00
|
|
|
};
|
2024-10-31 14:52:18 +00:00
|
|
|
|
2024-10-31 15:40:02 +00:00
|
|
|
nativeBuildInputs = [
|
|
|
|
gcc-arm-embedded
|
|
|
|
binutils-arm-embedded
|
|
|
|
makeWrapper
|
|
|
|
];
|
2024-10-31 15:42:01 +00:00
|
|
|
|
2024-10-31 15:40:02 +00:00
|
|
|
buildInputs = with python3Packages; [
|
|
|
|
python
|
|
|
|
pyusb
|
|
|
|
colorama
|
|
|
|
];
|
2024-10-31 14:52:18 +00:00
|
|
|
|
2024-10-31 15:42:19 +00:00
|
|
|
sourceRoot = "${finalAttrs.src.name}/src";
|
|
|
|
|
|
|
|
configureFlags = [ "--vidpid=${vid}:${pid}" ];
|
2024-10-31 14:52:18 +00:00
|
|
|
|
2024-10-31 15:42:19 +00:00
|
|
|
# TODO: Check how many of these patches are actually needed.
|
2024-10-31 14:52:18 +00:00
|
|
|
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}
|
|
|
|
'';
|
|
|
|
|
2024-10-31 15:42:01 +00:00
|
|
|
meta = {
|
|
|
|
homepage = "https://www.fsij.org/category/gnuk.html";
|
2024-10-31 14:52:18 +00:00
|
|
|
description = "Implementation of USB cryptographic token for gpg";
|
2024-10-31 15:42:01 +00:00
|
|
|
license = lib.licenses.gpl3;
|
|
|
|
platforms = lib.platforms.linux;
|
|
|
|
maintainers = [ ];
|
|
|
|
broken = true; # Needs Picolib, which is not packaged in Nixpkgs.
|
2024-10-31 14:52:18 +00:00
|
|
|
};
|
2024-10-31 15:41:26 +00:00
|
|
|
})
|