feat: moved first module into shared config
This commit is contained in:
parent
5ffcba1e46
commit
920779ee35
|
@ -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": {
|
||||
|
|
|
@ -19,7 +19,6 @@
|
|||
../meta.nix
|
||||
../smb-mounts.nix
|
||||
../deterministic-ids.nix
|
||||
../interface-naming.nix
|
||||
./impermanence
|
||||
|
||||
inputs.home-manager.nixosModules.default
|
||||
|
|
|
@ -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];
|
||||
};
|
||||
}
|
Loading…
Reference in a new issue