modules: cleanup myFlake.{nixos,darwin}.networking.dns

This commit is contained in:
Guanran Wang 2023-11-19 13:33:31 +08:00
parent 5fe1d802b8
commit 6763cdbedc
Signed by: nyancat
SSH key fingerprint: SHA256:8oWGKciPALWut/6WA27oFKofX+6Wtc0gQnsefXLQx/8
4 changed files with 62 additions and 46 deletions

View file

@ -2,28 +2,36 @@
lib, lib,
config, config,
... ...
}: { }: let
options.myFlake.darwin.networking.dns = lib.mkOption { cfg = config.myFlake.darwin.networking.dns;
type = lib.types.enum ["google" "alidns"]; in {
default = "google"; options = {
example = "alidns"; myFlake.darwin.networking.dns = {
description = "Select your DNS provider"; provider = lib.mkOption {
type = lib.types.enum ["google" "alidns"];
default = "google";
example = "alidns";
description = "Select desired DNS provider.";
};
};
}; };
config.networking.dns = lib.mkMerge [ config = {
(lib.mkIf (config.myFlake.darwin.networking.dns == "google") [ networking.dns = lib.mkMerge [
### Google DNS (lib.mkIf (cfg.provider == "google") [
"8.8.8.8" ### Google DNS
"8.8.4.4" "8.8.8.8"
"2001:4860:4860::8888" "8.8.4.4"
"2001:4860:4860::8844" "2001:4860:4860::8888"
]) "2001:4860:4860::8844"
(lib.mkIf (config.myFlake.darwin.networking.dns == "alidns") [ ])
### AliDNS (lib.mkIf (cfg.provider == "alidns") [
"223.5.5.5" ### AliDNS
"223.6.6.6" "223.5.5.5"
"2400:3200::1" "223.6.6.6"
"2400:3200:baba::1" "2400:3200::1"
]) "2400:3200:baba::1"
]; ])
];
};
} }

View file

@ -2,28 +2,36 @@
lib, lib,
config, config,
... ...
}: { }: let
options.myFlake.nixos.networking.dns = lib.mkOption { cfg = config.myFlake.nixos.networking.dns;
type = lib.types.enum ["google" "alidns"]; in {
default = "google"; options = {
example = "alidns"; myFlake.nixos.networking.dns = {
description = "Select desired DNS provider."; provider = lib.mkOption {
type = lib.types.enum ["google" "alidns"];
default = "google";
example = "alidns";
description = "Select desired DNS provider.";
};
};
}; };
config.networking.nameservers = lib.mkMerge [ config = {
(lib.mkIf (config.myFlake.nixos.networking.dns == "google") [ networking.nameservers = lib.mkMerge [
### Google DNS (lib.mkIf (cfg.provider == "google") [
"8.8.8.8" ### Google DNS
"8.8.4.4" "8.8.8.8"
"2001:4860:4860::8888" "8.8.4.4"
"2001:4860:4860::8844" "2001:4860:4860::8888"
]) "2001:4860:4860::8844"
(lib.mkIf (config.myFlake.nixos.networking.dns == "alidns") [ ])
### AliDNS (lib.mkIf (cfg.provider == "alidns") [
"223.5.5.5" ### AliDNS
"223.6.6.6" "223.5.5.5"
"2400:3200::1" "223.6.6.6"
"2400:3200:baba::1" "2400:3200::1"
]) "2400:3200:baba::1"
]; ])
];
};
} }

View file

@ -15,7 +15,7 @@
}; };
### Options ### Options
myFlake.darwin.networking.dns = lib.mkDefault "alidns"; myFlake.darwin.networking.dns.provider = lib.mkDefault "alidns";
time.timeZone = lib.mkDefault "Asia/Shanghai"; time.timeZone = lib.mkDefault "Asia/Shanghai";
### Flakes ### Flakes

View file

@ -24,7 +24,7 @@
programs.fish.enable = true; programs.fish.enable = true;
### Options ### Options
myFlake.nixos.networking.dns = lib.mkDefault "alidns"; myFlake.nixos.networking.dns.provider = lib.mkDefault "alidns";
time.timeZone = lib.mkDefault "Asia/Shanghai"; time.timeZone = lib.mkDefault "Asia/Shanghai";
### Flakes ### Flakes