2021-12-19 01:06:50 +00:00
|
|
|
{ lib, stdenv, fetchFromGitHub, fetchpatch, cmake, kernel, installShellFiles, pkg-config
|
2021-03-20 04:20:00 +00:00
|
|
|
, luajit, ncurses, perl, jsoncpp, libb64, openssl, curl, jq, gcc, elfutils, tbb, protobuf, grpc
|
2022-12-17 10:02:37 +00:00
|
|
|
, libyamlcpp, nlohmann_json, re2
|
2020-04-24 23:36:52 +00:00
|
|
|
}:
|
|
|
|
|
2021-02-05 17:12:51 +00:00
|
|
|
with lib;
|
2021-12-19 01:06:50 +00:00
|
|
|
let
|
|
|
|
# Compare with https://github.com/draios/sysdig/blob/dev/cmake/modules/falcosecurity-libs.cmake
|
2022-12-17 10:02:37 +00:00
|
|
|
libsRev = "0.9.1";
|
|
|
|
libsSha256 = "sha256-X+zLEnage8AuGdGn9sl1RN9b1CKTA1ErrdPNbYKY0s0=";
|
2022-05-18 14:49:53 +00:00
|
|
|
|
|
|
|
# Compare with https://github.com/falcosecurity/libs/blob/master/cmake/modules/valijson.cmake#L17
|
|
|
|
valijson = fetchFromGitHub {
|
|
|
|
owner = "tristanpenman";
|
|
|
|
repo = "valijson";
|
|
|
|
rev = "v0.6";
|
|
|
|
sha256 = "sha256-ZD19Q2MxMQd3yEKbY90GFCrerie5/jzgO8do4JQDoKM=";
|
|
|
|
};
|
|
|
|
|
2022-12-17 10:02:37 +00:00
|
|
|
driver = fetchFromGitHub {
|
|
|
|
owner = "falcosecurity";
|
|
|
|
repo = "libs";
|
|
|
|
rev = "3.0.1+driver";
|
|
|
|
sha256 = "sha256-bK9wv17bVl93rOqw7JICnMOM0fDtPIErfMmUmNKOD5c=";
|
|
|
|
};
|
|
|
|
|
2021-12-19 01:06:50 +00:00
|
|
|
in
|
2020-04-24 23:36:52 +00:00
|
|
|
stdenv.mkDerivation rec {
|
|
|
|
pname = "sysdig";
|
2022-12-17 10:02:37 +00:00
|
|
|
version = "0.30.2";
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "draios";
|
|
|
|
repo = "sysdig";
|
|
|
|
rev = version;
|
2022-12-17 10:02:37 +00:00
|
|
|
sha256 = "sha256-bDlrnTfm43zpYBIiP2MGB+LM5jtalmeUNtWHgxe81HM=";
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
|
2021-12-19 01:06:50 +00:00
|
|
|
nativeBuildInputs = [ cmake perl installShellFiles pkg-config ];
|
2020-04-24 23:36:52 +00:00
|
|
|
buildInputs = [
|
2022-05-18 14:49:53 +00:00
|
|
|
luajit
|
|
|
|
ncurses
|
|
|
|
libb64
|
|
|
|
openssl
|
|
|
|
curl
|
|
|
|
jq
|
|
|
|
gcc
|
|
|
|
elfutils
|
|
|
|
tbb
|
2022-12-17 10:02:37 +00:00
|
|
|
libb64
|
|
|
|
re2
|
2022-05-18 14:49:53 +00:00
|
|
|
protobuf
|
|
|
|
grpc
|
|
|
|
libyamlcpp
|
|
|
|
jsoncpp
|
|
|
|
nlohmann_json
|
2020-04-24 23:36:52 +00:00
|
|
|
] ++ optionals (kernel != null) kernel.moduleBuildDependencies;
|
|
|
|
|
|
|
|
hardeningDisable = [ "pic" ];
|
|
|
|
|
2021-12-19 01:06:50 +00:00
|
|
|
postUnpack = ''
|
|
|
|
cp -r ${fetchFromGitHub {
|
|
|
|
owner = "falcosecurity";
|
|
|
|
repo = "libs";
|
|
|
|
rev = libsRev;
|
|
|
|
sha256 = libsSha256;
|
|
|
|
}} libs
|
|
|
|
chmod -R +w libs
|
2022-12-17 10:02:37 +00:00
|
|
|
cp -r ${driver} driver-src
|
|
|
|
chmod -R +w driver-src
|
|
|
|
cmakeFlagsArray+=(
|
|
|
|
"-DFALCOSECURITY_LIBS_SOURCE_DIR=$(pwd)/libs"
|
|
|
|
"-DVALIJSON_INCLUDE=${valijson}/include"
|
|
|
|
"-DDRIVER_SOURCE_DIR=$(pwd)/driver-src/driver"
|
|
|
|
)
|
2021-12-19 01:06:50 +00:00
|
|
|
'';
|
|
|
|
|
2020-04-24 23:36:52 +00:00
|
|
|
cmakeFlags = [
|
|
|
|
"-DUSE_BUNDLED_DEPS=OFF"
|
|
|
|
"-DSYSDIG_VERSION=${version}"
|
2022-12-17 10:02:37 +00:00
|
|
|
"-DUSE_BUNDLED_B64=OFF"
|
|
|
|
"-DUSE_BUNDLED_TBB=OFF"
|
|
|
|
"-DUSE_BUNDLED_RE2=OFF"
|
2020-04-24 23:36:52 +00:00
|
|
|
"-DCREATE_TEST_TARGETS=OFF"
|
|
|
|
] ++ optional (kernel == null) "-DBUILD_DRIVER=OFF";
|
|
|
|
|
|
|
|
# needed since luajit-2.1.0-beta3
|
|
|
|
NIX_CFLAGS_COMPILE = "-DluaL_reg=luaL_Reg -DluaL_getn(L,i)=((int)lua_objlen(L,i))";
|
|
|
|
|
|
|
|
preConfigure = ''
|
2022-05-18 14:49:53 +00:00
|
|
|
if ! grep -q "${libsRev}" cmake/modules/falcosecurity-libs.cmake; then
|
|
|
|
echo "falcosecurity-libs checksum needs to be updated!"
|
|
|
|
exit 1
|
|
|
|
fi
|
2021-09-18 10:52:07 +00:00
|
|
|
cmakeFlagsArray+=(-DCMAKE_EXE_LINKER_FLAGS="-ltbb -lcurl -labsl_synchronization")
|
2020-04-24 23:36:52 +00:00
|
|
|
'' + optionalString (kernel != null) ''
|
2021-12-19 01:06:50 +00:00
|
|
|
export INSTALL_MOD_PATH="$out"
|
2020-04-24 23:36:52 +00:00
|
|
|
export KERNELDIR="${kernel.dev}/lib/modules/${kernel.modDirVersion}/build"
|
|
|
|
'';
|
|
|
|
|
2020-12-07 07:45:13 +00:00
|
|
|
postInstall =
|
|
|
|
''
|
|
|
|
# Fix the bash completion location
|
|
|
|
installShellCompletion --bash $out/etc/bash_completion.d/sysdig
|
|
|
|
rm $out/etc/bash_completion.d/sysdig
|
|
|
|
rmdir $out/etc/bash_completion.d
|
|
|
|
rmdir $out/etc
|
|
|
|
''
|
|
|
|
+ optionalString (kernel != null) ''
|
|
|
|
make install_driver
|
|
|
|
kernel_dev=${kernel.dev}
|
|
|
|
kernel_dev=''${kernel_dev#/nix/store/}
|
|
|
|
kernel_dev=''${kernel_dev%%-linux*dev*}
|
2021-12-19 01:06:50 +00:00
|
|
|
if test -f "$out/lib/modules/${kernel.modDirVersion}/extra/scap.ko"; then
|
|
|
|
sed -i "s#$kernel_dev#................................#g" $out/lib/modules/${kernel.modDirVersion}/extra/scap.ko
|
2020-12-07 07:45:13 +00:00
|
|
|
else
|
2021-12-19 01:06:50 +00:00
|
|
|
xz -d $out/lib/modules/${kernel.modDirVersion}/extra/scap.ko.xz
|
|
|
|
sed -i "s#$kernel_dev#................................#g" $out/lib/modules/${kernel.modDirVersion}/extra/scap.ko
|
|
|
|
xz $out/lib/modules/${kernel.modDirVersion}/extra/scap.ko
|
2020-12-07 07:45:13 +00:00
|
|
|
fi
|
|
|
|
'';
|
|
|
|
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
meta = {
|
|
|
|
description = "A tracepoint-based system tracing tool for Linux (with clients for other OSes)";
|
|
|
|
license = with licenses; [ asl20 gpl2 mit ];
|
|
|
|
maintainers = [maintainers.raskin];
|
|
|
|
platforms = ["x86_64-linux"] ++ platforms.darwin;
|
|
|
|
broken = kernel != null && versionOlder kernel.version "4.14";
|
|
|
|
homepage = "https://sysdig.com/opensource/";
|
|
|
|
downloadPage = "https://github.com/draios/sysdig/releases";
|
|
|
|
};
|
|
|
|
}
|