summary refs log tree commit diff
path: root/nixos/modules
diff options
context:
space:
mode:
authorhexclover2023-11-27 11:29:51 +0800
committerJörg Thalheim2023-11-29 10:16:52 +0100
commitc4b3e88a351a11dd1e3bc3840326307c39d33df7 (patch)
treeb5f8c4c33624eb03a13c183c1d57bf9d9a21a1e2 /nixos/modules
parentbb6b6a806b83fd08406bdf99851d0f73706b0479 (diff)
nixos/mininet: wrap with mininet in PYTHONPATH and ifconfig in PATH
(cherry picked from commit 4e6fc83b980ebd91d7cb3b24e5a2927f1d158520)
Diffstat (limited to 'nixos/modules')
-rw-r--r--nixos/modules/programs/mininet.nix33
1 files changed, 23 insertions, 10 deletions
diff --git a/nixos/modules/programs/mininet.nix b/nixos/modules/programs/mininet.nix
index 02272729d233..01ffd811e70e 100644
--- a/nixos/modules/programs/mininet.nix
+++ b/nixos/modules/programs/mininet.nix
@@ -5,26 +5,39 @@
 with lib;
 
 let
-  cfg  = config.programs.mininet;
+  cfg = config.programs.mininet;
 
-  generatedPath = with pkgs; makeSearchPath "bin"  [
-    iperf ethtool iproute2 socat
+  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.python.withPackages(ps: [ ps.mininet-python ]);
+  pyEnv = pkgs.python3.withPackages (ps: [ ps.mininet-python ]);
 
   mnexecWrapped = pkgs.runCommand "mnexec-wrapper"
-    { nativeBuildInputs = [ pkgs.makeWrapper pkgs.pythonPackages.wrapPython ]; }
+    { nativeBuildInputs = [ pkgs.makeWrapper pkgs.python3Packages.wrapPython ]; }
     ''
       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
-      # pkgs.inetutils brings an undesired ifconfig into PATH see #43105
-      ln -s ${pkgs.inetutils}/bin/telnet $out/bin/telnet
+      makeWrapper ${pyEnv}/bin/mn \
+        $out/bin/mn \
+        --prefix PYTHONPATH : "${pyEnv}/${pyEnv.sitePackages}" \
+        --prefix PATH : "${generatedPath}"
     '';
 in
 {