1{ lib, fetchgit, pkg-config, gettext, runCommand, makeWrapper
2, cpio, elfutils, kernel, gnumake, python3
3}:
4
5let
6 ## fetchgit info
7 url = "git://sourceware.org/git/systemtap.git";
8 rev = "release-${version}";
9 sha256 = "sha256-UiUMoqdfkk6mzaPGctpQW3dvOWKhNBNuScJ5BpCykVg=";
10 version = "4.8";
11
12 inherit (kernel) stdenv;
13
14 ## stap binaries
15 stapBuild = stdenv.mkDerivation {
16 pname = "systemtap";
17 inherit version;
18 src = fetchgit { inherit url rev sha256; };
19 nativeBuildInputs = [ pkg-config cpio python3 python3.pkgs.setuptools ];
20 buildInputs = [ elfutils gettext ];
21 enableParallelBuilding = true;
22 env.NIX_CFLAGS_COMPILE = toString [ "-Wno-error=deprecated-declarations" ]; # Needed with GCC 12
23 };
24
25 pypkgs = with python3.pkgs; makePythonPath [ pyparsing ];
26
27in runCommand "systemtap-${kernel.version}-${version}" {
28 inherit stapBuild;
29 nativeBuildInputs = [ makeWrapper ];
30 meta = {
31 homepage = "https://sourceware.org/systemtap/";
32 description = "Provides a scripting language for instrumentation on a live kernel plus user-space";
33 license = lib.licenses.gpl2;
34 platforms = lib.systems.inspect.patterns.isGnu;
35 };
36} ''
37 mkdir -p $out/bin
38 for bin in $stapBuild/bin/*; do
39 ln -s $bin $out/bin
40 done
41 rm $out/bin/stap $out/bin/dtrace
42 makeWrapper $stapBuild/bin/stap $out/bin/stap \
43 --add-flags "-r ${kernel.dev}" \
44 --prefix PATH : ${lib.makeBinPath [ stdenv.cc.cc stdenv.cc.bintools elfutils gnumake ]}
45 makeWrapper $stapBuild/bin/dtrace $out/bin/dtrace \
46 --prefix PYTHONPATH : ${pypkgs}
47''