mininet, nixos/mininet: Wrap executables in the package, not the module
Also move the `mn` executable from the Python module to the main package.
This commit is contained in:
parent
ea8bb2df93
commit
66bda599f4
2 changed files with 41 additions and 36 deletions
|
@ -6,39 +6,6 @@ with lib;
|
||||||
|
|
||||||
let
|
let
|
||||||
cfg = config.programs.mininet;
|
cfg = config.programs.mininet;
|
||||||
|
|
||||||
telnet = pkgs.runCommand "inetutils-telnet"
|
|
||||||
{ }
|
|
||||||
''
|
|
||||||
mkdir -p $out/bin
|
|
||||||
ln -s ${pkgs.inetutils}/bin/telnet $out/bin
|
|
||||||
'';
|
|
||||||
|
|
||||||
generatedPath = with pkgs; 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
|
|
||||||
];
|
|
||||||
|
|
||||||
pyEnv = pkgs.python3.withPackages (ps: [ ps.mininet-python ]);
|
|
||||||
|
|
||||||
mnexecWrapped = pkgs.runCommand "mnexec-wrapper"
|
|
||||||
{ nativeBuildInputs = [ pkgs.makeWrapper pkgs.python3Packages.wrapPython ]; }
|
|
||||||
''
|
|
||||||
makeWrapper ${pkgs.mininet}/bin/mnexec \
|
|
||||||
$out/bin/mnexec \
|
|
||||||
--prefix PATH : "${generatedPath}"
|
|
||||||
|
|
||||||
makeWrapper ${pyEnv}/bin/mn \
|
|
||||||
$out/bin/mn \
|
|
||||||
--prefix PYTHONPATH : "${pyEnv}/${pyEnv.sitePackages}" \
|
|
||||||
--prefix PATH : "${generatedPath}"
|
|
||||||
'';
|
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
options.programs.mininet.enable = mkEnableOption (lib.mdDoc "Mininet");
|
options.programs.mininet.enable = mkEnableOption (lib.mdDoc "Mininet");
|
||||||
|
@ -47,6 +14,6 @@ in
|
||||||
|
|
||||||
virtualisation.vswitch.enable = true;
|
virtualisation.vswitch.enable = true;
|
||||||
|
|
||||||
environment.systemPackages = [ mnexecWrapped ];
|
environment.systemPackages = [ pkgs.mininet ];
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,11 +1,38 @@
|
||||||
{ stdenv, lib, fetchFromGitHub
|
{ stdenv, lib, fetchFromGitHub
|
||||||
|
, runCommand
|
||||||
, which
|
, which
|
||||||
, python3
|
, python3
|
||||||
, help2man
|
, help2man
|
||||||
|
, makeWrapper
|
||||||
|
, ethtool
|
||||||
|
, inetutils
|
||||||
|
, iperf
|
||||||
|
, iproute2
|
||||||
|
, nettools
|
||||||
|
, socat
|
||||||
}:
|
}:
|
||||||
|
|
||||||
let
|
let
|
||||||
pyEnv = python3.withPackages(ps: [ ps.setuptools ]);
|
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
|
in
|
||||||
stdenv.mkDerivation rec {
|
stdenv.mkDerivation rec {
|
||||||
pname = "mininet";
|
pname = "mininet";
|
||||||
|
@ -24,7 +51,7 @@ stdenv.mkDerivation rec {
|
||||||
makeFlags = [ "PREFIX=$(out)" ];
|
makeFlags = [ "PREFIX=$(out)" ];
|
||||||
|
|
||||||
pythonPath = [ python3.pkgs.setuptools ];
|
pythonPath = [ python3.pkgs.setuptools ];
|
||||||
nativeBuildInputs = [ help2man ];
|
nativeBuildInputs = [ help2man makeWrapper python3.pkgs.wrapPython ];
|
||||||
|
|
||||||
propagatedBuildInputs = [ python3 which ];
|
propagatedBuildInputs = [ python3 which ];
|
||||||
|
|
||||||
|
@ -33,7 +60,18 @@ stdenv.mkDerivation rec {
|
||||||
preInstall = ''
|
preInstall = ''
|
||||||
mkdir -p $out $py
|
mkdir -p $out $py
|
||||||
# without --root, install fails
|
# without --root, install fails
|
||||||
${pyEnv.interpreter} setup.py install --root="/" --prefix=$py
|
"${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;
|
doCheck = false;
|
||||||
|
|
Loading…
Reference in a new issue