forked from pq-code-package/mlkem-c-embedded
-
Notifications
You must be signed in to change notification settings - Fork 0
/
libopencm3.nix
54 lines (49 loc) · 1.19 KB
/
libopencm3.nix
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# SPDX-License-Identifier: Apache-2.0
{ lib
, stdenvNoCC
, fetchFromGitHub
, writeText
, python311
, gcc-arm-embedded-13
, targets ? [ ]
}:
stdenvNoCC.mkDerivation rec {
pname = "libopencm3";
version = "ec5aeba354ec273782e4441440fe9000b1c965e3";
src = fetchFromGitHub {
owner = "libopencm3";
repo = pname;
rev = "ec5aeba354ec273782e4441440fe9000b1c965e3";
sha256 = "sha256-bgoMhOhBJZwPTa9gUH0vPSGZknDrb2mJZuFlCWNivYU=";
};
setupHook = writeText "setup-hook.sh" ''
export OPENCM3_DIR="$1"
'';
buildInputs = [
python311
gcc-arm-embedded-13 # arm-gnu-toolchain-13.2.rel1
];
postPatch = ''
patchShebangs --build scripts/irq2nvic_h
'';
dontConfigure = true;
buildPhase = ''
make ${if targets == [] then "lib" else "TARGETS='${lib.concatMapStrings (t: t + " ") targets}'"}
'';
installPhase = ''
runHook preInstall
mkdir -p $out
cp -r include/ $out/
cp -r ld/ $out/
cp -r lib/ $out/
cp -r mk/ $out/
cp -r scripts/ $out/
runHook postInstall
'';
dontStrip = true;
noAuditTmpdir = true;
meta = {
description = "Open source ARM Cortex-M microcontroller library";
homepage = "https://libopencm3.org/";
};
}