nixos,networking: add myFlake.nixos.networking.dns

This commit is contained in:
Guanran Wang 2023-11-07 15:08:34 +08:00
parent 32019b25d8
commit b056a38897
Signed by: nyancat
SSH key fingerprint: SHA256:8oWGKciPALWut/6WA27oFKofX+6Wtc0gQnsefXLQx/8
3 changed files with 33 additions and 20 deletions

View file

@ -171,7 +171,6 @@
./nixos/presets/desktop.nix ./nixos/presets/desktop.nix
./nixos/presets/core/zram-generator.nix ./nixos/presets/core/zram-generator.nix
./nixos/presets/core/boot/no-bootloader-menu.nix ./nixos/presets/core/boot/no-bootloader-menu.nix
./nixos/presets/core/networking/alidns.nix
./nixos/presets/desktop/gaming.nix ./nixos/presets/desktop/gaming.nix
./nixos/presets/desktop/virtualbox.nix ./nixos/presets/desktop/virtualbox.nix
./nixos/presets/desktop/wayland.nix ./nixos/presets/desktop/wayland.nix
@ -185,11 +184,14 @@
./machines/nixos/81fw-lenovo-legion-y7000/machine-1 ./machines/nixos/81fw-lenovo-legion-y7000/machine-1
{ {
# extra home-manager stuff
home-manager.users.guanranwang = import ./users/guanranwang/home-manager/nixos/presets/desktop/gaming.nix;
networking.hostName = "81FW-NixOS"; # Hostname networking.hostName = "81FW-NixOS"; # Hostname
time.timeZone = "Asia/Shanghai"; # Timezone time.timeZone = "Asia/Shanghai"; # Timezone
### Home-Manager
home-manager.users.guanranwang = import ./users/guanranwang/home-manager/nixos/presets/desktop/gaming.nix;
### Options
myFlake.nixos.networking.dns = "alidns";
} }
]; ];
}; };

View file

@ -1,9 +1,29 @@
{...}: { {
networking.nameservers = [ lib,
### Google DNS config,
"8.8.8.8" ...
"8.8.4.4" }: {
"2001:4860:4860::8888" options.myFlake.nixos.networking.dns = lib.mkOption {
"2001:4860:4860::8844" type = lib.types.string;
default = "google";
example = "alidns";
description = "Select your 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"
])
]; ];
} }

View file

@ -1,9 +0,0 @@
{lib, ...}: {
networking.nameservers = lib.mkForce [
### AliDNS
"223.5.5.5"
"223.6.6.6"
"2400:3200::1"
"2400:3200:baba::1"
];
}