MirrorZ Help

Nix Channels 镜像使用帮助

选择镜像

Nixpkgs binary cache

目前 TUNA/BFSU/USTC 等并未提供 nix-darwin 的 binary cache,请使用官方源或 SJTUG。

持久配置

以优先选择镜像,备选源站为例,选择以下配置之一:

  • 单独安装的 Nix:编辑配置文件添加或修改如下项(多用户安装修改 /etc/nix/nix.conf,单用户安装修改 ~/.config/nix/nix.conf):

    substituters = https://(Loading...)/store https://cache.nixos.org/
  • NixOS 21.11 及之前的版本在 configuration.nix 中使用如下配置(https://cache.nixos.org 会被自动添加)

    nix.binaryCaches = [ "https://(Loading...)/store" ];
  • NixOS 22.05 及之后的版本在 configuration.nix 中使用如下配置(https://cache.nixos.org 会被自动添加):

    nix.settings.substituters = [ "https://(Loading...)/store" ];

    如果因为无法访问 https://cache.nixos.org 等原因,希望避免自动添加该默认地址,请在配置中使用lib.mkForce

    # load `lib` into namespace at the file head with `{ config, pkgs, lib, ... }:`
    nix.settings.substituters = lib.mkForce [ "https://(Loading...)/store" ];

临时使用

在安装 NixOS 时临时使用:

nixos-install --option substituters "https://(Loading...)/store"

在 NixOS 切换配置时临时使用:

nixos-rebuild --option substituters "https://(Loading...)/store"

临时关闭可以通过清空 substituters 实现:

nixos-rebuild --options substituters ""

Nixpkgs channel

注:SJTUG 提供了 binary cache,未提供该镜像。

单独安装的 Nix 替换 nixpkgs-unstable 命令如下:

nix-channel --add https://(Loading...)/nixpkgs-unstable nixpkgs
nix-channel --update

替换 NixOS channel 命令如下(以 root 执行):

系统版本
nix-channel --add https://(Loading...)/nixos-22.11 nixos
nix-channel --update

这个页面的内容有问题?在 GitHub Issue 反馈

想完善这个页面?查看我们的贡献指南在 GitHub 上查看此页的源代码

本页面的全部内容在 CC BY-NC-SA 4.0 协议之条款下提供,附加条款亦可能应用。