最近重装了服务器,记录下过程省得以后重新摸索。本文使用 nixos-22.11 频道。

  1. 选择 Debian 11/10 镜像重装

    Ubuntu 22.04 不知道为什么重置密码后登不上去

    这是唯一与“腾讯云轻量应用服务器”有关的内容,以下步骤其他平台也适用。

  2. ssh-copy-id 拷贝 SSH 密钥

  3. 登录服务器,下载 NixOS-Infect with TUNA mirror patch 脚本

    NixOS-Infect 是个类似 vps2arch 的脚本,我做了几处修改以使用 TUNA 镜像,国外机器用原版就好。

    若担心修改版与原版不同步或者不想用 TUNA 请自行打补丁。

  4. 运行脚本,完成后会自动重启服务器

    NIX_CHANNEL=nixos-22.11 bash -x nixos-infect-tuna
    
  5. 重新登录服务器,添加更新频道

    nix-channel --add <https://mirrors.tuna.tsinghua.edu.cn/nix-channels/nixos-22.11> nixos
    nix-channel --update
    
  6. 编辑 /etc/nixos/configuration.nix 修改缓存镜像

    nix.settings.substituters = [
    	"<https://mirrors.tuna.tsinghua.edu.cn/nix-channels/store>"
    ];
    
  1. 不滚系统就只能粗暴地手动更改配置了,可以,这很不 pure

    rm /etc/nix/nix.conf
    cp /etc/{static,}/nix/nix.conf
    

    编辑 /etc/nix/nix.conf

    substituters = <https://mirrors.tuna.tsinghua.edu.cn/nix-channels/store> <https://cache.nixos.org/>
    
  2. 可以愉快地滚系统了

    nixos-rebuild switch