2021-02-05 17:12:51 +00:00
|
|
|
{ lib, fetchgit, pkg-config, gettext, runCommand, makeWrapper
|
2022-01-19 23:45:15 +00:00
|
|
|
, cpio, elfutils, kernel, gnumake, python3
|
2024-09-19 14:19:46 +00:00
|
|
|
, nixosTests
|
2020-04-24 23:36:52 +00:00
|
|
|
}:
|
|
|
|
|
|
|
|
let
|
|
|
|
## fetchgit info
|
|
|
|
url = "git://sourceware.org/git/systemtap.git";
|
|
|
|
rev = "release-${version}";
|
2024-01-13 08:15:51 +00:00
|
|
|
sha256 = "sha256-2L7+k/tgI6trkstDTY4xxfFzmNDlxbCHDRKAFaERQeM=";
|
|
|
|
version = "5.0a";
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
inherit (kernel) stdenv;
|
|
|
|
|
|
|
|
## stap binaries
|
|
|
|
stapBuild = stdenv.mkDerivation {
|
|
|
|
pname = "systemtap";
|
|
|
|
inherit version;
|
|
|
|
src = fetchgit { inherit url rev sha256; };
|
2022-03-30 09:31:56 +00:00
|
|
|
nativeBuildInputs = [ pkg-config cpio python3 python3.pkgs.setuptools ];
|
2024-01-02 11:29:13 +00:00
|
|
|
buildInputs = [ elfutils gettext python3 ];
|
2020-04-24 23:36:52 +00:00
|
|
|
enableParallelBuilding = true;
|
2023-03-04 12:14:45 +00:00
|
|
|
env.NIX_CFLAGS_COMPILE = toString [ "-Wno-error=deprecated-declarations" ]; # Needed with GCC 12
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
|
2024-01-13 08:15:51 +00:00
|
|
|
## symlink farm for --sysroot flag
|
|
|
|
sysroot = runCommand "systemtap-sysroot-${kernel.version}" { } ''
|
|
|
|
mkdir -p $out/boot $out/usr/lib/debug
|
|
|
|
ln -s ${kernel.dev}/vmlinux ${kernel.dev}/lib $out
|
|
|
|
ln -s ${kernel.dev}/vmlinux $out/usr/lib/debug
|
|
|
|
ln -s ${kernel}/System.map $out/boot/System.map-${kernel.version}
|
|
|
|
'';
|
|
|
|
|
2022-01-19 23:45:15 +00:00
|
|
|
pypkgs = with python3.pkgs; makePythonPath [ pyparsing ];
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
in runCommand "systemtap-${kernel.version}-${version}" {
|
2023-03-24 00:07:29 +00:00
|
|
|
inherit stapBuild;
|
2021-03-09 03:18:52 +00:00
|
|
|
nativeBuildInputs = [ makeWrapper ];
|
2024-09-19 14:19:46 +00:00
|
|
|
passthru.tests = { inherit (nixosTests.systemtap) linux_default linux_latest; };
|
2020-04-24 23:36:52 +00:00
|
|
|
meta = {
|
|
|
|
homepage = "https://sourceware.org/systemtap/";
|
|
|
|
description = "Provides a scripting language for instrumentation on a live kernel plus user-space";
|
|
|
|
license = lib.licenses.gpl2;
|
2023-02-02 18:25:31 +00:00
|
|
|
platforms = lib.systems.inspect.patterns.isGnu;
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
} ''
|
|
|
|
mkdir -p $out/bin
|
|
|
|
for bin in $stapBuild/bin/*; do
|
|
|
|
ln -s $bin $out/bin
|
|
|
|
done
|
|
|
|
rm $out/bin/stap $out/bin/dtrace
|
|
|
|
makeWrapper $stapBuild/bin/stap $out/bin/stap \
|
2024-01-13 08:15:51 +00:00
|
|
|
--add-flags "--sysroot ${sysroot}" \
|
2020-04-24 23:36:52 +00:00
|
|
|
--prefix PATH : ${lib.makeBinPath [ stdenv.cc.cc stdenv.cc.bintools elfutils gnumake ]}
|
|
|
|
makeWrapper $stapBuild/bin/dtrace $out/bin/dtrace \
|
|
|
|
--prefix PYTHONPATH : ${pypkgs}
|
|
|
|
''
|