2021-01-27 05:44:43 +00:00
|
|
|
{ lib, fetchgit, pkg-config, gettext, runCommand, makeWrapper
|
2022-01-12 03:37:34 +00:00
|
|
|
, cpio, elfutils, kernel, gnumake, python3
|
2017-10-10 23:01:42 +00:00
|
|
|
}:
|
|
|
|
|
2016-09-15 23:08:36 +00:00
|
|
|
let
|
|
|
|
## fetchgit info
|
2020-04-01 01:11:51 +00:00
|
|
|
url = "git://sourceware.org/git/systemtap.git";
|
2018-10-11 06:20:08 +00:00
|
|
|
rev = "release-${version}";
|
2021-02-28 16:47:21 +00:00
|
|
|
sha256 = "sha256-3LgqMBCnUG2UmsekaIvV43lBpSPEocEXmFV9WpE7wE0=";
|
|
|
|
version = "4.5";
|
2016-09-15 23:08:36 +00:00
|
|
|
|
2016-09-16 20:09:39 +00:00
|
|
|
inherit (kernel) stdenv;
|
2016-09-15 23:08:36 +00:00
|
|
|
|
|
|
|
## stap binaries
|
2016-09-16 20:09:39 +00:00
|
|
|
stapBuild = stdenv.mkDerivation {
|
2019-08-13 21:52:01 +00:00
|
|
|
pname = "systemtap";
|
|
|
|
inherit version;
|
2016-09-15 23:08:36 +00:00
|
|
|
src = fetchgit { inherit url rev sha256; };
|
2022-02-10 05:37:36 +00:00
|
|
|
nativeBuildInputs = [ pkg-config cpio python3 python3.pkgs.setuptools ];
|
|
|
|
buildInputs = [ elfutils gettext ];
|
2016-09-15 23:08:36 +00:00
|
|
|
enableParallelBuilding = true;
|
|
|
|
};
|
|
|
|
|
|
|
|
## a kernel build dir as expected by systemtap
|
2016-09-16 20:09:39 +00:00
|
|
|
kernelBuildDir = runCommand "kbuild-${kernel.version}-merged" { } ''
|
2016-09-15 23:08:36 +00:00
|
|
|
mkdir -p $out
|
2016-09-16 20:09:39 +00:00
|
|
|
for f in \
|
|
|
|
${kernel}/System.map \
|
|
|
|
${kernel.dev}/vmlinux \
|
|
|
|
${kernel.dev}/lib/modules/${kernel.modDirVersion}/build/{*,.*}
|
|
|
|
do
|
|
|
|
ln -s $(readlink -f $f) $out
|
|
|
|
done
|
2016-09-15 23:08:36 +00:00
|
|
|
'';
|
|
|
|
|
2022-01-12 03:37:34 +00:00
|
|
|
pypkgs = with python3.pkgs; makePythonPath [ pyparsing ];
|
2018-02-20 15:11:12 +00:00
|
|
|
|
2016-09-15 23:08:36 +00:00
|
|
|
in runCommand "systemtap-${kernel.version}-${version}" {
|
|
|
|
inherit stapBuild kernelBuildDir;
|
2021-02-07 09:17:39 +00:00
|
|
|
nativeBuildInputs = [ makeWrapper ];
|
2016-09-16 20:09:39 +00:00
|
|
|
meta = {
|
2020-04-01 01:11:51 +00:00
|
|
|
homepage = "https://sourceware.org/systemtap/";
|
2016-09-16 20:09:39 +00:00
|
|
|
description = "Provides a scripting language for instrumentation on a live kernel plus user-space";
|
|
|
|
license = lib.licenses.gpl2;
|
|
|
|
platforms = lib.platforms.linux;
|
2016-09-15 23:08:36 +00:00
|
|
|
};
|
|
|
|
} ''
|
|
|
|
mkdir -p $out/bin
|
2018-10-11 06:20:08 +00:00
|
|
|
for bin in $stapBuild/bin/*; do
|
2016-09-16 20:09:39 +00:00
|
|
|
ln -s $bin $out/bin
|
2016-09-15 23:08:36 +00:00
|
|
|
done
|
2018-02-20 15:11:12 +00:00
|
|
|
rm $out/bin/stap $out/bin/dtrace
|
2016-09-15 23:08:36 +00:00
|
|
|
makeWrapper $stapBuild/bin/stap $out/bin/stap \
|
|
|
|
--add-flags "-r $kernelBuildDir" \
|
2017-10-10 23:01:42 +00:00
|
|
|
--prefix PATH : ${lib.makeBinPath [ stdenv.cc.cc stdenv.cc.bintools elfutils gnumake ]}
|
2018-02-20 15:11:12 +00:00
|
|
|
makeWrapper $stapBuild/bin/dtrace $out/bin/dtrace \
|
|
|
|
--prefix PYTHONPATH : ${pypkgs}
|
2016-09-15 23:08:36 +00:00
|
|
|
''
|