Author: egorochkin
Date: Wed Nov 24 22:58:48 2010
New Revision: 24846
URL: https://svn.nixos.org/websvn/nix/?rev=24846&sc=1

Log:
network-interfaces: support changing MAC addresses of interfaces

Modified:
   nixos/trunk/modules/tasks/network-interfaces.nix

Modified: nixos/trunk/modules/tasks/network-interfaces.nix
==============================================================================
--- nixos/trunk/modules/tasks/network-interfaces.nix    Wed Nov 24 22:58:42 
2010        (r24845)
+++ nixos/trunk/modules/tasks/network-interfaces.nix    Wed Nov 24 22:58:48 
2010        (r24846)
@@ -115,6 +115,15 @@
           '';
         };
 
+        macAddress = mkOption {
+          default = "";
+          example = "00:11:22:33:44:55";
+          type = types.string;
+          description = ''
+            MAC address of the interface. Leave empty to use the default.
+          '';
+        };
+
       };
       
     };
@@ -157,6 +166,16 @@
             export PATH=${config.system.sbin.modprobe}/sbin:$PATH
             modprobe af_packet || true
 
+            ${pkgs.lib.concatMapStrings (i:
+              if i.macAddress != "" then
+                ''
+                  echo "Configuring interface ${i.name}..."
+                  ${ifconfig} "${i.name}" down || true
+                  ${ifconfig} hw ether "${i.name}" "${i.macAddress}" || true
+                ''
+              else "") cfg.interfaces
+            }
+
             for i in $(cd /sys/class/net && ls -d *); do
                 echo "Bringing up network device $i..."
                 ${ifconfig} $i up || true
_______________________________________________
nix-commits mailing list
[email protected]
http://mail.cs.uu.nl/mailman/listinfo/nix-commits

Reply via email to