From f5d40dac128fb0f77b2d73ec70f3673b465e02c6 Mon Sep 17 00:00:00 2001 From: Enric Morales Date: Wed, 28 Aug 2024 15:20:40 +0000 Subject: [PATCH] nitrokey-pro-firmware: init at 0.15 Co-authored-by: Simon Bruder Co-authored-by: Abdullah Imad Co-authored-by: Alberto Merino Co-authored-by: Enric Morales Co-authored-by: Jack Leightcap Co-authored-by: Roland Coeurjoly --- .../ni/nitrokey-pro-firmware/package.nix | 61 +++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 pkgs/by-name/ni/nitrokey-pro-firmware/package.nix diff --git a/pkgs/by-name/ni/nitrokey-pro-firmware/package.nix b/pkgs/by-name/ni/nitrokey-pro-firmware/package.nix new file mode 100644 index 000000000000..8c14178fc744 --- /dev/null +++ b/pkgs/by-name/ni/nitrokey-pro-firmware/package.nix @@ -0,0 +1,61 @@ +{ + lib, + stdenv, + fetchFromGitHub, + writeShellScriptBin, + python3, + srecord, + gcc-arm-embedded, +}: + +let + version = "0.15"; + + # The firmware version is pulled from `git` so we stub it here to avoid pulling the whole program. + fakeGit = writeShellScriptBin "git" '' + echo "${version}.nitrokey" + ''; + +in + +stdenv.mkDerivation { + pname = "nitrokey-pro-firmware"; + inherit version; + src = fetchFromGitHub { + owner = "Nitrokey"; + repo = "nitrokey-pro-firmware"; + rev = "v${version}"; + hash = "sha256-q+kbEOLA05xR6weAWDA1hx4fVsaN9UNKiOXGxPRfXuI="; + fetchSubmodules = true; + }; + + postPatch = '' + patchShebangs dapboot/libopencm3/scripts + ''; + + nativeBuildInputs = [ + fakeGit + gcc-arm-embedded + python3 + srecord + ]; + + installPhase = '' + runHook preInstall + install -D build/gcc/bootloader.hex $out/bootloader.hex + install -D build/gcc/nitrokey-pro-firmware.hex $out/firmware.hex + runHook postInstall + ''; + + meta = { + description = "Firmware for the Nitrokey Pro device"; + homepage = "https://github.com/Nitrokey/nitrokey-pro-firmware"; + license = lib.licenses.gpl3Plus; + maintainers = with lib.maintainers; [ + imadnyc + kiike + amerino + ]; + platforms = lib.platforms.unix; + }; +}