From ec8b4b40dd5a6459f6364c915478c6229fe414de Mon Sep 17 00:00:00 2001 From: John Titor <50095635+JohnRTitor@users.noreply.github.com> Date: Sun, 28 Jul 2024 00:40:47 +0530 Subject: [PATCH 1/2] ananicy-cpp: cleanup derivation use lib.cmakeBool and lib.cmakeFeature switch to finalAttrs from recursion format with nixfmt-rfc-style --- pkgs/by-name/an/ananicy-cpp/package.nix | 58 ++++++++++++++----------- 1 file changed, 32 insertions(+), 26 deletions(-) diff --git a/pkgs/by-name/an/ananicy-cpp/package.nix b/pkgs/by-name/an/ananicy-cpp/package.nix index 1906773921b4..cd9f052c650c 100644 --- a/pkgs/by-name/an/ananicy-cpp/package.nix +++ b/pkgs/by-name/an/ananicy-cpp/package.nix @@ -1,27 +1,28 @@ -{ lib -, clangStdenv -, fetchFromGitLab -, fetchpatch -, cmake -, pkg-config -, spdlog -, nlohmann_json -, systemd -, libbpf -, elfutils -, bpftools -, pcre2 -, zlib +{ + lib, + clangStdenv, + fetchFromGitLab, + fetchpatch, + cmake, + pkg-config, + spdlog, + nlohmann_json, + systemd, + libbpf, + elfutils, + bpftools, + pcre2, + zlib, }: -clangStdenv.mkDerivation rec { +clangStdenv.mkDerivation (finalAttrs: { pname = "ananicy-cpp"; version = "1.1.1"; src = fetchFromGitLab { owner = "ananicy-cpp"; repo = "ananicy-cpp"; - rev = "v${version}"; + rev = "v${finalAttrs.version}"; fetchSubmodules = true; hash = "sha256-oPinSc00+Z6SxjfTh7DttcXSjsLv1X0NI+O37C8M8GY="; }; @@ -55,17 +56,22 @@ clangStdenv.mkDerivation rec { ]; # BPF A call to built-in function '__stack_chk_fail' is not supported. - hardeningDisable = [ "stackprotector" "zerocallusedregs" ]; + hardeningDisable = [ + "stackprotector" + "zerocallusedregs" + ]; cmakeFlags = [ - "-DUSE_EXTERNAL_JSON=ON" - "-DUSE_EXTERNAL_SPDLOG=ON" - "-DUSE_EXTERNAL_FMTLIB=ON" - "-DUSE_BPF_PROC_IMPL=ON" - "-DBPF_BUILD_LIBBPF=OFF" - "-DENABLE_SYSTEMD=ON" - "-DENABLE_REGEX_SUPPORT=ON" - "-DVERSION=${version}" + (lib.mapAttrsToList lib.cmakeBool { + "USE_EXTERNAL_JSON" = true; + "USE_EXTERNAL_SPDLOG" = true; + "USE_EXTERNAL_FMTLIB" = true; + "USE_BPF_PROC_IMPL" = true; + "BPF_BUILD_LIBBPF" = false; + "ENABLE_SYSTEMD" = true; + "ENABLE_REGEX_SUPPORT" = true; + }) + (lib.cmakeFeature "VERSION" finalAttrs.version) ]; postInstall = '' @@ -85,4 +91,4 @@ clangStdenv.mkDerivation rec { ]; mainProgram = "ananicy-cpp"; }; -} +}) From ad5cd5a0a001807dba7c641dc8dac527d23a5de2 Mon Sep 17 00:00:00 2001 From: John Titor <50095635+JohnRTitor@users.noreply.github.com> Date: Sun, 28 Jul 2024 00:48:06 +0530 Subject: [PATCH 2/2] ananicy-cpp: make bpf support optional ananicy-cpp compiled with bpf does not work on hardened kernels So we make it optional to allow users to disable it https://github.com/NixOS/nixpkgs/issues/327382 --- pkgs/by-name/an/ananicy-cpp/package.nix | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/pkgs/by-name/an/ananicy-cpp/package.nix b/pkgs/by-name/an/ananicy-cpp/package.nix index cd9f052c650c..e34bebff8f26 100644 --- a/pkgs/by-name/an/ananicy-cpp/package.nix +++ b/pkgs/by-name/an/ananicy-cpp/package.nix @@ -13,6 +13,7 @@ bpftools, pcre2, zlib, + withBpf ? true, }: clangStdenv.mkDerivation (finalAttrs: { @@ -42,6 +43,7 @@ clangStdenv.mkDerivation (finalAttrs: { nativeBuildInputs = [ cmake pkg-config + ] ++ lib.optionals withBpf [ bpftools ]; @@ -50,9 +52,10 @@ clangStdenv.mkDerivation (finalAttrs: { spdlog nlohmann_json systemd + zlib + ] ++ lib.optionals withBpf [ libbpf elfutils - zlib ]; # BPF A call to built-in function '__stack_chk_fail' is not supported. @@ -66,7 +69,7 @@ clangStdenv.mkDerivation (finalAttrs: { "USE_EXTERNAL_JSON" = true; "USE_EXTERNAL_SPDLOG" = true; "USE_EXTERNAL_FMTLIB" = true; - "USE_BPF_PROC_IMPL" = true; + "USE_BPF_PROC_IMPL" = withBpf; "BPF_BUILD_LIBBPF" = false; "ENABLE_SYSTEMD" = true; "ENABLE_REGEX_SUPPORT" = true;