diff --git a/darwin/modules/networking/dns.nix b/darwin/modules/networking/dns.nix index b89815e..da21b8a 100644 --- a/darwin/modules/networking/dns.nix +++ b/darwin/modules/networking/dns.nix @@ -2,28 +2,36 @@ lib, config, ... -}: { - options.myFlake.darwin.networking.dns = lib.mkOption { - type = lib.types.enum ["google" "alidns"]; - default = "google"; - example = "alidns"; - description = "Select your DNS provider"; +}: let + cfg = config.myFlake.darwin.networking.dns; +in { + options = { + myFlake.darwin.networking.dns = { + provider = lib.mkOption { + type = lib.types.enum ["google" "alidns"]; + default = "google"; + example = "alidns"; + description = "Select desired DNS provider."; + }; + }; }; - config.networking.dns = lib.mkMerge [ - (lib.mkIf (config.myFlake.darwin.networking.dns == "google") [ - ### Google DNS - "8.8.8.8" - "8.8.4.4" - "2001:4860:4860::8888" - "2001:4860:4860::8844" - ]) - (lib.mkIf (config.myFlake.darwin.networking.dns == "alidns") [ - ### AliDNS - "223.5.5.5" - "223.6.6.6" - "2400:3200::1" - "2400:3200:baba::1" - ]) - ]; + config = { + networking.dns = lib.mkMerge [ + (lib.mkIf (cfg.provider == "google") [ + ### Google DNS + "8.8.8.8" + "8.8.4.4" + "2001:4860:4860::8888" + "2001:4860:4860::8844" + ]) + (lib.mkIf (cfg.provider == "alidns") [ + ### AliDNS + "223.5.5.5" + "223.6.6.6" + "2400:3200::1" + "2400:3200:baba::1" + ]) + ]; + }; } diff --git a/nixos/modules/networking/dns.nix b/nixos/modules/networking/dns.nix index 80824b0..466888d 100644 --- a/nixos/modules/networking/dns.nix +++ b/nixos/modules/networking/dns.nix @@ -2,28 +2,36 @@ lib, config, ... -}: { - options.myFlake.nixos.networking.dns = lib.mkOption { - type = lib.types.enum ["google" "alidns"]; - default = "google"; - example = "alidns"; - description = "Select desired DNS provider."; +}: let + cfg = config.myFlake.nixos.networking.dns; +in { + options = { + myFlake.nixos.networking.dns = { + provider = lib.mkOption { + type = lib.types.enum ["google" "alidns"]; + default = "google"; + example = "alidns"; + description = "Select desired DNS provider."; + }; + }; }; - config.networking.nameservers = lib.mkMerge [ - (lib.mkIf (config.myFlake.nixos.networking.dns == "google") [ - ### Google DNS - "8.8.8.8" - "8.8.4.4" - "2001:4860:4860::8888" - "2001:4860:4860::8844" - ]) - (lib.mkIf (config.myFlake.nixos.networking.dns == "alidns") [ - ### AliDNS - "223.5.5.5" - "223.6.6.6" - "2400:3200::1" - "2400:3200:baba::1" - ]) - ]; + config = { + networking.nameservers = lib.mkMerge [ + (lib.mkIf (cfg.provider == "google") [ + ### Google DNS + "8.8.8.8" + "8.8.4.4" + "2001:4860:4860::8888" + "2001:4860:4860::8844" + ]) + (lib.mkIf (cfg.provider == "alidns") [ + ### AliDNS + "223.5.5.5" + "223.6.6.6" + "2400:3200::1" + "2400:3200:baba::1" + ]) + ]; + }; } diff --git a/users/guanranwang/darwin/profiles/core/default.nix b/users/guanranwang/darwin/profiles/core/default.nix index fbe3d7d..b8e10ee 100644 --- a/users/guanranwang/darwin/profiles/core/default.nix +++ b/users/guanranwang/darwin/profiles/core/default.nix @@ -15,7 +15,7 @@ }; ### Options - myFlake.darwin.networking.dns = lib.mkDefault "alidns"; + myFlake.darwin.networking.dns.provider = lib.mkDefault "alidns"; time.timeZone = lib.mkDefault "Asia/Shanghai"; ### Flakes diff --git a/users/guanranwang/nixos/profiles/core/default.nix b/users/guanranwang/nixos/profiles/core/default.nix index bf049d9..fd95b15 100644 --- a/users/guanranwang/nixos/profiles/core/default.nix +++ b/users/guanranwang/nixos/profiles/core/default.nix @@ -24,7 +24,7 @@ programs.fish.enable = true; ### Options - myFlake.nixos.networking.dns = lib.mkDefault "alidns"; + myFlake.nixos.networking.dns.provider = lib.mkDefault "alidns"; time.timeZone = lib.mkDefault "Asia/Shanghai"; ### Flakes