2023-08-04 22:07:22 +00:00
|
|
|
{ lib
|
|
|
|
, cmake
|
|
|
|
, fetchFromGitHub
|
2024-07-27 06:49:29 +00:00
|
|
|
, fetchzip
|
|
|
|
, fetchurl
|
2023-08-04 22:07:22 +00:00
|
|
|
, git
|
|
|
|
, perl
|
|
|
|
, python3
|
2024-09-19 14:19:46 +00:00
|
|
|
, stdenv
|
2024-07-27 06:49:29 +00:00
|
|
|
, stdenvNoCC
|
|
|
|
, ninja
|
2024-09-19 14:19:46 +00:00
|
|
|
, nix-prefetch-git
|
2024-07-27 06:49:29 +00:00
|
|
|
, autoPatchelfHook
|
|
|
|
, jq
|
|
|
|
, removeReferencesTo
|
|
|
|
, nixosTests
|
2024-09-19 14:19:46 +00:00
|
|
|
, writers
|
2023-08-04 22:07:22 +00:00
|
|
|
}:
|
|
|
|
|
|
|
|
let
|
2024-07-27 06:49:29 +00:00
|
|
|
|
2024-09-19 14:19:46 +00:00
|
|
|
info = builtins.fromJSON (builtins.readFile ./info.json);
|
2024-07-27 06:49:29 +00:00
|
|
|
|
2024-09-19 14:19:46 +00:00
|
|
|
opensslSrc = fetchurl info.openssl;
|
2024-07-27 06:49:29 +00:00
|
|
|
|
2024-10-23 06:41:50 +00:00
|
|
|
toolchain = import ./toolchain-bin.nix { inherit stdenv lib fetchzip autoPatchelfHook; };
|
2024-07-27 06:49:29 +00:00
|
|
|
|
|
|
|
in
|
|
|
|
|
|
|
|
stdenvNoCC.mkDerivation rec {
|
|
|
|
|
|
|
|
pname = "osquery";
|
|
|
|
|
2024-09-19 14:19:46 +00:00
|
|
|
version = info.osquery.rev;
|
|
|
|
|
|
|
|
src = fetchFromGitHub info.osquery;
|
2024-07-27 06:49:29 +00:00
|
|
|
|
2023-08-04 22:07:22 +00:00
|
|
|
patches = [
|
|
|
|
./Remove-git-reset.patch
|
|
|
|
];
|
|
|
|
|
|
|
|
nativeBuildInputs = [
|
|
|
|
cmake
|
|
|
|
git
|
|
|
|
perl
|
|
|
|
python3
|
2024-07-27 06:49:29 +00:00
|
|
|
ninja
|
|
|
|
autoPatchelfHook
|
|
|
|
jq
|
|
|
|
removeReferencesTo
|
2023-08-04 22:07:22 +00:00
|
|
|
];
|
|
|
|
|
|
|
|
postPatch = ''
|
|
|
|
substituteInPlace cmake/install_directives.cmake --replace "/control" "control"
|
|
|
|
'';
|
|
|
|
|
2024-07-27 06:49:29 +00:00
|
|
|
configurePhase = ''
|
|
|
|
mkdir build
|
|
|
|
cd build
|
|
|
|
cmake .. \
|
|
|
|
-DCMAKE_INSTALL_PREFIX=$out \
|
|
|
|
-DOSQUERY_TOOLCHAIN_SYSROOT=${toolchain} \
|
|
|
|
-DOSQUERY_VERSION=${version} \
|
|
|
|
-DCMAKE_PREFIX_PATH=${toolchain}/usr/lib/cmake \
|
|
|
|
-DCMAKE_LIBRARY_PATH=${toolchain}/usr/lib \
|
|
|
|
-DOSQUERY_OPENSSL_ARCHIVE_PATH=${opensslSrc} \
|
|
|
|
-GNinja
|
2023-08-04 22:07:22 +00:00
|
|
|
'';
|
|
|
|
|
2024-07-27 06:49:29 +00:00
|
|
|
disallowedReferences = [ toolchain ];
|
2023-08-04 22:07:22 +00:00
|
|
|
|
2024-07-27 06:49:29 +00:00
|
|
|
postInstall = ''
|
|
|
|
rm -rf $out/control
|
|
|
|
remove-references-to -t ${toolchain} $out/bin/osqueryd
|
2023-08-04 22:07:22 +00:00
|
|
|
'';
|
|
|
|
|
2024-07-27 06:49:29 +00:00
|
|
|
passthru = {
|
2024-09-19 14:19:46 +00:00
|
|
|
inherit opensslSrc toolchain;
|
2024-07-27 06:49:29 +00:00
|
|
|
tests = {
|
|
|
|
inherit (nixosTests) osquery;
|
|
|
|
};
|
2024-09-19 14:19:46 +00:00
|
|
|
updateScript = writers.writePython3
|
|
|
|
"osquery-update"
|
|
|
|
{ makeWrapperArgs = "--prefix PATH : ${lib.makeBinPath [ nix-prefetch-git ]}"; }
|
|
|
|
(builtins.readFile ./update.py);
|
2024-07-27 06:49:29 +00:00
|
|
|
};
|
2023-08-04 22:07:22 +00:00
|
|
|
|
|
|
|
meta = with lib; {
|
2024-01-13 08:15:51 +00:00
|
|
|
description = "SQL powered operating system instrumentation, monitoring, and analytics";
|
2023-08-04 22:07:22 +00:00
|
|
|
homepage = "https://osquery.io";
|
2024-07-27 06:49:29 +00:00
|
|
|
license = with licenses; [ gpl2Only asl20 ];
|
2023-08-04 22:07:22 +00:00
|
|
|
platforms = platforms.linux;
|
2024-07-27 06:49:29 +00:00
|
|
|
sourceProvenance = with sourceTypes; [ fromSource ];
|
|
|
|
maintainers = with maintainers; [ znewman01 lewo squalus ];
|
2023-08-04 22:07:22 +00:00
|
|
|
};
|
|
|
|
}
|