{ lib , cmake , fetchFromGitHub <del> , fetchpatch </del> <ins> , fetchzip , fetchurl </ins> , git <del> , llvmPackages , nixosTests , overrideCC </del> , perl , python3 <del> , stdenv , openssl_1_1 </del> <ins> , stdenvNoCC , ninja , autoPatchelfHook , writeShellApplication , jq , removeReferencesTo </ins> }: let <del> buildStdenv = overrideCC stdenv llvmPackages.clangUseLLVM; in buildStdenv.mkDerivation rec { pname = "osquery"; version = "5.5.1"; </del> <ins> version = "5.12.2"; opensslVersion = "3.2.1"; opensslSha256 = "83c7329fe52c850677d75e5d0b0ca245309b97e8ecbcfdc1dfdc4ab9fac35b39"; </ins> src = fetchFromGitHub { owner = "osquery"; repo = "osquery"; rev = version; fetchSubmodules = true; <del> sha256 = "sha256-Q6PQVnBjAjAlR725fyny+RhQFUNwxWGjLDuS5p9JKlU="; </del> <ins> hash = "sha256-PJrGAqDxo5l6jtQdpTqraR195G6kaLQ2ik08WtlWEmk="; </ins> }; <ins> extractOpensslInfo = writeShellApplication { name = "extractOpensslInfo"; text = '' if [ $# -ne 1 ]; then echo "Usage: $0 <osquery-source-directory>" exit 1 fi opensslCmake="$1"/libraries/cmake/formula/openssl/CMakeLists.txt version=$(gawk 'match($0, /OPENSSL_VERSION "(.*)"/, a) {print a[1]}' < "$opensslCmake") sha256=$(gawk 'match($0, /OPENSSL_ARCHIVE_SHA256 "(.*)"/, a) {print a[1]}' < "$opensslCmake") echo "{"version": "$version", "sha256": "$sha256"}" ''; }; opensslSrc = fetchurl { url = "https://www.openssl.org/source/openssl-${opensslVersion}.tar.gz"; sha256 = opensslSha256; }; toolchain = import ./toolchain-bin.nix { inherit autoPatchelfHook stdenvNoCC lib fetchzip; }; in stdenvNoCC.mkDerivation rec { pname = "osquery"; inherit src version; </ins> patches = [ ./Remove-git-reset.patch <del> ./Use-locale.h-instead-of-removed-xlocale.h-header.patch ./Remove-circular-definition-of-AUDIT_FILTER_EXCLUDE.patch # For current state of compilation against glibc in the clangWithLLVM toolchain, refer to the upstream issue in https://github.com/osquery/osquery/issues/7823. ./Remove-system-controls-table.patch # osquery uses a vendored boost library that still relies on old standard types (e.g. `std::unary_function`) # which have been removed as of C++17. The patch is already checked in upstream, but there have been no # releases yet. Can likely be removed with versions > 5.10.2. (fetchpatch { name = "fix-build-on-clang-16.patch"; url  = "https://github.com/osquery/osquery/commit/222991a15b4ae0a0fb919e4965603616536e1b0a.patch"; hash = "sha256-PdzEoeR1LXVri1Cd+7KMhKmDC8yZhAx3f1+9tjLJKyo="; }) </del> ]; <del> buildInputs = [ llvmPackages.libunwind ]; </del> nativeBuildInputs = [ cmake git perl python3 <ins> ninja autoPatchelfHook extractOpensslInfo jq removeReferencesTo </ins> ]; postPatch = '' substituteInPlace cmake/install_directives.cmake --replace "/control" "control" <del> # This is required to build libarchive with our glibc version # which provides the ARC4RANDOM_BUF function substituteInPlace libraries/cmake/source/libarchive/CMakeLists.txt --replace "  target_compile_definitions(thirdparty_libarchive PRIVATE" "  target_compile_definitions(thirdparty_libarchive PRIVATE HAVE_ARC4RANDOM_BUF" # We need to override this hash because we use our own openssl 1.1 version substituteInPlace libraries/cmake/formula/openssl/CMakeLists.txt --replace  "d7939ce614029cdff0b6c20f0e2e5703158a489a72b2507b8bd51bf8c8fd10ca"  "$(sha256sum ${openssl_1_1.src} | cut -f1 '-d ')" cat libraries/cmake/formula/openssl/CMakeLists.txt </del> ''; <del> # For explanation of these deletions, refer to the ./Use-locale.h-instead-of-removed-xlocale.h-header.patch file. preConfigure = '' find libraries/cmake/source -name 'config.h' -exec sed -i '/#define HAVE_XLOCALE_H 1/d' {} ; </del> <ins> configurePhase = '' expectedOpensslVersion=$(extractOpensslInfo . | jq -r .version) expectedOpensslSha256=$(extractOpensslInfo . | jq -r .sha256) if [ "$expectedOpensslVersion" != "${opensslVersion}" ]; then echo "openssl version mismatch: expected=$expectedOpensslVersion actual=${opensslVersion}" opensslMismatch=1 fi if [ "$expectedOpensslSha256" != "${opensslSha256}" ]; then echo "openssl sha256 mismatch: expected=$expectedOpensslSha256 actual=${opensslSha256}" opensslMismatch=1 fi if [ -n "$opensslMismatch" ]; then exit 1 fi 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 </ins> ''; <del> cmakeFlags = [ "-DOSQUERY_VERSION=${version}" "-DOSQUERY_OPENSSL_ARCHIVE_PATH=${openssl_1_1.src}" ]; </del> <ins> disallowedReferences = [ toolchain ]; </ins> <del> postFixup = '' patchelf --set-rpath "${llvmPackages.libunwind}/lib:$(patchelf --print-rpath $out/bin/osqueryd)" "$out/bin/osqueryd" </del> <ins> postInstall = '' rm -rf $out/control remove-references-to -t ${toolchain} $out/bin/osqueryd </ins> ''; <del> passthru.tests.osquery = nixosTests.osquery; </del> <ins> passthru = { inherit extractOpensslInfo opensslSrc toolchain; }; </ins> meta = with lib; { description = "SQL powered operating system instrumentation, monitoring, and analytics"; <del> longDescription = '' The system controls table is not included as it does not presently compile with glibc >= 2.32. For more information, refer to https://github.com/osquery/osquery/issues/7823 ''; </del> homepage = "https://osquery.io"; <del> license = licenses.bsd3; </del> <ins> license = with licenses; [ gpl2Only asl20 ]; </ins> platforms = platforms.linux; <del> maintainers = with maintainers; [ znewman01 lewo ]; </del> <ins> sourceProvenance = with sourceTypes; [ fromSource ]; maintainers = with maintainers; [ znewman01 lewo squalus ]; </ins> }; }