blob: bbb5c81b0ec38385ceee3eb845e92b827c767c61 [file] [log] [blame]
Serge Bazanski6abe4fa2020-10-03 00:18:34 +02001# Sketchy little module to renamei interfaces by MAC.
2# This only works on startup.
3
4{ config, lib, pkgs, ... }:
5
6with lib;
7let
8 cfg = config.hscloud.renameInterfaces;
9in {
10 options.hscloud.renameInterfaces = mkOption {
11 type = with types; attrsOf (submodule {
12 options = {
13 mac = mkOption {
14 type = types.str;
15 description = ''
16 MAC address to match by, in hexadecimal form (ie. ac:1f:6b:1c:d7:ae).
17 '';
18 };
19 };
20 });
21 description = ''
22 Interfaces to rename by property (eg. MAC address).
23 '';
24 };
25
26 config.services.udev.extraRules = concatStringsSep "\n" (mapAttrsToList (n: v: ''
27 ACTION=="add", SUBSYSTEM=="net", ATTR{address}=="${v.mac}", ATTR{addr_assign_type}=="0", NAME="${n}"
28 '') cfg);
29}