2016-09-16 21:09:39 +01:00
|
|
|
{ fetchgit, pkgconfig, gettext, runCommand, makeWrapper
|
|
|
|
, elfutils, kernel, gnumake }:
|
2016-09-16 00:08:36 +01:00
|
|
|
let
|
|
|
|
## fetchgit info
|
|
|
|
url = git://sourceware.org/git/systemtap.git;
|
2016-09-16 21:09:39 +01:00
|
|
|
rev = "a10bdceb7c9a7dc52c759288dd2e555afcc5184a";
|
|
|
|
sha256 = "1kllzfnh4ksis0673rma5psglahl6rvy0xs5v05qkqn6kl7irmg1";
|
|
|
|
version = "2016-09-16";
|
2016-09-16 00:08:36 +01:00
|
|
|
|
2016-09-16 21:09:39 +01:00
|
|
|
inherit (kernel) stdenv;
|
|
|
|
inherit (stdenv) lib;
|
2016-09-16 00:08:36 +01:00
|
|
|
|
|
|
|
## stap binaries
|
2016-09-16 21:09:39 +01:00
|
|
|
stapBuild = stdenv.mkDerivation {
|
2016-09-16 00:08:36 +01:00
|
|
|
name = "systemtap-${version}";
|
|
|
|
src = fetchgit { inherit url rev sha256; };
|
|
|
|
buildInputs = [ elfutils pkgconfig gettext ];
|
|
|
|
enableParallelBuilding = true;
|
|
|
|
};
|
|
|
|
|
|
|
|
## a kernel build dir as expected by systemtap
|
2016-09-16 21:09:39 +01:00
|
|
|
kernelBuildDir = runCommand "kbuild-${kernel.version}-merged" { } ''
|
2016-09-16 00:08:36 +01:00
|
|
|
mkdir -p $out
|
2016-09-16 21:09:39 +01: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-16 00:08:36 +01:00
|
|
|
'';
|
|
|
|
|
|
|
|
in runCommand "systemtap-${kernel.version}-${version}" {
|
|
|
|
inherit stapBuild kernelBuildDir;
|
|
|
|
buildInputs = [ makeWrapper ];
|
2016-09-16 21:09:39 +01:00
|
|
|
meta = {
|
2016-09-16 00:08:36 +01:00
|
|
|
homepage = https://sourceware.org/systemtap/;
|
2016-09-16 21:09:39 +01:00
|
|
|
repositories.git = url;
|
|
|
|
description = "Provides a scripting language for instrumentation on a live kernel plus user-space";
|
|
|
|
license = lib.licenses.gpl2;
|
|
|
|
platforms = lib.platforms.linux;
|
2016-09-16 00:08:36 +01:00
|
|
|
};
|
|
|
|
} ''
|
|
|
|
mkdir -p $out/bin
|
|
|
|
for bin in $stapBuild/bin/*; do # hello emacs */
|
2016-09-16 21:09:39 +01:00
|
|
|
ln -s $bin $out/bin
|
2016-09-16 00:08:36 +01:00
|
|
|
done
|
|
|
|
rm $out/bin/stap
|
|
|
|
makeWrapper $stapBuild/bin/stap $out/bin/stap \
|
|
|
|
--add-flags "-r $kernelBuildDir" \
|
2016-09-16 21:09:39 +01:00
|
|
|
--prefix PATH : ${lib.makeBinPath [ stdenv.cc.cc elfutils gnumake ]}
|
2016-09-16 00:08:36 +01:00
|
|
|
''
|