From 97072e8eae24c480938e53144ce6974ed0cedeb8 Mon Sep 17 00:00:00 2001 From: Guanran Wang Date: Mon, 27 Nov 2023 20:33:27 +0800 Subject: [PATCH] treewide: set mirrors by timezone --- darwin/profiles/core/nix/nix.nix | 30 ++++++++++++++++++++---------- nixos/profiles/core/nix/nix.nix | 29 +++++++++++++++++++---------- 2 files changed, 39 insertions(+), 20 deletions(-) diff --git a/darwin/profiles/core/nix/nix.nix b/darwin/profiles/core/nix/nix.nix index c365c6d..8d6881a 100755 --- a/darwin/profiles/core/nix/nix.nix +++ b/darwin/profiles/core/nix/nix.nix @@ -1,15 +1,25 @@ -{pkgs, ...}: { +{ + pkgs, + lib, + config, + ... +}: { nix.settings = { trusted-users = ["@admin"]; - substituters = [ - "https://mirrors.ustc.edu.cn/nix-channels/store" # USTC - 中国科学技术大学 Mirror - "https://mirrors.tuna.tsinghua.edu.cn/nix-channels/store" # TUNA - 清华大学 Mirror - "https://mirrors.bfsu.edu.cn/nix-channels/store" # BFSU - 北京外国语大学 Mirror - "https://mirror.sjtu.edu.cn/nix-channels/store" # SJTU - 上海交通大学 Mirror - - "https://nix-community.cachix.org" - "https://cache.garnix.io" - ]; + substituters = + lib.mkMerge + [ + (lib.mkIf (config.time.timeZone == "Asia/Shanghai") [ + "https://mirrors.ustc.edu.cn/nix-channels/store" # USTC - 中国科学技术大学 Mirror + "https://mirrors.tuna.tsinghua.edu.cn/nix-channels/store" # TUNA - 清华大学 Mirror + "https://mirrors.bfsu.edu.cn/nix-channels/store" # BFSU - 北京外国语大学 Mirror + "https://mirror.sjtu.edu.cn/nix-channels/store" # SJTU - 上海交通大学 Mirror + ]) + [ + "https://nix-community.cachix.org" + "https://cache.garnix.io" + ] + ]; trusted-public-keys = [ "nix-community.cachix.org-1:mB9FSh9qf2dCimDSUo8Zy7bkq5CX+/rkCWyvRCYg3Fs=" "cache.garnix.io:CTFPyKSLcx5RMJKfLo5EEPUObbA78b0YQ2DTCJXqr9g=" diff --git a/nixos/profiles/core/nix/nix.nix b/nixos/profiles/core/nix/nix.nix index 51db219..16bd75d 100755 --- a/nixos/profiles/core/nix/nix.nix +++ b/nixos/profiles/core/nix/nix.nix @@ -1,15 +1,24 @@ -{lib, ...}: { +{ + lib, + config, + ... +}: { nix.settings = { trusted-users = ["@wheel"]; - substituters = [ - "https://mirrors.ustc.edu.cn/nix-channels/store" # USTC - 中国科学技术大学 Mirror - "https://mirrors.tuna.tsinghua.edu.cn/nix-channels/store" # TUNA - 清华大学 Mirror - "https://mirrors.bfsu.edu.cn/nix-channels/store" # BFSU - 北京外国语大学 Mirror - "https://mirror.sjtu.edu.cn/nix-channels/store" # SJTU - 上海交通大学 Mirror - - "https://nix-community.cachix.org" - "https://cache.garnix.io" - ]; + substituters = + lib.mkMerge + [ + (lib.mkIf (config.time.timeZone == "Asia/Shanghai") [ + "https://mirrors.ustc.edu.cn/nix-channels/store" # USTC - 中国科学技术大学 Mirror + "https://mirrors.tuna.tsinghua.edu.cn/nix-channels/store" # TUNA - 清华大学 Mirror + "https://mirrors.bfsu.edu.cn/nix-channels/store" # BFSU - 北京外国语大学 Mirror + "https://mirror.sjtu.edu.cn/nix-channels/store" # SJTU - 上海交通大学 Mirror + ]) + [ + "https://nix-community.cachix.org" + "https://cache.garnix.io" + ] + ]; trusted-public-keys = [ "nix-community.cachix.org-1:mB9FSh9qf2dCimDSUo8Zy7bkq5CX+/rkCWyvRCYg3Fs=" "cache.garnix.io:CTFPyKSLcx5RMJKfLo5EEPUObbA78b0YQ2DTCJXqr9g="