forked from hswaw/hscloud
Serge Bazanski
6abe4fa771
This configures our WAW edge router using NixOS. This replaces our previous Ubuntu installation. Change-Id: Ibd72bde66ec413164401da407c5b268ad83fd3af
29 lines
784 B
Nix
29 lines
784 B
Nix
# 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);
|
|
}
|