Skip to content

Instantly share code, notes, and snippets.

@ottidmes
Created November 19, 2018 00:20
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 ottidmes/eaea270bc321d28742b2ce66fbea529b to your computer and use it in GitHub Desktop.
Save ottidmes/eaea270bc321d28742b2ce66fbea529b to your computer and use it in GitHub Desktop.
# Use predictable interface names we define ourselves that are available in the initial ramdisk as well.
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