base16-schemes: unstable-2024-06-21 -> unstable-2024-11-12
[NixPkgs.git] / pkgs / by-name / ni / nitrokey-storage-firmware / package.nix
blob51d448ee808c8c28f9131d529008406fd11c8223
2   lib,
3   stdenv,
4   fetchzip,
5   fetchFromGitHub,
6 }:
7 let
8   pname = "nitrokey-storage-firmware";
9   version = "0.57";
11   src = fetchFromGitHub {
12     owner = "Nitrokey";
13     repo = "nitrokey-storage-firmware";
14     rev = "V${version}";
15     hash = "sha256-u8IK57NVS/IOPIE3Ah/O8WuOIr0EY6AF1bEaeDgIBuk=";
16   };
18   toolchain = stdenv.mkDerivation (finalAttrs: {
19     pname = "avr32-toolchain";
20     version = "3.0.0.201009140852";
22     src = fetchzip {
23       url = "https://ww1.microchip.com/downloads/archive/avr32studio-ide-2.6.0.753-linux.gtk.x86_64.zip";
24       hash = "sha256-MwsaGyNqbO0lBy1rcczuvKOaGbO3f0V+j84sUCkRlxc=";
25     };
27     postPatch = ''
28       cp ${src}/pm_240.h plugins/com.atmel.avr.toolchains.linux.x86_64_${finalAttrs.version}/os/linux/x86_64/avr32/include/avr32/pm_231.h
29     '';
31     installPhase = ''
32       runHook preInstall
33       cp -r plugins/com.atmel.avr.toolchains.linux.x86_64_${finalAttrs.version}/os/linux/x86_64 $out
34       rm -r $out/avr $out/bin/avr-*
35       runHook postInstall
36     '';
38     meta = {
39       description = "AVR32 toolchain";
40       homepage = "https://web.archive.org/web/20210419192039/https://www.microchip.com/mplab/avr-support/avr-and-sam-downloads-archive";
41       # The zip does not explicitly say this,
42       # it only mentions the license(s) of AVR32 Studio.
43       # Because it is very clearly a fork of GCC 4.3.3,
44       # it should be licensed under GPLv2+
45       license = lib.licenses.gpl2Plus;
46       platforms = [ "x86_64-linux" ];
47     };
48   });
50 stdenv.mkDerivation {
51   inherit pname version src;
53   sourceRoot = "source/src";
55   postPatch = ''
56     substituteInPlace Makefile \
57       --replace-fail '$(shell git describe)' "V${version}"
58   '';
60   makeFlags = [
61     "CC=${toolchain}/bin/avr32-gcc"
62     "nitrokey-storage-V${version}-reproducible.hex"
63   ];
65   enableParallelBuilding = true;
67   installPhase = ''
68     runHook preInstall
69     install -D nitrokey-storage-V${version}-reproducible.hex $out/nitrokey-storage-V${version}-reproducible.hex
70     runHook postInstall
71   '';
73   meta = {
74     description = "Firmware for the Nitrokey Storage device";
75     homepage = "https://github.com/Nitrokey/nitrokey-storage-firmware";
76     license = lib.licenses.gpl3Plus;
77     maintainers = with lib.maintainers; [
78       imadnyc
79       kiike
80       amerino
81     ];
82     platforms = [ "x86_64-linux" ];
83   };