# Sketchy little module to renamei interfaces by MAC. # This only works on startup. { config, lib, pkgs, ... }: with lib; let cfg = config.hscloud.renameInterfaces; in { options.hscloud.renameInterfaces = mkOption { type = with types; attrsOf (submodule { options = { mac = mkOption { type = types.str; description = '' MAC address to match by, in hexadecimal form (ie. ac:1f:6b:1c:d7:ae). ''; }; }; }); description = '' Interfaces to rename by property (eg. MAC address). ''; }; config.services.udev.extraRules = concatStringsSep "\n" (mapAttrsToList (n: v: '' ACTION=="add", SUBSYSTEM=="net", ATTR{address}=="${v.mac}", ATTR{addr_assign_type}=="0", NAME="${n}" '') cfg); }