blob: a578257b013941f053473d09be6c8dd017f438a4 (
plain)
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
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
|
{
description = "Kernel development environments";
inputs = {
systems.url = "github:nix-systems/default-linux";
nixpkgs.url = "github:nixos/nixpkgs?ref=nixos-unstable";
flake-utils = {
url = "github:numtide/flake-utils";
inputs.systems.follows = "systems";
};
rust-overlay = {
url = "github:oxalica/rust-overlay";
inputs.nixpkgs.follows = "nixpkgs";
};
fenix = {
url = "github:nix-community/fenix";
inputs.nixpkgs.follows = "nixpkgs";
};
};
outputs = { self, nixpkgs, rust-overlay, fenix, flake-utils, ... }:
flake-utils.lib.eachDefaultSystem (system:
let
pkgs = nixpkgs.legacyPackages."${system}";
# A set of scripts to simplify kernel development.
kernelDevTools = pkgs.callPackage ./tools.nix {
flakeSelf = self.outPath;
};
linuxCommonDependencies = [
kernelDevTools
] ++ (with pkgs; [
gnumake
perl
bison
flex
gmp
libmpc
mpfr
pahole
nettools
bc
rsync
openssl
cpio
elfutils
zstd
python3Minimal
zlib
kmod
ubootTools
# htmldocs
sphinx
python312Packages.pyyaml
graphviz
# For make menuconfig
ncurses
# For make gtags
global
# For git send-email ðŸ«
gitFull
]);
rust-analyzer = fenix.packages."${system}".rust-analyzer;
linuxRustDependencies = { clang, rustVersion }:
let
rustc = rust-overlay.packages."${system}"."${rustVersion}".override {
extensions = [
"rust-src"
"rustfmt"
"clippy"
];
};
rustPlatform = pkgs.makeRustPlatform {
cargo = rustc;
rustc = rustc;
};
bindgenUnwrapped = pkgs.callPackage ./bindgen/0.65.1.nix {
inherit rustPlatform clang;
};
bindgen = pkgs.rust-bindgen.override {
rust-bindgen-unwrapped = bindgenUnwrapped;
};
in
[
rustc
bindgen
rust-analyzer
];
mkGccShell = { gccVersion }: pkgs.mkShell {
packages =
linuxCommonDependencies
++ [ pkgs."gcc${gccVersion}" ];
# Disable all automatically applied hardening. The Linux
# kernel will take care of itself.
NIX_HARDENING_ENABLE = "";
};
mkClangShell = { clangVersion, rustcVersion }:
let
llvmPackages = pkgs."llvmPackages_${clangVersion}";
in
pkgs.mkShell {
packages =
(with llvmPackages;
[
bintools
llvm
clang
])
++ (linuxRustDependencies {
inherit (llvmPackages) clang;
rustVersion = "rust_${rustcVersion}";
})
++ linuxCommonDependencies;
# To force LLVM build mode. This should create less problems
# with Rust interop.
LLVM = "1";
# Disable all automatically applied hardening. The Linux
# kernel will take care of itself.
NIX_HARDENING_ENABLE = "";
};
in
{
packages = {
default = kernelDevTools;
inherit kernelDevTools;
};
devShells = {
default = self.devShells."${system}".linux_6_12;
linux_6_6 = mkClangShell { clangVersion = "19"; rustcVersion = "1_78_0"; };
linux_6_6_gcc = mkGccShell { gccVersion = "14"; };
linux_6_11 = mkClangShell { clangVersion = "19"; rustcVersion = "1_78_0"; };
linux_6_11_gcc = mkGccShell { gccVersion = "14"; };
linux_6_12 = mkClangShell { clangVersion = "19"; rustcVersion = "1_82_0"; };
linux_6_12_gcc = mkGccShell { gccVersion = "14"; };
};
});
}
|