summaryrefslogtreecommitdiff
path: root/pkgs
diff options
context:
space:
mode:
authorAlejandro Soto <alejandro@34project.org>2023-06-13 00:40:16 -0600
committerAlejandro Soto <alejandro@34project.org>2023-06-13 00:40:16 -0600
commit04b6e1fa94ebfa2b788875515dcf66de98d0fb3f (patch)
tree64275cd8a9f54eebb68a411c642dc0c3c8e68d5b /pkgs
parent31a416967a3a9765023d3bcdab14c72f4e79d32d (diff)
pkgs/gem5: initial commit
Diffstat (limited to '')
-rw-r--r--pkgs/default.nix1
-rw-r--r--pkgs/gem5.nix64
2 files changed, 65 insertions, 0 deletions
diff --git a/pkgs/default.nix b/pkgs/default.nix
index 9f161fa..f220934 100644
--- a/pkgs/default.nix
+++ b/pkgs/default.nix
@@ -4,6 +4,7 @@ let
in
{
btclone = callPackage ./btclone { };
+ gem5 = callPackage ./gem5.nix { gem5ISA = "x86"; };
git-aliases = callPackage ./git-aliases.nix { };
kbuild-standalone = callPackage ./kbuild-standalone.nix { };
mssql-tools = callPackage ./mssql-tools.nix { };
diff --git a/pkgs/gem5.nix b/pkgs/gem5.nix
new file mode 100644
index 0000000..f9aebd7
--- /dev/null
+++ b/pkgs/gem5.nix
@@ -0,0 +1,64 @@
+{ boost
+, lib
+, fetchFromGitHub
+, gnum4
+, gperftools
+, hdf5-cpp
+, libpng
+, protobuf
+, scons
+, stdenv
+, zlib
+, enableHdf5 ? true
+, enableLibpng ? true
+, enableTrace ? true
+, enableSystemC ? true
+, enableTcmalloc ? true
+, gem5ISA
+}:
+let
+ version = "22.1.0.0";
+
+ isa = assert lib.assertMsg (lib.elem gem5ISA [ "arm" "null" "mips" "power" "x86" ])
+ "${gem5ISA} is not a valid gem5 target ISA";
+ lib.toUpper gem5ISA;
+
+ target = "build/${isa}/gem5.opt";
+in
+stdenv.mkDerivation {
+ pname = "gem5";
+ version = "${gem5ISA}-${version}";
+
+ src = fetchFromGitHub {
+ repo = "gem5";
+ owner = "gem5";
+
+ rev = "v${version}";
+ sha256 = "sha256-Yxag8emR6hf7oX4GAtQi/YYcKrpXicUoQg5+rjKyjc0=";
+ };
+
+ buildInputs = [ zlib ]
+ ++ lib.optional enableHdf5 hdf5-cpp
+ ++ lib.optional enableLibpng libpng
+ ++ lib.optional enableTrace boost
+ ++ lib.optional enableSystemC protobuf
+ ++ lib.optional enableTcmalloc gperftools;
+
+ nativeBuildInputs = [ gnum4 scons ];
+
+ sconsFlags = [ target ];
+
+ enableParallelBuilding = true;
+
+ # Without this we get "ValueError: invalid width 0 (must be > 0)"
+ COLUMNS = 80;
+
+ postPatch = ''
+ patchShebangs util/
+ '';
+
+ installPhase = ''
+ mkdir -p $out/bin/
+ cp ${target} $out/bin/
+ '';
+}