nix-rebuild
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseNix System Rebuild
Nix系统重建
After changing any Nix-managed config in , 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存储的符号链接是只读的——你无法直接在原地编辑它们。
~/.config/dotfilesQuick Rebuild
快速重建
bash
cd ~/.config/dotfiles
sudo darwin-rebuild switch --flake .darwin-rebuildbash
cd ~/.config/dotfiles
sudo darwin-rebuild switch --flake .darwin-rebuildUsing hey
使用hey命令
The command wraps rebuilds:
heybash
hey rebuild # or: hey re
hey test # build + activate without boot entry
hey rollback # roll back to previous generationheybash
hey rebuild # 或:hey re
hey test # 构建并激活,不添加启动项
hey rollback # 回滚到上一个系统版本When to Rebuild
何时需要重建
- After editing any file
.nix - 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
工作流程
- Edit source config in
~/.config/dotfiles/ - Commit changes
- Run
sudo darwin-rebuild switch --flake ~/.config/dotfiles - Verify the symlink now points to updated Nix store path
- 在中编辑源配置
~/.config/dotfiles/ - 提交变更
- 运行
sudo darwin-rebuild switch --flake ~/.config/dotfiles - 验证符号链接现在指向更新后的Nix存储路径