-
Notifications
You must be signed in to change notification settings - Fork 52
/
Copy pathflake.nix
117 lines (104 loc) · 3.29 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
107
108
109
110
111
112
113
114
115
116
117
#
# Copyright 2024, UNSW
# SPDX-License-Identifier: BSD-2-Clause
#
{
description = "A flake for building microkit";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/24.05";
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;
}
);
aarch64-toolchain = import nixpkgs {
localSystem = "${system}";
crossSystem = {
config = "aarch64-none-elf";
};
};
# pyfdt is not officially supported in Nix so we compile it ourselves
pyfdt = with pkgs.python311Packages;
buildPythonPackage rec {
pname = "pyfdt";
version = "0.3";
src = pkgs.fetchFromGitHub {
owner = "superna9999";
repo = pname;
rev = "${pname}-${version}";
hash = "sha256-lt/Mcw3j1aTBVOVhDBSYtriDyzeJHcSli69EXLfsgDM=";
};
meta = with lib; {
description = "Python Flattened Device Tree Library";
homepage = "https://github.com/superna9999/pyfdt";
license = with licenses; [ asl20 ];
maintainers = with maintainers; [ wucke13 ];
};
};
pythonTool = pkgs.python311.withPackages (ps: [
ps.mypy
ps.black
ps.flake8
ps.ply
ps.jinja2
ps.pyaml
ps.lxml
pyfdt
ps.setuptools
]);
microkiToolToml = nixpkgs.lib.trivial.importTOML ./tool/microkit/Cargo.toml;
microkitToolVersion = microkiToolToml.package.rust-version;
rustTool = pkgs.rust-bin.stable.${microkitToolVersion}.default.override {
targets = [ pkgs.pkgsStatic.hostPlatform.rust.rustcTarget ];
};
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.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
pythonTool
git
rustTool
pandoc
(texlive.combine {
inherit (texlive) scheme-medium titlesec enumitem sfmath roboto fontaxes isodate substr tcolorbox environ pdfcol;
})
cmake
ninja
libxml2
];
};
});
}