1{ stdenv, lib, fetchFromGitHub, pkgconfig, cmake, pythonPackages
2, udev, audit, aws-sdk-cpp, cryptsetup, lvm2, libgcrypt, libarchive
3, libgpgerror, libuuid, iptables, apt, dpkg, lzma, lz4, bzip2, rpm
4, beecrypt, augeas, libxml2, sleuthkit, yara, lldpd, google-gflags
5, thrift, boost, rocksdb_lite, cpp-netlib, glog, gbenchmark, snappy
6, openssl, linenoise-ng, file, doxygen, devicemapper
7, gtest, sqlite
8}:
9
10let
11 thirdparty = fetchFromGitHub {
12 owner = "osquery";
13 repo = "third-party";
14 rev = "6919841175b2c9cb2dee8986e0cfe49191ecb868";
15 sha256 = "1kjxrky586jd1b2z1vs9cm7x1dxw51cizpys9kddiarapc2ih65j";
16 };
17
18in
19
20stdenv.mkDerivation rec {
21 name = "osquery-${version}";
22 version = "2.5.2";
23
24 # this is what `osquery --help` will show as the version.
25 OSQUERY_BUILD_VERSION = version;
26
27 src = fetchFromGitHub {
28 owner = "facebook";
29 repo = "osquery";
30 rev = version;
31 sha256 = "16isplk66qpvhrf041l0lxb4z6k7wwd1sg7kpsw2q6kivkxpnk3z";
32 };
33
34 patches = [ ./misc.patch ] ++ lib.optional stdenv.isLinux ./platform-nixos.patch;
35
36 nativeBuildInputs = [
37 pkgconfig cmake pythonPackages.python pythonPackages.jinja2
38 ];
39
40 buildInputs = [
41 udev audit
42
43 (aws-sdk-cpp.override {
44 apis = [ "firehose" "kinesis" "sts" ];
45 customMemoryManagement = false;
46 })
47
48 lvm2 libgcrypt libarchive libgpgerror libuuid iptables.dev apt dpkg
49 lzma lz4 bzip2 rpm beecrypt augeas libxml2 sleuthkit
50 yara lldpd google-gflags thrift boost
51 cpp-netlib glog gbenchmark snappy openssl linenoise-ng
52 file doxygen devicemapper cryptsetup
53 gtest sqlite
54
55 # need to be consistent about the malloc implementation
56 (rocksdb_lite.override { jemalloc = null; gperftools = null; })
57 ];
58
59 preConfigure = ''
60 export NIX_CFLAGS_COMPILE="-I${libxml2.dev}/include/libxml2 $NIX_CFLAGS_COMPILE"
61
62 cmakeFlagsArray+=(
63 -DCMAKE_LIBRARY_PATH=${cryptsetup}/lib
64 -DCMAKE_VERBOSE_MAKEFILE=OFF
65 )
66
67 cp -r ${thirdparty}/* third-party
68 chmod +w -R third-party
69 rm -r third-party/{googletest,sqlite3}
70 '';
71
72 meta = with lib; {
73 description = "SQL powered operating system instrumentation, monitoring, and analytics";
74 homepage = https://osquery.io/;
75 license = licenses.bsd3;
76 platforms = platforms.linux;
77 maintainers = with maintainers; [ cstrahan ];
78 };
79}