Mirrors

2026-02-26

记录日常使用中会用到的镜像和代理服务。

System

操作系统相关镜像。

Ubuntu

[[Ubuntu]] 在 24.04 之前的版本软件源默认路径为: /etc/apt/sources.list,最新的位于: /etc/apt/sources.list.d/ubuntu.sources

版本号可以通过 [[lsb_release]] 命令或是 cat /etc/os-release 查看。

参考:

NixOS

Debian

参考:

OpenWRT

参考:

openEuler

参考:

Soft

Docker

因为不可抗拒的因素,目前国内常用镜像站均已失效,下方均是第三方提供的 Docker 镜像站:

  • docker.1ms.run
  • docker.m.daocloud.io

临时使用:

Terminal window
docker pull docker.1ms.run/python

修改 /etc/docker/daemon.json 文件:

Terminal window
# 如果未创建先创建目录
sudo mkdir -p /etc/docker
sudo tee /etc/docker/daemon.json <<-'EOF'
{
"registry-mirrors": [
"https://docker.1ms.run",
"https://docker.m.daocloud.io"
]
}
EOF

修改完成后需要通过 [[systemctl]] 命令重启服务:

Terminal window
sudo systemctl daemon-reload
sudo systemctl restart docker

验证是否修改成功:

Terminal window
docker info | grep -i -C 3 mirrors

参考:

GitHub

GitHub 可以通过修改 /etc/hosts (Linux) C:\Windows\System32\drivers\etc\hosts (Windows) 达到加速的目的:

GitHub 镜像:

  • gitclone.com

临时使用,直接在修改 URL:

Terminal window
# 原始
git clone https://github.com/astral-sh/uv
# 修改后
git clone https://gitclone.com/github.com/astral-sh/uv

参考:

Homebrew

参考:

NVIDIA Container Toolkit

安装 NVIDIA 的 [[nvidia-container-toolkit]] 驱动:

先配置存储库:

Terminal window
curl -fsSL https://mirrors.ustc.edu.cn/libnvidia-container/gpgkey | sudo gpg --dearmor -o /usr/share/keyrings/nvidia-container-toolkit-keyring.gpg \
&& curl -s -L https://mirrors.ustc.edu.cn/libnvidia-container/stable/deb/nvidia-container-toolkit.list | \
sed 's#deb https://nvidia.github.io#deb [signed-by=/usr/share/keyrings/nvidia-container-toolkit-keyring.gpg] https://mirrors.ustc.edu.cn#g' | \
sudo tee /etc/apt/sources.list.d/nvidia-container-toolkit.list

然后更新软件包并安装驱动:

Terminal window
sudo apt update && sudo apt install nvidia-container-toolkit -y

验证是否安装成功:

Terminal window
nvidia-ctk --version

参考:

Nix

以多用户模式在 [[Linux]] 中安装 [[Nix]]

Terminal window
sh <(curl -L https://mirrors.tuna.tsinghua.edu.cn/nix/latest/install) --daemon

配置软件源

这里记录的是在 Linux 中安装的 Nix 配置方式,非 [[#NixOS]] 的配置。

方式一,把当前用户加入到受信任用户列表:

Terminal window
echo "trusted-users = root $USER" | sudo tee -a /etc/nix/nix.conf
sudo systemctl restart nix-daemon

写入软件源到 ~/.config/nix/nix.conf :

Terminal window
cat >> ~/.config/nix/nix.conf << 'EOF'
substituters = https://mirrors.tuna.tsinghua.edu.cn/nix-channels/store https://cache.nixos.org/
trusted-public-keys = cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY=
EOF

方式二,直接写入到系统级配置:

Terminal window
cat >> ~/.config/nix/nix.conf << 'EOF'
substituters = https://mirrors.tuna.tsinghua.edu.cn/nix-channels/store https://cache.nixos.org/
trusted-public-keys = cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY=
EOF

方式三,在 flake.nix 中声明:

Terminal window
{
description = "My Dotfiles";
nixConfig = {
substituters = [
"https://mirrors.tuna.tsinghua.edu.cn/nix-channels/store"
"https://cache.nixos.org/"
];
trusted-public-keys = [
"cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY="
];
};
inputs = { ... };
outputs = { ... };
}

Language

Pypi

[[Python]] pip 源:

[[pip]] 临时使用:

Terminal window
pip install -i https://mirrors.ustc.edu.cn/pypi/simple package

设置为 pip 的默认源:

Terminal window
pip config set global.index-url https://mirrors.ustc.edu.cn/pypi/simple

[[uv]] 临时使用:

Terminal window
uv add loguru --index-url https://pypi.tuna.tsinghua.edu.cn/simple

设置为 uv 的默认源,全局 ~/.config/uv/uv.toml 文件或当前项目 pyproject.toml 文件中添加以下内容:

[[index]]
url = "https://mirrors.ustc.edu.cn/pypi/simple"
default = true

AI

Hugging Face

Hugging Face 镜像站:

[[huggingface_hub]] 和 [[transformers]] 中设置环境变量 HF_ENDPOINT 使用镜像:

Terminal window
export HF_ENDPOINT=https://hf-mirror.com
import os
os.environ["HF_ENDPOINT"] = "https://hf-mirror.com"
from transformers import AutoModel
model = AutoModel.from_pretrained("bert-base-uncased")

如果是 [[Windows]]:

Terminal window
$env:HF_ENDPOINT = "https://hf-mirror.com"

参考