nixpkgs mirror (for testing)
github.com/NixOS/nixpkgs
nix
1{
2 lib,
3 buildPythonPackage,
4 cmake,
5 fetchFromGitHub,
6 pytestCheckHook,
7 libxcrypt,
8 gtest,
9 pybind11,
10 nlohmann_json,
11 setuptools,
12}:
13
14let
15 pog = fetchFromGitHub {
16 owner = "metthal";
17 repo = "pog";
18 rev = "b09bbf9cea573ee62aab7eccda896e37961d16cd";
19 hash = "sha256-El4WA92t2O/L4wUqH6Xj8w+ANtb6liRwafDhqn8jxjQ=";
20 };
21in
22buildPythonPackage (finalAttrs: {
23 pname = "yaramod";
24 version = "4.6.0";
25 pyproject = true;
26
27 src = fetchFromGitHub {
28 owner = "avast";
29 repo = "yaramod";
30 tag = "v${finalAttrs.version}";
31 hash = "sha256-2XI7lGfoMHimtuQ29I1cFtV4OgfvR3Qcvh/FhA0yeBw=";
32 };
33
34 postPatch = ''
35 rm -r deps/googletest deps/pog/ deps/pybind11/ deps/json/json.hpp
36 cp -r --no-preserve=all ${pog} deps/pog/
37 cp -r --no-preserve=all ${nlohmann_json.src}/single_include/nlohmann/json.hpp deps/json/
38 cp -r --no-preserve=all ${pybind11.src} deps/pybind11/
39 cp -r --no-preserve=all ${gtest.src} deps/googletest/
40
41 substituteInPlace deps/pog/deps/fmt/fmt/CMakeLists.txt \
42 --replace-fail "cmake_minimum_required(VERSION 3.1.0)" "cmake_minimum_required(VERSION 3.10)"
43 '';
44
45 dontUseCmakeConfigure = true;
46
47 buildInputs = [ libxcrypt ];
48
49 nativeBuildInputs = [
50 cmake
51 pog
52 ];
53
54 build-system = [ setuptools ];
55
56 env.ENV_YARAMOD_BUILD_WITH_UNIT_TESTS = true;
57
58 nativeCheckInputs = [
59 gtest
60 pytestCheckHook
61 ];
62
63 enabledTestPaths = [ "tests/" ];
64
65 pythonImportsCheck = [ "yaramod" ];
66
67 meta = {
68 description = "Parsing of YARA rules into AST and building new rulesets in C++";
69 homepage = "https://github.com/avast/yaramod";
70 changelog = "https://github.com/avast/yaramod/blob/${finalAttrs.src.tag}/CHANGELOG.md";
71 license = lib.licenses.mit;
72 maintainers = with lib.maintainers; [ msm ];
73 };
74})