blob: c97c0331ab42d7894859c67264d8b722f1cc3d27 (
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
|
{
description = "BPF-based scheduler using sched-ext";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
flake-utils.url = "github:numtide/flake-utils";
rust-overlay = {
url = "github:oxalica/rust-overlay";
inputs = {
nixpkgs.follows = "nixpkgs";
flake-utils.follows = "flake-utils";
};
};
};
outputs = { self, nixpkgs, flake-utils, rust-overlay }:
flake-utils.lib.eachDefaultSystem (system:
let
overlays = [ (import rust-overlay) ];
pkgs = import nixpkgs {
inherit system overlays;
config = {
hardeningDisable = [ "stackprotector" "zerocallusedregs" ];
};
};
# Use a stable rust with specific components
rustVersion = pkgs.rust-bin.stable.latest.default.override {
extensions = [ "rust-src" "rust-analyzer" "clippy" "rustfmt" ];
};
# Python with ML dependencies
pythonEnv = pkgs.python3.withPackages (ps: with ps; [
pandas
numpy
scikit-learn
matplotlib
pytorch
]);
# Dependencies based on scx_rustscheds
nativeBuildInputs = with pkgs; [
pkg-config
rustVersion
llvmPackages.clang
bpftools # bpftool
pythonEnv # Add Python environment
];
buildInputs = with pkgs; [
elfutils
zlib
zstd
libbpf
];
# Environment variables needed for compilation
shellEnv = {
LIBCLANG_PATH = "${pkgs.lib.getLib pkgs.llvmPackages.libclang}/lib";
BPF_CLANG = pkgs.lib.getExe pkgs.llvmPackages.clang;
BPF_EXTRA_CFLAGS_PRE_INCL = pkgs.lib.concatStringsSep " " [
"-I${pkgs.libbpf}/include"
"-I${pkgs.libbpf}/include/uapi"
"-I${pkgs.libbpf}/include/linux"
];
BPF_EXTRA_CFLAGS = "-fno-stack-protector";
RUSTFLAGS = pkgs.lib.concatStringsSep " " [
"-C relocation-model=pic"
"-C link-args=-lelf"
"-C link-args=-lz"
"-C link-args=-lzstd"
"-L ${pkgs.libbpf}/lib"
];
};
in
{
# Development shell with all dependencies
devShells.default = pkgs.mkShell {
inherit nativeBuildInputs buildInputs;
inherit (shellEnv) LIBCLANG_PATH BPF_CLANG BPF_EXTRA_CFLAGS_PRE_INCL BPF_EXTRA_CFLAGS RUSTFLAGS;
hardeningDisable = [ "stackprotector" "zerocallusedregs" ];
# Additional development tools
packages = with pkgs; [
cargo-watch
cargo-expand
samply
just
];
# Shell hook to print some useful info
shellHook = ''
echo "BPF scheduler development environment"
echo "Kernel: $(uname -r)"
echo "Rust: $(rustc --version)"
echo "Clang: $(clang --version | head -n1)"
echo "Python: $(python --version)"
'';
};
});
}
|