From 920779ee35251f357a2185a54ec525f8b9c55efa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Patrick=20Gro=C3=9Fmann?= Date: Fri, 22 Dec 2023 01:49:38 +0100 Subject: [PATCH] feat: moved first module into shared config --- flake.lock | 6 ++--- modules/config/default.nix | 1 - modules/interface-naming.nix | 49 ------------------------------------ 3 files changed, 3 insertions(+), 53 deletions(-) delete mode 100644 modules/interface-naming.nix diff --git a/flake.lock b/flake.lock index 31ca70a..776b6b2 100644 --- a/flake.lock +++ b/flake.lock @@ -974,11 +974,11 @@ "pre-commit-hooks": "pre-commit-hooks_2" }, "locked": { - "lastModified": 1703205251, - "narHash": "sha256-V8Uxy/g6WRn+ISgBHjs0IY9ZGqjovguNp2FZ2aL+Oqg=", + "lastModified": 1703206032, + "narHash": "sha256-hCuX9y1lUwa8Ck0jruebL2YLhwnDunav/uiIp9EvmNc=", "owner": "oddlama", "repo": "nixos-extra-modules", - "rev": "42374eff1f3ca895d631789e38c04f3f10318abb", + "rev": "073a8ae3b34ed85619dd22bba0d4fb6b6e8e14d1", "type": "github" }, "original": { diff --git a/modules/config/default.nix b/modules/config/default.nix index a86e942..4a7462f 100644 --- a/modules/config/default.nix +++ b/modules/config/default.nix @@ -19,7 +19,6 @@ ../meta.nix ../smb-mounts.nix ../deterministic-ids.nix - ../interface-naming.nix ./impermanence inputs.home-manager.nixosModules.default diff --git a/modules/interface-naming.nix b/modules/interface-naming.nix deleted file mode 100644 index 95de899..0000000 --- a/modules/interface-naming.nix +++ /dev/null @@ -1,49 +0,0 @@ -# Provides an option to easily rename interfaces by their mac addresses. -{ - config, - lib, - pkgs, - ... -}: let - inherit - (lib) - attrValues - concatStringsSep - duplicates - mapAttrsToList - mkIf - mkOption - types - ; - - cfg = config.networking.renameInterfacesByMac; - - interfaceNamesUdevRules = pkgs.writeTextFile { - name = "interface-names-udev-rules"; - text = concatStringsSep "\n" (mapAttrsToList - (name: mac: ''SUBSYSTEM=="net", ACTION=="add", ATTR{address}=="${mac}", NAME:="${name}"'') - cfg); - destination = "/etc/udev/rules.d/01-interface-names.rules"; - }; -in { - options.networking.renameInterfacesByMac = mkOption { - default = {}; - example = {lan = "11:22:33:44:55:66";}; - description = "Allows naming of network interfaces based on their physical address"; - type = types.attrsOf types.str; - }; - - config = mkIf (cfg != {}) { - assertions = let - duplicateMacs = duplicates (attrValues cfg); - in [ - { - assertion = duplicateMacs == []; - message = "Duplicate mac addresses found in network interface name assignment: ${concatStringsSep ", " duplicateMacs}"; - } - ]; - - services.udev.packages = [interfaceNamesUdevRules]; - boot.initrd.services.udev.packages = [interfaceNamesUdevRules]; - }; -}