treewide: simplify

This commit is contained in:
Guanran Wang 2023-12-03 16:16:41 +08:00
parent 91dfa05ef9
commit 887c187cb0
Signed by: nyancat
SSH key fingerprint: SHA256:8oWGKciPALWut/6WA27oFKofX+6Wtc0gQnsefXLQx/8
4 changed files with 38 additions and 53 deletions

View file

@ -1,24 +1,23 @@
{ {
pkgs, pkgs,
lib,
config, config,
... ...
}: { }: {
nix.settings = { nix.settings = {
trusted-users = ["@admin"]; trusted-users = ["@admin"];
substituters = substituters =
lib.mkMerge {
[ "Asia/Shanghai" = [
(lib.mkIf (config.time.timeZone == "Asia/Shanghai") [
"https://mirrors.ustc.edu.cn/nix-channels/store" # USTC - 中国科学技术大学 Mirror "https://mirrors.ustc.edu.cn/nix-channels/store" # USTC - 中国科学技术大学 Mirror
"https://mirrors.tuna.tsinghua.edu.cn/nix-channels/store" # TUNA - 清华大学 Mirror "https://mirrors.tuna.tsinghua.edu.cn/nix-channels/store" # TUNA - 清华大学 Mirror
"https://mirrors.bfsu.edu.cn/nix-channels/store" # BFSU - 北京外国语大学 Mirror "https://mirrors.bfsu.edu.cn/nix-channels/store" # BFSU - 北京外国语大学 Mirror
"https://mirror.sjtu.edu.cn/nix-channels/store" # SJTU - 上海交通大学 Mirror "https://mirror.sjtu.edu.cn/nix-channels/store" # SJTU - 上海交通大学 Mirror
]) ];
[ }
.${config.time.timeZone}
++ [
"https://nix-community.cachix.org" "https://nix-community.cachix.org"
"https://cache.garnix.io" "https://cache.garnix.io"
]
]; ];
trusted-public-keys = [ trusted-public-keys = [
"nix-community.cachix.org-1:mB9FSh9qf2dCimDSUo8Zy7bkq5CX+/rkCWyvRCYg3Fs=" "nix-community.cachix.org-1:mB9FSh9qf2dCimDSUo8Zy7bkq5CX+/rkCWyvRCYg3Fs="

View file

@ -17,21 +17,23 @@ in {
}; };
config = { config = {
networking.nameservers = lib.mkMerge [ networking.nameservers =
(lib.mkIf (cfg.provider == "google") [ {
google = [
### Google DNS ### Google DNS
"8.8.8.8" "8.8.8.8"
"8.8.4.4" "8.8.4.4"
"2001:4860:4860::8888" "2001:4860:4860::8888"
"2001:4860:4860::8844" "2001:4860:4860::8844"
]) ];
(lib.mkIf (cfg.provider == "alidns") [ alidns = [
### AliDNS ### AliDNS
"223.5.5.5" "223.5.5.5"
"223.6.6.6" "223.6.6.6"
"2400:3200::1" "2400:3200::1"
"2400:3200:baba::1" "2400:3200:baba::1"
])
]; ];
}
.${cfg.provider};
}; };
} }

View file

@ -1,23 +1,19 @@
{ {config, ...}: {
lib,
config,
...
}: {
nix.settings = { nix.settings = {
trusted-users = ["@wheel"]; trusted-users = ["@wheel"];
substituters = substituters =
lib.mkMerge {
[ "Asia/Shanghai" = [
(lib.mkIf (config.time.timeZone == "Asia/Shanghai") [
"https://mirrors.ustc.edu.cn/nix-channels/store" # USTC - 中国科学技术大学 Mirror "https://mirrors.ustc.edu.cn/nix-channels/store" # USTC - 中国科学技术大学 Mirror
"https://mirrors.tuna.tsinghua.edu.cn/nix-channels/store" # TUNA - 清华大学 Mirror "https://mirrors.tuna.tsinghua.edu.cn/nix-channels/store" # TUNA - 清华大学 Mirror
"https://mirrors.bfsu.edu.cn/nix-channels/store" # BFSU - 北京外国语大学 Mirror "https://mirrors.bfsu.edu.cn/nix-channels/store" # BFSU - 北京外国语大学 Mirror
"https://mirror.sjtu.edu.cn/nix-channels/store" # SJTU - 上海交通大学 Mirror "https://mirror.sjtu.edu.cn/nix-channels/store" # SJTU - 上海交通大学 Mirror
]) ];
[ }
.${config.time.timeZone}
++ [
"https://nix-community.cachix.org" "https://nix-community.cachix.org"
"https://cache.garnix.io" "https://cache.garnix.io"
]
]; ];
trusted-public-keys = [ trusted-public-keys = [
"nix-community.cachix.org-1:mB9FSh9qf2dCimDSUo8Zy7bkq5CX+/rkCWyvRCYg3Fs=" "nix-community.cachix.org-1:mB9FSh9qf2dCimDSUo8Zy7bkq5CX+/rkCWyvRCYg3Fs="
@ -33,13 +29,6 @@
}; };
system = { system = {
# Copy the NixOS configuration file and link it from the resulting system
# (/run/current-system/configuration.nix). This is useful in case you
# accidentally delete configuration.nix.
# Does not work with flake based configurations
copySystemConfiguration = lib.mkDefault true;
# This value determines the NixOS release from which the default # This value determines the NixOS release from which the default
# settings for stateful data, like file locations and database versions # settings for stateful data, like file locations and database versions
# on your system were taken. It's perfectly fine and recommended to leave # on your system were taken. It's perfectly fine and recommended to leave

View file

@ -1,11 +1,7 @@
{ {pkgs, ...}: {
lib,
pkgs,
...
}: {
programs.starship = { programs.starship = {
enable = true; enable = true;
settings = lib.mkMerge [ settings =
{ {
add_newline = false; add_newline = false;
line_break.disabled = true; line_break.disabled = true;
@ -19,7 +15,6 @@
vimcmd_visual_symbol = "[<](bold yellow)"; vimcmd_visual_symbol = "[<](bold yellow)";
}; };
} }
(builtins.fromTOML (builtins.readFile "${pkgs.starship}/share/starship/presets/nerd-font-symbols.toml")) // (builtins.fromTOML (builtins.readFile "${pkgs.starship}/share/starship/presets/nerd-font-symbols.toml"));
];
}; };
} }