Skip to content

Instantly share code, notes, and snippets.

@livnev
Created February 23, 2019 20:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save livnev/344df5eba299cb9ed784a98c86b45713 to your computer and use it in GitHub Desktop.
Save livnev/344df5eba299cb9ed784a98c86b45713 to your computer and use it in GitHub Desktop.
networking.usePredictableInterfaceNames = false;
boot.kernelParams = [ "net.ifnames=0" "biosdevname=0" ];
boot.initrd.extraUdevRulesCommands = with lib;
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 ''
cp -v ${extraUdevRules}/*.rules $out/
'';
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment