Merge pull request #330634 from r-ryantm/auto-update/circumflex
[NixPkgs.git] / pkgs / servers / fastnetmon-advanced / default.nix
blobab655bca526cc3ba4ee05cb5f1c560412fc6016f
1 { lib
2 , stdenv
3 , fetchurl
4 , autoPatchelfHook
5 , bzip2
6 , nixosTests
7 }:
9 stdenv.mkDerivation rec {
10   pname = "fastnetmon-advanced";
11   version = "2.0.363";
13   src = fetchurl {
14     url = "https://repo.fastnetmon.com/fastnetmon_ubuntu_jammy/pool/fastnetmon/f/fastnetmon/fastnetmon_${version}_amd64.deb";
15     hash = "sha256-2AKUNPQ7OzuYOolJHwTnWHzB4Qpwun/77+dFCN/cE98=";
16   };
18   nativeBuildInputs = [
19     autoPatchelfHook
20   ];
22   buildInputs = [
23     bzip2
24   ];
26   unpackPhase = ''
27     ar xf $src
28     tar xf data.tar.xz
30     # both clickhouse 2.0.0 and 2.3.0 libs are included, without versioning it will by
31     # default choose the first it finds, but we need 2.3.0 otherwise the fastnetmon
32     # binary will be missing symbols
33     rm -r opt/fastnetmon/libraries/libclickhouse_2_0_0
35     # unused libraries, which have additional dependencies
36     rm opt/fastnetmon/libraries/gcc1210/lib/libgccjit.so.0.0.1
37     rm opt/fastnetmon/libraries/poco_1_10_0/lib/libPocoCryptod.so.70
38     rm opt/fastnetmon/libraries/poco_1_10_0/lib/libPocoCrypto.so.70
39     rm opt/fastnetmon/libraries/poco_1_10_0/lib/libPocoJWTd.so.70
40     rm opt/fastnetmon/libraries/poco_1_10_0/lib/libPocoJWT.so.70
41     rm opt/fastnetmon/libraries/wkhtmltopdf-0.12.3/wkhtmltox/lib/libwkhtmltox.so.0.12.3
42   '';
44   installPhase = ''
45     mkdir -p $out/libexec/fastnetmon
46     cp -r opt/fastnetmon/app/bin $out/bin
47     cp -r opt/fastnetmon/libraries $out/libexec/fastnetmon
49     readlink usr/sbin/gobgpd
50     readlink usr/bin/gobgp
52     ln -s $(readlink usr/sbin/gobgpd | sed "s:/opt/fastnetmon:$out/libexec/fastnetmon:") $out/bin/fnm-gobgpd
53     ln -s $(readlink usr/bin/gobgp | sed "s:/opt/fastnetmon:$out/libexec/fastnetmon:") $out/bin/fnm-gobgp
55     addAutoPatchelfSearchPath $out/libexec/fastnetmon/libraries
56   '';
58   doInstallCheck = true;
59   installCheckPhase = ''
60     set +o pipefail
61     $out/bin/fastnetmon 2>&1 | grep "Can't open log file"
62     $out/bin/fcli 2>&1 | grep "Please run this tool with root rights"
63     $out/bin/fnm-gobgp --help 2>&1 | grep "Available Commands"
64     $out/bin/fnm-gobgpd --help 2>&1 | grep "Application Options"
65   '';
67   passthru.tests = { inherit (nixosTests) fastnetmon-advanced; };
69   meta = with lib; {
70     description = "High performance DDoS detector / sensor - commercial edition";
71     homepage = "https://fastnetmon.com";
72     changelog = "https://github.com/FastNetMon/fastnetmon-advanced-releases/releases/tag/v${version}";
73     sourceProvenance = with sourceTypes; [ binaryNativeCode ];
74     maintainers = teams.wdz.members;
75     license = licenses.unfree;
76     platforms = [ "x86_64-linux" ];
77   };