Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
at flake-libs 90 lines 2.2 kB view raw
1{ 2 lib, 3 fetchgit, 4 pkg-config, 5 gettext, 6 runCommand, 7 makeWrapper, 8 cpio, 9 elfutils, 10 kernel, 11 gnumake, 12 python3, 13 nixosTests, 14 withStap ? true, # avoid cyclic dependency with glib, reduce closure size substantially 15}: 16 17let 18 ## fetchgit info 19 url = "git://sourceware.org/git/systemtap.git"; 20 rev = "release-${version}"; 21 hash = "sha256-SUPNarZW8vdK9hQaI2kU+rfKWIPiXB4BvJvRNC1T9tU="; 22 version = "5.2"; 23 24 inherit (kernel) stdenv; 25 26 ## stap binaries 27 stapBuild = stdenv.mkDerivation { 28 pname = "systemtap"; 29 inherit version; 30 src = fetchgit { inherit url rev hash; }; 31 nativeBuildInputs = [ 32 pkg-config 33 cpio 34 python3 35 python3.pkgs.setuptools 36 ]; 37 buildInputs = [ 38 elfutils 39 gettext 40 python3 41 ]; 42 enableParallelBuilding = true; 43 }; 44 45 ## symlink farm for --sysroot flag 46 sysroot = runCommand "systemtap-sysroot-${kernel.version}" { } '' 47 mkdir -p $out/boot $out/usr/lib/debug 48 ln -s ${kernel.dev}/vmlinux ${kernel.dev}/lib $out 49 ln -s ${kernel.dev}/vmlinux $out/usr/lib/debug 50 ln -s ${kernel}/System.map $out/boot/System.map-${kernel.version} 51 ''; 52 53 pypkgs = with python3.pkgs; makePythonPath [ pyparsing ]; 54 55in 56runCommand "systemtap-${version}" 57 { 58 inherit stapBuild; 59 nativeBuildInputs = [ makeWrapper ]; 60 passthru.tests = { inherit (nixosTests.systemtap) linux_default linux_latest; }; 61 meta = { 62 homepage = "https://sourceware.org/systemtap/"; 63 description = "Provides a scripting language for instrumentation on a live kernel plus user-space"; 64 license = lib.licenses.gpl2; 65 platforms = lib.systems.inspect.patterns.isGnu; 66 }; 67 } 68 ( 69 '' 70 mkdir -p $out/bin 71 for bin in $stapBuild/bin/*; do 72 ln -s $bin $out/bin 73 done 74 rm $out/bin/stap $out/bin/dtrace 75 makeWrapper $stapBuild/bin/dtrace $out/bin/dtrace \ 76 --prefix PYTHONPATH : ${pypkgs} 77 '' 78 + lib.optionalString withStap '' 79 makeWrapper $stapBuild/bin/stap $out/bin/stap \ 80 --add-flags "--sysroot ${sysroot}" \ 81 --prefix PATH : ${ 82 lib.makeBinPath [ 83 stdenv.cc.cc 84 stdenv.cc.bintools 85 elfutils 86 gnumake 87 ] 88 } 89 '' 90 )