forked from rex-rs/rex
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathflake.nix
140 lines (121 loc) · 3.56 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
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
{
description = "A flake for the REX project";
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
};
outputs = { self, nixpkgs, ... }:
let
system = "x86_64-linux";
pkgs = import nixpkgs {
inherit system;
# overlays = overlays;
};
wrapCC = cc: pkgs.wrapCCWith {
inherit cc;
extraBuildCommands = ''
# Remove the line that contains "-nostdlibinc"
sed -i 's|-nostdlibinc||g' "$out/nix-support/cc-cflags"
echo " -resource-dir=${pkgs.llvmPackages.clang}/resource-root" >> "$out/nix-support/cc-cflags"
echo > "$out/nix-support/add-local-cc-cflags-before.sh"
'';
};
wrappedClang = wrapCC pkgs.llvmPackages.clang.cc;
lib = nixpkgs.lib;
# Use unwrapped clang & lld to avoid warnings about multi-target usage
rexPackages = with pkgs; [
# Kernel builds
autoconf
bc
binutils
bison
cmake
diffutils
elfutils
elfutils.dev
fakeroot
flex
gcc
glibc.dev
getopt
gnumake
ncurses
openssl.dev
pahole
pkg-config
xz.dev
zlib
zlib.dev
ninja
rust-bindgen
pahole
strace
zstd
eza
linuxKernel.packages.linux_latest_libre.perf
# Clang kernel builds
# llvmPackages.clang
# llvmPackages.clang
wrappedClang
# llvmPackages.libcxxStdenv
lld
mold
# llvmPackages.bintools
qemu
busybox
perf-tools
# for llvm/Demangle/Demangle.h
libllvm
libllvm.dev
libgcc
libclang.lib
libclang.dev
bear # generate compile commands
rsync # for make headers_install
gdb
# bmc deps
iproute2
memcached
# python3 scripts
(pkgs.python3.withPackages
(python-pkgs: (with python-pkgs; [
# select Python packages here
tqdm
])))
zoxide # in case host is using zoxide
openssh # q-script ssh support
];
# (pkgs.buildFHSEnv.override { stdenv = pkgs.llvmPackages.stdenv; })
fhs = (pkgs.buildFHSEnv.override { stdenv = pkgs.llvmPackages.stdenv; })
{
name = "rex-env";
targetPkgs = pkgs: rexPackages;
runScript = "./scripts/start.sh";
# NIX_CFLAGS_COMPILE = lib.strings.makeLibraryPath [ ] + " -isystem ${pkgs.libclang.lib}/lib/clang/19/include";
profile = ''
export LD_LIBRARY_PATH=${pkgs.libgcc.lib}/lib:$LD_LIBRARY_PATH
export LIBCLANG_PATH="${pkgs.libclang.lib}/lib/libclang.so"
export NIX_ENFORCE_NO_NATIVE=0
'';
};
in
{
devShells."${system}" = {
default = fhs.env;
rex = pkgs.mkShell {
packages = rexPackages;
# Disable default hardening flags. These are very confusing when doing
# development and they break builds of packages/systems that don't
# expect these flags to be on. Automatically enables stuff like
# FORTIFY_SOURCE, -Werror=format-security, -fPIE, etc. See:
# - https://nixos.org/manual/nixpkgs/stable/#sec-hardening-in-nixpkgs
# - https://nixos.wiki/wiki/C#Hardening_flags
hardeningDisable = [ "all" ];
shellHook = ''
echo "loading rex env"
source ./scripts/env.sh
export NIX_ENFORCE_NO_NATIVE=0
'';
};
};
};
}