diff options
author | Nick Cao <nickcao@nichi.co> | 2023-12-28 12:21:40 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-12-28 12:21:40 -0500 |
commit | 0cc24b07fc9afc8970a2116e1bb6cc9fb424cd1f (patch) | |
tree | f4acaa6df53b261070559e25f8f266f54b5498b0 | |
parent | 95c7ab7555072c58ac6853b9fcbc84e240f1be8f (diff) | |
parent | 9813c7b684f1da40b613bdec659d96cc69bc111d (diff) |
Merge pull request #276095 from NixOS/backport-272718-to-release-23.11
[Backport release-23.11] mininet: fix enabling the module & installing the Python package at the same time
-rw-r--r-- | nixos/modules/programs/mininet.nix | 35 | ||||
-rw-r--r-- | pkgs/tools/virtualization/mininet/default.nix | 42 |
2 files changed, 41 insertions, 36 deletions
diff --git a/nixos/modules/programs/mininet.nix b/nixos/modules/programs/mininet.nix index 01ffd811e70e2..3568736854d8e 100644 --- a/nixos/modules/programs/mininet.nix +++ b/nixos/modules/programs/mininet.nix @@ -6,39 +6,6 @@ with lib; let 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 { options.programs.mininet.enable = mkEnableOption (lib.mdDoc "Mininet"); @@ -47,6 +14,6 @@ in virtualisation.vswitch.enable = true; - environment.systemPackages = [ mnexecWrapped ]; + environment.systemPackages = [ pkgs.mininet ]; }; } diff --git a/pkgs/tools/virtualization/mininet/default.nix b/pkgs/tools/virtualization/mininet/default.nix index c33389861dd0a..3d7339bf56b63 100644 --- a/pkgs/tools/virtualization/mininet/default.nix +++ b/pkgs/tools/virtualization/mininet/default.nix @@ -1,11 +1,38 @@ { 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"; @@ -24,7 +51,7 @@ stdenv.mkDerivation rec { makeFlags = [ "PREFIX=$(out)" ]; pythonPath = [ python3.pkgs.setuptools ]; - nativeBuildInputs = [ help2man ]; + nativeBuildInputs = [ help2man makeWrapper python3.pkgs.wrapPython ]; propagatedBuildInputs = [ python3 which ]; @@ -33,7 +60,18 @@ stdenv.mkDerivation rec { preInstall = '' mkdir -p $out $py # 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; |