nixpkgs mirror (for testing)
github.com/NixOS/nixpkgs
nix
1{
2 lib,
3 stdenv,
4 fetchurl,
5 autoPatchelfHook,
6 bzip2,
7 nixosTests,
8}:
9
10stdenv.mkDerivation rec {
11 pname = "fastnetmon-advanced";
12 version = "2.0.371";
13
14 src = fetchurl {
15 url = "https://repo.fastnetmon.com/fastnetmon_ubuntu_jammy/pool/fastnetmon/f/fastnetmon/fastnetmon_${version}_amd64.deb";
16 hash = "sha256-/qCUeo/2AYIT9Yl6QjoTBPfmg8Lk2efDU5Axv4JU+t8=";
17 };
18
19 nativeBuildInputs = [
20 autoPatchelfHook
21 ];
22
23 buildInputs = [
24 bzip2
25 ];
26
27 unpackPhase = ''
28 ar xf $src
29 tar xf data.tar.xz
30
31 # unused libraries, which have additional dependencies
32 rm opt/fastnetmon/libraries/gcc1210/lib/libgccjit.so*
33 '';
34
35 installPhase = ''
36 mkdir -p $out/libexec/fastnetmon
37 cp -r opt/fastnetmon/app/bin $out/bin
38 cp -r opt/fastnetmon/libraries $out/libexec/fastnetmon
39
40 readlink usr/sbin/gobgpd
41 readlink usr/bin/gobgp
42
43 ln -s $(readlink usr/sbin/gobgpd | sed "s:/opt/fastnetmon:$out/libexec/fastnetmon:") $out/bin/fnm-gobgpd
44 ln -s $(readlink usr/bin/gobgp | sed "s:/opt/fastnetmon:$out/libexec/fastnetmon:") $out/bin/fnm-gobgp
45
46 addAutoPatchelfSearchPath $out/libexec/fastnetmon/libraries
47 '';
48
49 doInstallCheck = true;
50 installCheckPhase = ''
51 set +o pipefail
52 $out/bin/fastnetmon 2>&1 | grep "Can't open log file"
53 $out/bin/fcli 2>&1 | grep "Please run this tool with root rights"
54 $out/bin/fnm-gobgp --help 2>&1 | grep "Available Commands"
55 $out/bin/fnm-gobgpd --help 2>&1 | grep "Application Options"
56 '';
57
58 passthru.tests = { inherit (nixosTests) fastnetmon-advanced; };
59
60 meta = {
61 description = "High performance DDoS detector / sensor - commercial edition";
62 homepage = "https://fastnetmon.com";
63 changelog = "https://github.com/FastNetMon/fastnetmon-advanced-releases/releases/tag/v${version}";
64 sourceProvenance = with lib.sourceTypes; [ binaryNativeCode ];
65 teams = [ lib.teams.wdz ];
66 license = lib.licenses.unfree;
67 platforms = [ "x86_64-linux" ];
68 };
69}