-
Notifications
You must be signed in to change notification settings - Fork 72
Expand file tree
/
Copy pathflake.nix
More file actions
133 lines (113 loc) · 3.36 KB
/
flake.nix
File metadata and controls
133 lines (113 loc) · 3.36 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
{
description = "gem5 - a modular platform for computer-system architecture research";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-25.05";
flake-utils.url = "github:numtide/flake-utils";
};
outputs = { self, nixpkgs, flake-utils }:
flake-utils.lib.eachDefaultSystem (system:
let
pkgs = import nixpkgs {
inherit system;
};
python = pkgs.python310;
pythonPackages = python.pkgs;
# Create a scons based on python310
# pybind used in current version of gem5 need python <= 3.10
scons = pkgs.scons.override {
python3Packages = pythonPackages;
};
# gem5 dependencies
buildInputs = with pkgs; [
boost
cmake
gflags
glog
gnum4
gnumake
gperftools
gtest
libelf
libffi
libpng
libtool
m4
ninja
pkg-config
python
pythonPackages.distutils
pythonPackages.pydot
pythonPackages.six
scons
sqlite
swig
zlib
zstd # xs-gem5 zstd checkpoint
# The following dependencies are optional and seldom used
# protobuf # protobuf version is strictly enforced by gem5, not sure which version
# hdf5
];
# Development tools
devTools = with pkgs; [
# Build & Development Tools
gdb
mold # Faster linking
# bintools # gold linker
ccache
git
valgrind
pythonPackages.pyupgrade
pythonPackages.pyyaml
glibcLocales
# LSP
pyright # Python LSP
# ruff # Python formatter
clang-tools # C++
nixd # LSP of This file
nixpkgs-fmt # Nix formatter
];
in
{
packages.default = pkgs.stdenv.mkDerivation {
pname = "gem5";
version = "1.0.0";
src = self;
enableParallelBuilding = true;
inherit buildInputs;
patchPhase = ''
patchShebangs --build util/cpt_upgrader.py
'';
# Disable the automatic cmake configuration
dontUseCmakeConfigure = true;
# Disable standard configure
dontConfigure = true;
# Not intended for official build flow
# Hard-code RISCV and opt for now
buildPhase = ''
scons -j $NIX_BUILD_CORES build/RISCV/gem5.opt
'';
installPhase = ''
mkdir -p $out/bin
cp -a build/*/gem5.opt $out/bin
'';
};
devShells.default = pkgs.mkShell.override
{
stdenv = pkgs.stdenvAdapters.useMoldLinker (pkgs.stdenvAdapters.overrideCC pkgs.stdenv pkgs.clang);
}
{
inherit buildInputs;
nativeBuildInputs = devTools;
# Disable hardening, FORTIFY is causing problem when building debug version without optimization
hardeningDisable = [ "all" ];
# Prebuilt NEMU need libstdc++, give it libstdc++
shellHook = ''
export LD_LIBRARY_PATH=${pkgs.lib.makeLibraryPath [
pkgs.stdenv.cc.cc
]}
'';
};
formatter = pkgs.nixpkgs-fmt;
}
);
}