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-2L7+k/tgI6trkstDTY4xxfFzmNDlxbCHDRKAFaERQeM=";
10 version = "5.0a";
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 python3 ];
21 enableParallelBuilding = true;
22 env.NIX_CFLAGS_COMPILE = toString [ "-Wno-error=deprecated-declarations" ]; # Needed with GCC 12
23 };
24
25 ## symlink farm for --sysroot flag
26 sysroot = runCommand "systemtap-sysroot-${kernel.version}" { } ''
27 mkdir -p $out/boot $out/usr/lib/debug
28 ln -s ${kernel.dev}/vmlinux ${kernel.dev}/lib $out
29 ln -s ${kernel.dev}/vmlinux $out/usr/lib/debug
30 ln -s ${kernel}/System.map $out/boot/System.map-${kernel.version}
31 '';
32
33 pypkgs = with python3.pkgs; makePythonPath [ pyparsing ];
34
35in runCommand "systemtap-${kernel.version}-${version}" {
36 inherit stapBuild;
37 nativeBuildInputs = [ makeWrapper ];
38 meta = {
39 homepage = "https://sourceware.org/systemtap/";
40 description = "Provides a scripting language for instrumentation on a live kernel plus user-space";
41 license = lib.licenses.gpl2;
42 platforms = lib.systems.inspect.patterns.isGnu;
43 };
44} ''
45 mkdir -p $out/bin
46 for bin in $stapBuild/bin/*; do
47 ln -s $bin $out/bin
48 done
49 rm $out/bin/stap $out/bin/dtrace
50 makeWrapper $stapBuild/bin/stap $out/bin/stap \
51 --add-flags "--sysroot ${sysroot}" \
52 --prefix PATH : ${lib.makeBinPath [ stdenv.cc.cc stdenv.cc.bintools elfutils gnumake ]}
53 makeWrapper $stapBuild/bin/dtrace $out/bin/dtrace \
54 --prefix PYTHONPATH : ${pypkgs}
55''