bgpwtf/machines: init edge01.waw
This configures our WAW edge router using NixOS. This replaces our
previous Ubuntu installation.
Change-Id: Ibd72bde66ec413164401da407c5b268ad83fd3af
diff --git a/bgpwtf/machines/modules/rename-interfaces.nix b/bgpwtf/machines/modules/rename-interfaces.nix
new file mode 100644
index 0000000..bbb5c81
--- /dev/null
+++ b/bgpwtf/machines/modules/rename-interfaces.nix
@@ -0,0 +1,29 @@
+# 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);
+}