2018-11-21 23:33:10 +00:00
|
|
|
# Global configuration for mininet
|
|
|
|
# kernel must have NETNS/VETH/SCHED
|
|
|
|
{ config, lib, pkgs, ... }:
|
|
|
|
|
|
|
|
with lib;
|
|
|
|
|
|
|
|
let
|
|
|
|
cfg = config.programs.mininet;
|
|
|
|
|
|
|
|
generatedPath = with pkgs; makeSearchPath "bin" [
|
2021-03-14 16:05:16 +00:00
|
|
|
iperf ethtool iproute2 socat
|
2018-11-21 23:33:10 +00:00
|
|
|
];
|
|
|
|
|
|
|
|
pyEnv = pkgs.python.withPackages(ps: [ ps.mininet-python ]);
|
|
|
|
|
|
|
|
mnexecWrapped = pkgs.runCommand "mnexec-wrapper"
|
2022-09-24 21:28:38 +00:00
|
|
|
{ nativeBuildInputs = [ pkgs.makeWrapper pkgs.pythonPackages.wrapPython ]; }
|
2018-11-21 23:33:10 +00:00
|
|
|
''
|
|
|
|
makeWrapper ${pkgs.mininet}/bin/mnexec \
|
|
|
|
$out/bin/mnexec \
|
|
|
|
--prefix PATH : "${generatedPath}"
|
|
|
|
|
|
|
|
ln -s ${pyEnv}/bin/mn $out/bin/mn
|
|
|
|
|
|
|
|
# mn errors out without a telnet binary
|
2022-04-17 00:46:33 +00:00
|
|
|
# pkgs.inetutils brings an undesired ifconfig into PATH see #43105
|
|
|
|
ln -s ${pkgs.inetutils}/bin/telnet $out/bin/telnet
|
2018-11-21 23:33:10 +00:00
|
|
|
'';
|
|
|
|
in
|
|
|
|
{
|
|
|
|
options.programs.mininet.enable = mkEnableOption (lib.mdDoc "Mininet");
|
|
|
|
|
|
|
|
config = mkIf cfg.enable {
|
|
|
|
|
|
|
|
virtualisation.vswitch.enable = true;
|
|
|
|
|
|
|
|
environment.systemPackages = [ mnexecWrapped ];
|
|
|
|
};
|
|
|
|
}
|