default.nix (792B)
1 { 2 lib, 3 options, 4 config, 5 ... 6 }: 7 { 8 options.modules.networkmanager = { 9 enable = lib.mkOption { 10 description = "Whether to enable NetworkManager."; 11 default = false; 12 type = lib.types.bool; 13 }; 14 randomiseMacAddress = lib.mkOption { 15 description = "Whether to randomise the MAC address of each interface."; 16 default = false; 17 type = lib.types.bool; 18 }; 19 }; 20 21 config = lib.mkIf config.modules.networkmanager.enable { 22 networking.networkmanager = 23 let 24 inherit (config.modules.networkmanager) randomiseMacAddress; 25 macAddress = if randomiseMacAddress then "random" else "preserve"; 26 in 27 { 28 enable = true; 29 wifi = { inherit macAddress; }; 30 ethernet = { inherit macAddress; }; 31 }; 32 }; 33 }