about summary refs log tree commit diff
path: root/pkgs/tools/security/networkminer/default.nix
blob: f83c6b3e2415e6e266c324d4c9c3888385b299df (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
{ lib
, buildDotnetModule
, fetchurl
, unzip
, dos2unix
, msbuild
, mono
}:
buildDotnetModule rec {
  pname = "networkminer";
  version = "2.8";

  src = fetchurl {
    # Upstream does not provide versioned releases, a mirror has been uploaded
    # to archive.org
    url = "https://archive.org/download/networkminer-${lib.replaceStrings ["."] ["-"] version}/NetworkMiner_${lib.replaceStrings ["."] ["-"] version}_source.zip";
    sha256 = "1n2312acq5rq0jizlcfk0crslx3wgcsd836p47nk3pnapzw0cqvv";
  };

  nativeBuildInputs = [ unzip dos2unix msbuild ];

  patches = [
    # Store application data in XDG_DATA_DIRS instead of trying to write to nix store
    ./xdg-dirs.patch
  ];

  postPatch = ''
    # Not all files have UTF-8 BOM applied consistently
    find . -type f -exec dos2unix -m {} \+

    # Embedded base64-encoded app icon in resx fails to parse. Delete it
    sed -zi 's|<data name="$this.Icon".*</data>||g' NetworkMiner/NamedPipeForm.resx
    sed -zi 's|<data name="$this.Icon".*</data>||g' NetworkMiner/UpdateCheck.resx
  '';

  nugetDeps = ./deps.nix;

  buildPhase = ''
    runHook preBuild

    msbuild /p:Configuration=Release NetworkMiner.sln

    runHook postBuild
  '';

  installPhase = ''
    runHook preInstall

    mkdir -p $out/bin $out/share
    cp -r NetworkMiner/bin/Release $out/share/NetworkMiner
    makeWrapper ${mono}/bin/mono $out/bin/NetworkMiner \
      --add-flags "$out/share/NetworkMiner/NetworkMiner.exe" \
      --add-flags "--noupdatecheck"

    install -D NetworkMiner/NetworkMiner.desktop $out/share/applications/NetworkMiner.desktop
    substituteInPlace $out/share/applications/NetworkMiner.desktop \
      --replace "Exec=mono NetworkMiner.exe %f" "Exec=NetworkMiner" \
      --replace "Icon=./networkminericon-96x96.png" "Icon=NetworkMiner"
    install -D NetworkMiner/networkminericon-96x96.png $out/share/pixmaps/NetworkMiner.png

    runHook postInstall
  '';

  meta = with lib; {
    description = "Open Source Network Forensic Analysis Tool (NFAT)";
    homepage = "https://www.netresec.com/?page=NetworkMiner";
    license = licenses.gpl2Only;
    maintainers = with maintainers; [ emilytrau ];
    platforms = platforms.linux;
    mainProgram = "NetworkMiner";
  };
}