33 # Compare with https://github.com/draios/sysdig/blob/0.38.1/cmake/modules/falcosecurity-libs.cmake
35 libsHash = "sha256-BTLXtdU7GjOJReaycHvXkSd2vtybnCn0rTR7OEsvaMQ=";
37 # Compare with https://github.com/falcosecurity/libs/blob/0.17.2/cmake/modules/valijson.cmake
38 valijson = fetchFromGitHub {
39 owner = "tristanpenman";
42 hash = "sha256-wvFdjsDtKH7CpbEpQjzWtLC4RVOU9+D2rSK0Xo1cJqo=";
45 # https://github.com/draios/sysdig/blob/0.38.1/cmake/modules/driver.cmake
46 driver = fetchFromGitHub {
47 owner = "falcosecurity";
50 hash = "sha256-FIlnJsNgofGo4HETEEpW28wpC3U9z5AZprwFR5AgFfA=";
53 # "main.c" from master after (https://github.com/falcosecurity/libs/pull/1884)
54 # Remove when an upstream release includes the driver update
55 driverKernel610MainC = fetchurl {
56 url = "https://raw.githubusercontent.com/falcosecurity/libs/fa26daf65bb4117ecfe099fcad48ea75fe86d8bb/driver/main.c";
57 hash = "sha256-VI/tOSXs5OcEDehSqICF3apmSnwe4QCmbkHz+DGH4uM=";
66 src = fetchFromGitHub {
70 hash = "sha256-oufRTr5TFdpF50pmem2L3bBFIfwxCR8f1xi0A328iHo=";
99 ] ++ lib.optionals (kernel != null) kernel.moduleBuildDependencies;
101 hardeningDisable = [ "pic" "zerocallusedregs" ];
106 owner = "falcosecurity";
114 substituteInPlace libs/userspace/libscap/libscap.pc.in libs/userspace/libsinsp/libsinsp.pc.in \
115 --replace-fail "\''${prefix}/@CMAKE_INSTALL_LIBDIR@" "@CMAKE_INSTALL_FULL_LIBDIR@" \
116 --replace-fail "\''${prefix}/@CMAKE_INSTALL_INCLUDEDIR@" "@CMAKE_INSTALL_FULL_INCLUDEDIR@"
118 cp -r ${driver} driver-src
119 chmod -R +w driver-src
120 cp ${driverKernel610MainC} driver-src/driver/main.c
123 "-DFALCOSECURITY_LIBS_SOURCE_DIR=$(pwd)/libs"
124 "-DDRIVER_SOURCE_DIR=$(pwd)/driver-src/driver"
129 "-DUSE_BUNDLED_DEPS=OFF"
130 "-DSYSDIG_VERSION=${version}"
131 "-DUSE_BUNDLED_B64=OFF"
132 "-DUSE_BUNDLED_TBB=OFF"
133 "-DUSE_BUNDLED_RE2=OFF"
134 "-DUSE_BUNDLED_JSONCPP=OFF"
135 "-DCREATE_TEST_TARGETS=OFF"
136 "-DVALIJSON_INCLUDE=${valijson}/include"
137 "-DUTHASH_INCLUDE=${uthash}/include"
138 ] ++ lib.optional (kernel == null) "-DBUILD_DRIVER=OFF";
140 env.NIX_CFLAGS_COMPILE =
141 # fix compiler warnings been treated as errors
146 if ! grep -q "${libsRev}" cmake/modules/falcosecurity-libs.cmake; then
147 echo "falcosecurity-libs checksum needs to be updated!"
150 cmakeFlagsArray+=(-DCMAKE_EXE_LINKER_FLAGS="-ltbb -lcurl -lzstd -labsl_synchronization")
152 + lib.optionalString (kernel != null) ''
153 export INSTALL_MOD_PATH="$out"
154 export KERNELDIR="${kernel.dev}/lib/modules/${kernel.modDirVersion}/build"
159 # Fix the bash completion location
160 installShellCompletion --bash $out/etc/bash_completion.d/sysdig
161 rm $out/etc/bash_completion.d/sysdig
162 rmdir $out/etc/bash_completion.d
165 + lib.optionalString (kernel != null) ''
167 kernel_dev=${kernel.dev}
168 kernel_dev=''${kernel_dev#${builtins.storeDir}/}
169 kernel_dev=''${kernel_dev%%-linux*dev*}
170 if test -f "$out/lib/modules/${kernel.modDirVersion}/extra/scap.ko"; then
171 sed -i "s#$kernel_dev#................................#g" $out/lib/modules/${kernel.modDirVersion}/extra/scap.ko
173 for i in $out/lib/modules/${kernel.modDirVersion}/{extra,updates}/scap.ko.xz; do
174 if test -f "$i"; then
176 sed -i "s#$kernel_dev#................................#g" ''${i%.xz}
184 description = "A tracepoint-based system tracing tool for Linux (with clients for other OSes)";
185 license = with lib.licenses; [
190 maintainers = with lib.maintainers; [ raskin ];
191 platforms = [ "x86_64-linux" ] ++ lib.platforms.darwin;
193 kernel != null && ((lib.versionOlder kernel.version "4.14") || kernel.isHardened || kernel.isZen);
194 homepage = "https://sysdig.com/opensource/";
195 downloadPage = "https://github.com/draios/sysdig/releases";