about summary refs log tree commit diff
path: root/nixpkgs/pkgs/tools/virtualization/mininet/default.nix
blob: 3d7339bf56b63c0ad6e50aeff0d20776a1a90d8e (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
79
80
81
82
83
84
85
86
87
88
{ stdenv, lib, fetchFromGitHub
, runCommand
, which
, python3
, help2man
, makeWrapper
, ethtool
, inetutils
, iperf
, iproute2
, nettools
, socat
}:

let
  pyEnv = python3.withPackages(ps: [ ps.setuptools ]);

  telnet = runCommand "inetutils-telnet"
    { }
    ''
      mkdir -p "$out/bin"
      ln -s "${inetutils}"/bin/telnet "$out/bin"
    '';

  generatedPath = lib.makeSearchPath "bin" [
    iperf
    ethtool
    iproute2
    socat
    # mn errors out without a telnet binary
    # pkgs.inetutils brings an undesired ifconfig into PATH see #43105
    nettools
    telnet
  ];

in
stdenv.mkDerivation rec {
  pname = "mininet";
  version = "2.3.1b4";

  outputs = [ "out" "py" ];

  src = fetchFromGitHub {
    owner = "mininet";
    repo = "mininet";
    rev = version;
    hash = "sha256-Z7Vbfu0EJ4+rCpckXrt3hgxeB9N2nnyPIXgPBnpV4uw=";
  };

  buildFlags = [ "mnexec" ];
  makeFlags = [ "PREFIX=$(out)" ];

  pythonPath = [ python3.pkgs.setuptools ];
  nativeBuildInputs = [ help2man makeWrapper python3.pkgs.wrapPython ];

  propagatedBuildInputs = [ python3 which ];

  installTargets = [ "install-mnexec" "install-manpages" ];

  preInstall = ''
    mkdir -p $out $py
    # without --root, install fails
    "${pyEnv.interpreter}" setup.py install \
      --root="/" \
      --prefix="$py" \
      --install-scripts="$out/bin"
  '';

  postFixup = ''
    wrapPythonProgramsIn "$out/bin" "$py $pythonPath"
    wrapProgram "$out/bin/mnexec" \
      --prefix PATH : "${generatedPath}"
    wrapProgram "$out/bin/mn" \
      --prefix PATH : "${generatedPath}"
  '';

  doCheck = false;


  meta = with lib; {
    description = "Emulator for rapid prototyping of Software Defined Networks";
    license = licenses.bsd3;
    platforms = platforms.linux;
    homepage = "https://github.com/mininet/mininet";
    maintainers = with maintainers; [ teto ];
    mainProgram = "mnexec";
  };
}