summary refs log tree commit diff
path: root/pkgs/development/python-modules/yaramod/default.nix
blob: c376c2ddbd6ee9393cc01e4ed02ebca3fd66836c (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
{ lib
, buildPythonPackage
, cmake
, fetchFromGitHub
, pytestCheckHook
, libxcrypt
, pythonOlder
, gtest
, pybind11
, nlohmann_json
}:

let
  pog = fetchFromGitHub {
    owner = "metthal";
    repo = "pog";
    rev = "b09bbf9cea573ee62aab7eccda896e37961d16cd";
    hash = "sha256-El4WA92t2O/L4wUqH6Xj8w+ANtb6liRwafDhqn8jxjQ=";
  };
in
  buildPythonPackage rec {
    pname = "yaramod";
    version = "3.20.0";
    format = "setuptools";

    disabled = pythonOlder "3.7";

    src = fetchFromGitHub {
      owner = "avast";
      repo = pname;
      rev = "refs/tags/v${version}";
      hash = "sha256-b4jHveGQGwO1BjpS/WJrMMBGB0LVB6Q7oltq4azp+7o=";
    };

    postPatch = ''
      rm -r deps/googletest deps/pog/ deps/pybind11/ deps/json/json.hpp
      cp -r --no-preserve=all ${pog} deps/pog/
      cp -r --no-preserve=all ${nlohmann_json.src}/single_include/nlohmann/json.hpp deps/json/
      cp -r --no-preserve=all ${pybind11.src} deps/pybind11/
      cp -r --no-preserve=all ${gtest.src} deps/googletest/
    '';

    dontUseCmakeConfigure = true;

    buildInputs = [
      libxcrypt
    ];

    nativeBuildInputs = [
      cmake
      pog
      gtest
    ];

    setupPyBuildFlags = [
      "--with-unit-tests"
    ];

    checkInputs = [
      pytestCheckHook
    ];

    pytestFlagsArray = [
      "tests/"
    ];

    pythonImportsCheck = [
      "yaramod"
    ];

    meta = with lib; {
      description = "Parsing of YARA rules into AST and building new rulesets in C++";
      homepage = "https://github.com/avast/yaramod";
      changelog = "https://github.com/avast/yaramod/blob/v${version}/CHANGELOG.md";
      license = licenses.mit;
      maintainers = with maintainers; [ msm ];
    };
  }