Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
at devShellTools-shell 73 lines 1.9 kB view raw
1{ 2 lib, 3 stdenv, 4 fetchFromGitLab, 5 gcc-arm-embedded, 6 binutils-arm-embedded, 7 makeWrapper, 8 python3Packages, 9 10 # Default FSIJ IDs 11 vid ? "234b", 12 pid ? "0000", 13}: 14 15stdenv.mkDerivation (finalAttrs: { 16 pname = "gnuk"; 17 version = "2.2"; 18 19 src = fetchFromGitLab { 20 domain = "salsa.debian.org"; 21 owner = "gnuk-team"; 22 repo = "gnuk/gnuk"; 23 rev = "release/${finalAttrs.version}"; 24 hash = "sha256-qY/dwkcPJiPx/+inSxH7w7a0v3cWUQDX+NYJwUjnkMY="; 25 fetchSubmodules = true; 26 }; 27 28 nativeBuildInputs = [ 29 gcc-arm-embedded 30 binutils-arm-embedded 31 makeWrapper 32 ]; 33 34 buildInputs = with python3Packages; [ 35 python 36 pyusb 37 colorama 38 ]; 39 40 sourceRoot = "${finalAttrs.src.name}/src"; 41 42 configureFlags = [ "--vidpid=${vid}:${pid}" ]; 43 44 # TODO: Check how many of these patches are actually needed. 45 installPhase = '' 46 mkdir -p $out/bin 47 48 find . -name gnuk.bin -exec cp {} $out \; 49 50 #sed -i 's,Exception as e,IOError as e,' ../tool/stlinkv2.py 51 sed -i ../tool/stlinkv2.py \ 52 -e "1a import array" \ 53 -e "s,\(data_received =\) (),\1 array.array('B'),g" \ 54 -e "s,\(data_received\) = data_received + \(.*\),\1.extend(\2),g" 55 cp ../tool/stlinkv2.py $out/bin/stlinkv2 56 wrapProgram $out/bin/stlinkv2 --prefix PYTHONPATH : "$PYTHONPATH" 57 58 # Some useful helpers 59 echo "#! ${stdenv.shell} -e" | tee $out/bin/{unlock,flash} 60 echo "$out/bin/stlinkv2 -u \$@" >> $out/bin/unlock 61 echo "$out/bin/stlinkv2 -b \$@ $out/gnuk.bin" >> $out/bin/flash 62 chmod +x $out/bin/{unlock,flash} 63 ''; 64 65 meta = { 66 homepage = "https://www.fsij.org/category/gnuk.html"; 67 description = "Implementation of USB cryptographic token for gpg"; 68 license = lib.licenses.gpl3; 69 platforms = lib.platforms.linux; 70 maintainers = [ ]; 71 broken = true; # Needs Picolib, which is not packaged in Nixpkgs. 72 }; 73})