about summary refs log tree commit diff
path: root/third_party/asncounter/default.nix
blob: 477581452dcd9740fed8b6b2bd1235fed6bce9cc (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
# TODO(sterni): upstream into nixpkgs
{ pkgs, lib, ... }:

let
  inherit (pkgs.python3.pkgs)
    buildPythonPackage
    setuptools
    setuptools-scm
    pyasn
    manhole
    netaddr
    scapy
    prometheus-client
    pytestCheckHook
    ;

  inherit (pkgs)
    fetchFromGitLab
    pandoc
    installShellFiles
    ;
in

buildPythonPackage rec {
  pname = "asncounter";
  version = "0.5.0";

  src = fetchFromGitLab {
    owner = "anarcat";
    repo = "asncounter";
    tag = version;
    hash = "sha256-aFnxPc1qLIBzN3fKaGhcqF4z1TIToeSONJd0VgaMchQ=";
  };

  pyproject = true;
  build-system = [
    setuptools
    setuptools-scm
  ];

  nativeBuildInputs = [
    pandoc
    installShellFiles
  ];

  dependencies = [
    pyasn
  ];

  # TODO(sterni): add overridable switch
  optional-dependencies.full = [
    manhole
    netaddr
    scapy
    prometheus-client
  ];

  # see debian/rules
  postInstall = ''
    pandoc --standalone --to man asncounter.1.md > asncounter.1
    installManPage asncounter.1
  '';

  doCheck = true;
  checkInputs = optional-dependencies.full;
  nativeCheckInputs = [ pytestCheckHook ];

  meta = {
    description = "Count the number of hits per autonomous system number (ASN) and related network blocks";
    homepage = "https://gitlab.com/anarcat/asncounter";
    changelog = "https://gitlab.com/anarcat/asncounter/-/blob/${version}/debian/changelog?ref_type=tags";
    license = lib.licenses.agpl3Plus;
    maintainers = [ lib.maintainers.sternenseemann ];
  };
}