diff --git a/_data/options.yml b/_data/options.yml index da7de00..f779ead 100644 --- a/_data/options.yml +++ b/_data/options.yml @@ -247,7 +247,11 @@ mirror_desc: - name: neurodebian desc: 用于神经科学研究的 Debian 软件包源 - name: nix - desc: NixOS 软件源 + desc: Nix 软件包管理器 + - name: nix-channels + desc: Nixpkgs 软件包发行版 + - name: nixos-images + desc: NixOS 的安装镜像和虚拟机镜像 - name: nodejs-release desc: 预编译的 Node.js 二进制程序 - name: nodesource diff --git a/_posts/help/2019-02-17-nix.md b/_posts/help/2019-02-17-nix.md index 7c4e1ad..2f96c1d 100644 --- a/_posts/help/2019-02-17-nix.md +++ b/_posts/help/2019-02-17-nix.md @@ -6,7 +6,7 @@ mirrorid: nix ## Nix 镜像使用帮助 -[Nix](https://nixos.org/nix) 是一个支持 Linux 和 Mac OS X 的独特的“函数式包管理器”,具有原子更新、依赖隔离、构建尽可能可复现等特点。 +[Nix](https://nixos.org/nix) 是一个支持 Linux 和 macOS 的独特的“函数式包管理器”,具有原子更新、依赖隔离、构建尽可能可复现等特点。 [Nixpkgs](https://nixos.org/nixpkgs) 是 Nix 包管理器对应的软件发行版,使用 Nix 函数式语言编写,除软件包外提供用于软件定制、构建、开发环境配置的工具。 @@ -17,14 +17,60 @@ mirrorid: nix 细节内容,请参见 Nix 文档中的 [Installing a Binary Distribution](https://nixos.org/nix/manual/#ch-installing-binary) 一节。 - 单用户安装 + ```console $ sh <(curl https://mirrors.tuna.tsinghua.edu.cn/nix/latest/install) ``` - 多用户安装: + ```console $ sh <(curl https://mirrors.tuna.tsinghua.edu.cn/nix/latest/install) --daemon ``` 如果需要,可以在[文件列表中手动挑选需要的版本](https://mirrors.tuna.tsinghua.edu.cn/nix)。 -目前暂时没有 Nixpkgs 软件包的镜像,敬请期待。 +### NixOS + +NixOS 的安装镜像和 OVF 虚拟机镜像可以在镜像站首页“下载链接”处或 下载。 + +### Nixpkgs binary cache + +Binary cache 的镜像位于 ,与 channel 同步更新。 + +以优先选择镜像,备选源站为例,选择以下配置之一: + +- 单独安装的 Nix:编辑配置文件添加或修改如下项(通常系统配置在 `/etc/nix/nix.conf`,用户配置在 `~/.config/nix/nix.conf`): + + ```plain + substituters = https://mirrors.tuna.tsinghua.edu.cn/nix-channels/store https://cache.nixos.org/ + ``` + +- NixOS 和 nix-darwin 使用如下配置: + + ```nix + nix.binaryCaches = [ "https://mirrors.tuna.tsinghua.edu.cn/nix-channels/store" "https://cache.nixos.org/" ]; + ``` + +- NixOS 19.09 及以后版本和 nix-darwin 中系统会自动配置备选源站,也可用如下配置: + + ```nix + nix.binaryCaches = [ "https://mirrors.tuna.tsinghua.edu.cn/nix-channels/store" ]; + ``` + +### Nixpkgs channel + +Channel 的镜像位于 目录下,使用方式与 相同。 + +单独安装的 Nix 替换 `nixpkgs-unstable` 命令如下: + +```console +$ nix-channel --add https://mirrors.tuna.tsinghua.edu.cn/nix-channels/nixpkgs-unstable +$ nix-channel --update +``` + +替换 NixOS channel 命令如下(以 root 执行,将 `19.09` 替换为系统版本): + +```console +# nix-channel --add https://mirrors.tuna.tsinghua.edu.cn/nix-channels/nixos-19.09 +# nix-channel --update +```