Skip to content

Instantly share code, notes, and snippets.

@msteen
Created February 23, 2019 19:01
Show Gist options
  • Save msteen/87d241a1073d62a44b2f2d7320cae0d7 to your computer and use it in GitHub Desktop.
Save msteen/87d241a1073d62a44b2f2d7320cae0d7 to your computer and use it in GitHub Desktop.
let
macInterfaces = filterAttrs (name: interface: interface.macAddress != null) config.networking.interfaces;
extraUdevRules = pkgs.writeTextDir "10-mac-network.rules" (concatStrings (mapAttrsToList (name: interface: ''
ACTION=="add", SUBSYSTEM=="net", ATTR{address}=="${interface.macAddress}", NAME="${name}"
'') macInterfaces));
in mkIf (!config.networking.usePredictableInterfaceNames && macInterfaces != {}) {
boot.kernelParams = [ "net.ifnames=0" "biosdevname=0" ];
boot.initrd.extraUdevRulesCommands = ''
cp -v ${extraUdevRules}/*.rules $out/
'';
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment