nix-rebuild

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Nix System Rebuild

Nix系统重建

After changing any Nix-managed config in
~/.config/dotfiles
, the system must be rebuilt for changes to take effect. Nix store symlinks are read-only — you cannot edit them in place.
在修改
~/.config/dotfiles
中任何由Nix管理的配置后,必须重建系统才能使变更生效。Nix存储的符号链接是只读的——你无法直接在原地编辑它们。

Quick Rebuild

快速重建

bash
cd ~/.config/dotfiles
sudo darwin-rebuild switch --flake .
darwin-rebuild
has a NOPASSWD sudoers rule, so this works non-interactively.
bash
cd ~/.config/dotfiles
sudo darwin-rebuild switch --flake .
darwin-rebuild
配置了NOPASSWD的sudoers规则,因此无需交互即可运行。

Using hey

使用hey命令

The
hey
command wraps rebuilds:
bash
hey rebuild    # or: hey re
hey test       # build + activate without boot entry
hey rollback   # roll back to previous generation
hey
命令封装了重建操作:
bash
hey rebuild    # 或:hey re
hey test       # 构建并激活,不添加启动项
hey rollback   # 回滚到上一个系统版本

When to Rebuild

何时需要重建

  • After editing any
    .nix
    file
  • After editing config files symlinked through home-manager (lazygit, ghostty, etc.)
  • When you see "permission denied" writing to a Nix store path
  • 编辑任何
    .nix
    文件后
  • 编辑通过home-manager创建符号链接的配置文件(如lazygit、ghostty等)后
  • 当你在写入Nix存储路径时看到“权限被拒绝”提示时

Workflow

工作流程

  1. Edit source config in
    ~/.config/dotfiles/
  2. Commit changes
  3. Run
    sudo darwin-rebuild switch --flake ~/.config/dotfiles
  4. Verify the symlink now points to updated Nix store path
  1. ~/.config/dotfiles/
    中编辑源配置
  2. 提交变更
  3. 运行
    sudo darwin-rebuild switch --flake ~/.config/dotfiles
  4. 验证符号链接现在指向更新后的Nix存储路径