-
Notifications
You must be signed in to change notification settings - Fork 73
Expand file tree
/
Copy pathflake.nix
More file actions
115 lines (103 loc) · 3.47 KB
/
flake.nix
File metadata and controls
115 lines (103 loc) · 3.47 KB
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
107
108
109
110
111
112
113
114
115
#
# Copyright 2024, UNSW
# SPDX-License-Identifier: BSD-2-Clause
#
{
description = "A flake for building microkit";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/25.11";
utils.url = "github:numtide/flake-utils";
rust-overlay.url = "github:oxalica/rust-overlay";
treefmt-nix = {
url = "github:numtide/treefmt-nix";
inputs.nixpkgs.follows = "nixpkgs";
};
};
outputs = { self, nixpkgs, rust-overlay, treefmt-nix, ... }@inputs: inputs.utils.lib.eachSystem [
"x86_64-linux"
"aarch64-linux"
"x86_64-darwin"
"aarch64-darwin"
]
(system:
let
pkgs = import nixpkgs {
inherit system;
overlays = [ (import rust-overlay) ];
};
treefmtEval = treefmt-nix.lib.evalModule pkgs (
{ ... }:
{
projectRootFile = "flake.nix";
programs.nixpkgs-fmt.enable = true;
}
);
python = pkgs.python312;
pythonPackages = python.withPackages (ps: [
ps.mypy
ps.black
ps.flake8
ps.ply
ps.jinja2
ps.pyaml
ps.lxml
ps.pyfdt
ps.setuptools
]);
microkitToolToml = nixpkgs.lib.trivial.importTOML ./tool/microkit/Cargo.toml;
microkitToolVersion = microkitToolToml.package.rust-version;
# Unfortunately Cargo does not support all targets by default so for cross-compiling
# we must explicitly add certain targets.
rustAdditionalTargets = {
aarch64-darwin = [ "x86_64-apple-darwin" "x86_64-unknown-linux-musl" "aarch64-unknown-linux-musl" ];
x86_64-darwin = [ "aarch64-apple-darwin" "x86_64-unknown-linux-musl" "aarch64-unknown-linux-musl" ];
x86_64-linux = [];
aarch64-linux = [];
}.${system} or (throw "Unsupported system: ${system}");
# For the initialiser
crossTargets = [
"aarch64-unknown-none"
"riscv64gc-unknown-none-elf"
"x86_64-unknown-none"
];
rustTool = pkgs.rust-bin.stable.${microkitToolVersion}.default.override {
extensions = [ "rust-src" ];
targets = [ pkgs.pkgsStatic.stdenv.hostPlatform.rust.rustcTarget ] ++ rustAdditionalTargets ++ crossTargets;
};
in
{
# for `nix fmt`
formatter = treefmtEval.config.build.wrapper;
# for `nix flake check`
checks.formatting = treefmtEval.config.build.check self;
devShells.default = pkgs.mkShell rec {
name = "microkit-shell";
nativeBuildInputs = with pkgs; [
pkgsCross.x86_64-embedded.stdenv.cc.bintools.bintools
pkgsCross.x86_64-embedded.stdenv.cc.cc
pkgsCross.aarch64-embedded.stdenv.cc.bintools.bintools
pkgsCross.aarch64-embedded.stdenv.cc.cc
pkgsCross.riscv64-embedded.stdenv.cc.bintools.bintools
pkgsCross.riscv64-embedded.stdenv.cc.cc
gnumake
dtc
expect
python
pythonPackages
git
rustTool
pandoc
(texlive.combine {
inherit (texlive) scheme-small fancyvrb parskip titlesec enumitem sfmath roboto fontaxes isodate substr tcolorbox environ pdfcol;
})
cmake
ninja
libxml2
qemu
gnutar
];
# Necessary for Rust bindgen
LIBCLANG_PATH = "${pkgs.llvmPackages_18.libclang.lib}/lib";
};
});
}