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-3LgqMBCnUG2UmsekaIvV43lBpSPEocEXmFV9WpE7wE0=";
10 version = "4.5";
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 };
23
24 ## a kernel build dir as expected by systemtap
25 kernelBuildDir = runCommand "kbuild-${kernel.version}-merged" { } ''
26 mkdir -p $out
27 for f in \
28 ${kernel}/System.map \
29 ${kernel.dev}/vmlinux \
30 ${kernel.dev}/lib/modules/${kernel.modDirVersion}/build/{*,.*}
31 do
32 ln -s $(readlink -f $f) $out
33 done
34 '';
35
36 pypkgs = with python3.pkgs; makePythonPath [ pyparsing ];
37
38in runCommand "systemtap-${kernel.version}-${version}" {
39 inherit stapBuild kernelBuildDir;
40 nativeBuildInputs = [ makeWrapper ];
41 meta = {
42 homepage = "https://sourceware.org/systemtap/";
43 description = "Provides a scripting language for instrumentation on a live kernel plus user-space";
44 license = lib.licenses.gpl2;
45 platforms = lib.platforms.linux;
46 };
47} ''
48 mkdir -p $out/bin
49 for bin in $stapBuild/bin/*; do
50 ln -s $bin $out/bin
51 done
52 rm $out/bin/stap $out/bin/dtrace
53 makeWrapper $stapBuild/bin/stap $out/bin/stap \
54 --add-flags "-r $kernelBuildDir" \
55 --prefix PATH : ${lib.makeBinPath [ stdenv.cc.cc stdenv.cc.bintools elfutils gnumake ]}
56 makeWrapper $stapBuild/bin/dtrace $out/bin/dtrace \
57 --prefix PYTHONPATH : ${pypkgs}
58''