-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathflake.nix
More file actions
157 lines (146 loc) · 4.42 KB
/
flake.nix
File metadata and controls
157 lines (146 loc) · 4.42 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
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
{
description = "Bitcoin development environment with tools for building, testing, and debugging";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
flake-utils.url = "github:numtide/flake-utils";
};
outputs =
{
nixpkgs,
flake-utils,
...
}:
flake-utils.lib.eachDefaultSystem (
system:
let
pkgs = import nixpkgs {
inherit system;
};
inherit (pkgs) lib;
inherit (pkgs.stdenv) isLinux isDarwin;
python = pkgs.python313;
llvmPackages = pkgs.llvmPackages_latest;
clang-tidy-diff =
pkgs.runCommand "clang-tidy-diff"
{
nativeBuildInputs = [ pkgs.makeWrapper ];
}
''
mkdir -p $out/bin
cp ${llvmPackages.clang-unwrapped.src}/clang-tools-extra/clang-tidy/tool/clang-tidy-diff.py \
$out/bin/clang-tidy-diff
chmod +x $out/bin/clang-tidy-diff
wrapProgram $out/bin/clang-tidy-diff \
--prefix PATH : ${
lib.makeBinPath [
pkgs.clang-tools
pythonEnv
]
}
'';
patchelf-releases = pkgs.writeShellApplication {
name = "patchelf-releases";
runtimeInputs = with pkgs; [
patchelf
file
findutils
gnugrep
];
text = builtins.replaceStrings [ "@interp@" ] [ "${pkgs.glibc}/lib/ld-linux-x86-64.so.2" ] (
builtins.readFile ./scripts/patchelf-releases.sh
);
};
stdEnv =
let
llvmStdenv =
if isLinux then
llvmPackages.stdenv.override {
cc = llvmPackages.stdenv.cc.override {
bintools = llvmPackages.bintools;
};
}
else
llvmPackages.stdenv;
in
let
moldStdenv = if isLinux then pkgs.stdenvAdapters.useMoldLinker llvmStdenv else llvmStdenv;
in
pkgs.ccacheStdenv.override { stdenv = moldStdenv; };
pythonEnv = python.withPackages (
ps:
with ps;
[
flake8
lief
mypy
pyzmq
pycapnp
requests
]
++ lib.optionals isLinux [
bcc
]
);
# Will only exist in the build environment
nativeBuildInputs = [
pkgs.bison
pkgs.ccache
pkgs.clang-tools
pkgs.cmakeCurses
pkgs.curlMinimal
pkgs.ninja
pkgs.pkg-config
pkgs.xz
]
++ lib.optionals isLinux [
pkgs.libsystemtap
pkgs.linuxPackages.bcc
pkgs.linuxPackages.bpftrace
];
# Will exist in the runtime environment
buildInputs = [
pkgs.boost
pkgs.capnproto
pkgs.libevent
pkgs.sqlite.dev
pkgs.zeromq
];
mkDevShell =
nativeInputs: buildInputs:
(pkgs.mkShell.override { stdenv = stdEnv; }) {
nativeBuildInputs = nativeInputs;
inherit buildInputs;
hardeningDisable = lib.optionals isDarwin [ "stackclashprotection" ];
packages = [
clang-tidy-diff
pkgs.codespell
pkgs.doxygen
pkgs.hexdump
pkgs.include-what-you-use
pkgs.ruff
pkgs.ty
pythonEnv
]
++ lib.optionals isLinux [
patchelf-releases
pkgs.gdb
pkgs.valgrind
]
++ lib.optionals isDarwin [ llvmPackages.lldb ];
CMAKE_GENERATOR = "Ninja";
CMAKE_EXPORT_COMPILE_COMMANDS = 1;
LD_LIBRARY_PATH = lib.makeLibraryPath [ pkgs.capnproto ];
LOCALE_ARCHIVE = lib.optionalString isLinux "${pkgs.glibcLocales}/lib/locale/locale-archive";
# Force depends capnp to also use clang, otherwise it fails when
# looking for the default (gcc/g++)
build_CC = "clang";
build_CXX = "clang++";
};
in
{
devShells.default = mkDevShell nativeBuildInputs buildInputs;
devShells.depends = mkDevShell nativeBuildInputs [ ];
formatter = pkgs.nixfmt-tree;
}
);
}