From 3af3076a869633479b2cfb6f2e5bb63463d6f4de Mon Sep 17 00:00:00 2001 From: Origami404 Date: Sat, 16 May 2026 23:48:31 +0800 Subject: [PATCH] hosts: add nix-cache module --- hosts/eris/configuration.nix | 7 ++---- hosts/modules/nix-cache.nix | 27 ++++++++++++++++++++++++ hosts/oparic-local-dev/configuration.nix | 7 ++---- 3 files changed, 31 insertions(+), 10 deletions(-) create mode 100644 hosts/modules/nix-cache.nix diff --git a/hosts/eris/configuration.nix b/hosts/eris/configuration.nix index d0d3968..ccb8e6a 100644 --- a/hosts/eris/configuration.nix +++ b/hosts/eris/configuration.nix @@ -10,10 +10,9 @@ # Include the results of the hardware scan. ./hardware-configuration.nix inputs.sops-nix.nixosModules.sops + ../modules/nix-cache.nix ]; - nix.settings.experimental-features = [ "nix-command" "flakes" ]; - boot.loader = { efi = { canTouchEfiVariables = true; @@ -32,10 +31,8 @@ time.timeZone = "Asia/Shanghai"; nix.settings = { + experimental-features = [ "nix-command" "flakes" ]; trusted-users = [ "origami" ]; - substituters = [ - "https://mirrors.ustc.edu.cn/nix-channels/store" - ]; auto-optimise-store = true; }; diff --git a/hosts/modules/nix-cache.nix b/hosts/modules/nix-cache.nix new file mode 100644 index 0000000..0046799 --- /dev/null +++ b/hosts/modules/nix-cache.nix @@ -0,0 +1,27 @@ +{ inputs, lib, pkgs, ... }: + +{ + nix.settings = { + substituters = + let + channelStore = x: "https://${x}/nix-channels/store"; + mirrors = map (x: channelStore "mirrors.${x}.edu.cn") [ + "bfsu" + "tuna.tsinghua" + "ustc" + ]; + cachix = x: "https://${x}.cachix.org"; + in + lib.flatten [ + mirrors + (cachix "nix-community") + "https://cache.nixos.org" + (cachix "inclyc") + ]; + trusted-public-keys = [ + "nix-community.cachix.org-1:mB9FSh9qf2dCimDSUo8Zy7bkq5CX+/rkCWyvRCYg3Fs=" + "inclyc.cachix.org-1:izGZ+f/JLPovKX1OKd3rQZ8nPOCpvPij3+bebjxdZ2k=" + ]; + builders-use-substitutes = true; + }; +} diff --git a/hosts/oparic-local-dev/configuration.nix b/hosts/oparic-local-dev/configuration.nix index 3368aa5..3073f3e 100644 --- a/hosts/oparic-local-dev/configuration.nix +++ b/hosts/oparic-local-dev/configuration.nix @@ -5,10 +5,9 @@ [ ./hardware-configuration.nix inputs.sops-nix.nixosModules.sops + ../modules/nix-cache.nix ]; - nix.settings.experimental-features = [ "nix-command" "flakes" ]; - # BIOS + GRUB, 安装到 MBR boot.loader.grub = { enable = true; @@ -29,10 +28,8 @@ time.timeZone = "Asia/Shanghai"; nix.settings = { + experimental-features = [ "nix-command" "flakes" ]; trusted-users = [ "origami" ]; - substituters = [ - "https://mirrors.bfsu.edu.cn/nix-channels/store" - ]; auto-optimise-store = true; };