nixpkgs mirror (for testing)
github.com/NixOS/nixpkgs
nix
1{
2 stdenv,
3 lib,
4 fetchFromGitHub,
5 runCommand,
6 which,
7 python3,
8 help2man,
9 makeWrapper,
10 ethtool,
11 inetutils,
12 iperf,
13 iproute2,
14 net-tools,
15 socat,
16}:
17
18let
19 pyEnv = python3.withPackages (ps: [
20 ps.setuptools
21 ps.packaging
22 ps.distutils
23 ]);
24
25 telnet = runCommand "inetutils-telnet" { } ''
26 mkdir -p "$out/bin"
27 ln -s "${inetutils}"/bin/telnet "$out/bin"
28 '';
29
30 generatedPath = lib.makeSearchPath "bin" [
31 iperf
32 ethtool
33 iproute2
34 socat
35 # mn errors out without a telnet binary
36 # pkgs.inetutils brings an undesired ifconfig into PATH see #43105
37 net-tools
38 telnet
39 ];
40
41in
42stdenv.mkDerivation (finalAttrs: {
43 pname = "mininet";
44 version = "2.3.1b4";
45
46 outputs = [
47 "out"
48 "py"
49 ];
50
51 src = fetchFromGitHub {
52 owner = "mininet";
53 repo = "mininet";
54 rev = finalAttrs.version;
55 hash = "sha256-Z7Vbfu0EJ4+rCpckXrt3hgxeB9N2nnyPIXgPBnpV4uw=";
56 };
57
58 buildFlags = [ "mnexec" ];
59 makeFlags = [ "PREFIX=$(out)" ];
60
61 pythonPath = [ python3.pkgs.setuptools ];
62 nativeBuildInputs = [
63 help2man
64 makeWrapper
65 python3.pkgs.wrapPython
66 ];
67
68 propagatedBuildInputs = [
69 pyEnv
70 which
71 ];
72
73 installTargets = [
74 "install-mnexec"
75 "install-manpages"
76 ];
77
78 preInstall = ''
79 mkdir -p $out $py
80 # without --root, install fails
81 "${pyEnv.interpreter}" setup.py install \
82 --root="/" \
83 --prefix="$py" \
84 --install-scripts="$out/bin"
85 '';
86
87 postFixup = ''
88 wrapPythonProgramsIn "$out/bin" "$py ''${pythonPath[*]}"
89 wrapProgram "$out/bin/mnexec" \
90 --prefix PATH : "${generatedPath}"
91 wrapProgram "$out/bin/mn" \
92 --prefix PATH : "${generatedPath}"
93 '';
94
95 doCheck = false;
96
97 meta = {
98 description = "Emulator for rapid prototyping of Software Defined Networks";
99 license = lib.licenses.bsd3;
100 platforms = lib.platforms.linux;
101 homepage = "https://github.com/mininet/mininet";
102 maintainers = with lib.maintainers; [ teto ];
103 mainProgram = "mnexec";
104 };
105})