forked from pq-code-package/mlkem-c-embedded
-
Notifications
You must be signed in to change notification settings - Fork 0
/
flake.nix
106 lines (88 loc) · 2.99 KB
/
flake.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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
# SPDX-License-Identifier: Apache-2.0
{
description = "mlkem-c-embedded";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-24.05";
esp-dev = {
url = "github:mirrexagon/nixpkgs-esp-dev?rev=86a2bbe01fe0258887de7396af2a5eb0e37ac3be";
inputs.nixpkgs.follows = "nixpkgs";
};
flake-parts = {
url = "github:hercules-ci/flake-parts";
inputs.nixpkgs-lib.follows = "nixpkgs";
};
};
outputs = inputs@{ flake-parts, esp-dev, ... }:
flake-parts.lib.mkFlake { inherit inputs; } {
imports = [ ];
systems = [ "x86_64-linux" "aarch64-linux" "aarch64-darwin" "x86_64-darwin" ];
perSystem = { pkgs, system, ... }:
let
core = builtins.attrValues {
astyle = pkgs.astyle.overrideAttrs (old: rec {
version = "3.4.13";
src = pkgs.fetchurl {
url = "mirror://sourceforge/${old.pname}/${old.pname}-${version}.tar.bz2";
hash = "sha256-eKYQq9OelOD5E+nuXNoehbtizWM1U97LngDT2SAQGc4=";
};
});
inherit (pkgs)
# formatter & linters
nixpkgs-fmt
shfmt
# build dependencies
qemu# 8.2.4
yq;
inherit (pkgs.python311Packages)
python
black
pyserial# 3.5
click;
};
arm-pkgs = builtins.attrValues {
libopencm3 = pkgs.callPackage ./libopencm3.nix {
targets = [ "stm32/f2" "stm32/f4" "stm32/f7" ];
};
mbed-os = pkgs.callPackage ./mbed-os.nix {
targets = [ "TARGET_MPS2_M3" "TARGET_MPS2_M4" "TARGET_MPS2_M7" ];
};
inherit (pkgs)
gcc-arm-embedded-13; # arm-gnu-toolchain-13.2.rel1
};
riscv-pkgs = builtins.attrValues {
esp-idf-lib = pkgs.callPackage ./esp-idf-lib.nix { };
};
wrapShell = mkShell: attrs:
mkShell (attrs // {
shellHook = ''
export PATH=$PWD/scripts:$PWD/scripts/ci:$PATH
'';
});
in
{
_module.args = {
pkgs = import inputs.nixpkgs {
inherit system;
overlays = [ esp-dev.overlays.default ];
};
};
devShells.default = wrapShell pkgs.mkShellNoCC {
packages = core ++ arm-pkgs ++ riscv-pkgs ++ builtins.attrValues {
inherit (pkgs)
direnv
nix-direnv
# debug dependencies
openocd; # 0.12.0
};
};
devShells.ci = wrapShell pkgs.mkShellNoCC {
packages = core ++ arm-pkgs ++ riscv-pkgs;
};
};
flake = {
# The usual flake attributes can be defined here, including system-
# agnostic ones like nixosModule and system-enumerating ones, although
# those are more easily expressed in perSystem.
};
};
}