nh
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
Chinesenh (Nix Helper)
nh(Nix 辅助工具)
CLI tool that simplifies Nix operations with cleaner interface for builds, switches, and garbage collection.
一款CLI工具,通过更简洁的界面简化Nix操作,涵盖构建、切换和垃圾回收等功能。
Core Commands
核心命令
System Updates (NixOS)
系统更新(NixOS)
Use for managing NixOS configurations. Prefix local paths with .
nh ospath:bash
undefined使用管理NixOS配置。本地路径需添加前缀。
nh ospath:bash
undefinedBuild and switch to a configuration (equivalent to nixos-rebuild switch)
Build and switch to a configuration (equivalent to nixos-rebuild switch)
nh os switch path:.
nh os switch path:.
Build and test a configuration (equivalent to nixos-rebuild test)
Build and test a configuration (equivalent to nixos-rebuild test)
nh os test path:.
nh os test path:.
Build a configuration without switching (equivalent to nixos-rebuild build)
Build a configuration without switching (equivalent to nixos-rebuild build)
nh os build path:.
nh os build path:.
Make configuration the boot default without activating
Make configuration the boot default without activating
nh os boot path:.
nh os boot path:.
Rollback to a previous generation
Rollback to a previous generation
nh os rollback
nh os rollback
List available generations
List available generations
nh os info
nh os info
Build a NixOS VM image
Build a NixOS VM image
nh os build-vm path:.
nh os build-vm path:.
Load system configuration in a REPL (use tmux for interactive)
Load system configuration in a REPL (use tmux for interactive)
tmux new -d -s nh-repl 'nh os repl path:.'
undefinedtmux new -d -s nh-repl 'nh os repl path:.'
undefinedHome Manager Updates
Home Manager 更新
Use for managing Home Manager configurations.
nh homebash
undefined使用管理Home Manager配置。
nh homebash
undefinedBuild and switch Home Manager configuration
Build and switch Home Manager configuration
nh home switch path:.
nh home switch path:.
Build Home Manager configuration without switching
Build Home Manager configuration without switching
nh home build path:.
nh home build path:.
Load Home Manager configuration in a REPL (use tmux for interactive)
Load Home Manager configuration in a REPL (use tmux for interactive)
tmux new -d -s hm-repl 'nh home repl path:.'
undefinedtmux new -d -s hm-repl 'nh home repl path:.'
undefinedNix-Darwin (macOS)
Nix-Darwin(macOS)
Use for managing nix-darwin configurations on macOS.
nh darwinbash
undefined使用管理macOS上的nix-darwin配置。
nh darwinbash
undefinedBuild and switch darwin configuration
Build and switch darwin configuration
nh darwin switch path:.
nh darwin switch path:.
Build darwin configuration without switching
Build darwin configuration without switching
nh darwin build path:.
undefinednh darwin build path:.
undefinedPackage Search
包搜索
Search for packages using search.nixos.org:
bash
undefined通过search.nixos.org搜索包:
bash
undefinedSearch for packages
Search for packages
nh search ripgrep
undefinednh search ripgrep
undefinedMaintenance and Cleanup
维护与清理
nh cleanbash
undefinednh cleanbash
undefinedClean all profiles (system + user)
Clean all profiles (system + user)
nh clean all --keep-since 7d
nh clean all --keep-since 7d
Clean only current user's profiles
Clean only current user's profiles
nh clean user --keep 5
nh clean user --keep 5
Clean a specific profile
Clean a specific profile
nh clean profile /nix/var/nix/profiles/system --keep 3
nh clean profile /nix/var/nix/profiles/system --keep 3
Run garbage collection on the Nix store
Run garbage collection on the Nix store
nh clean all
undefinednh clean all
undefinedCommon Options
通用选项
- : Ask for confirmation before performing actions (Avoid in headless/automated scripts).
--ask - : Show what would happen without making changes.
--dry - : Update flake inputs before building.
--update
- :执行操作前请求确认(在无界面/自动化脚本中避免使用)。
--ask - :显示将要执行的操作但不实际修改。
--dry - :构建前更新flake输入。
--update
Best Practices
最佳实践
- Headless Usage: Avoid using the flag in scripts or automated environments as it requires user interaction.
--ask - Path Inference: automatically looks for a
nhin the current directory if no path is provided.flake.nix - Visuals: provides a more readable "Nom-like" output by default, which is helpful for monitoring build progress in a terminal.
nh
- 无界面使用:在脚本或自动化环境中避免使用标志,因为它需要用户交互。
--ask - 路径推断:如果未提供路径,会自动在当前目录查找
nh文件。flake.nix - 可视化输出:默认提供更易读的“Nom-like”输出,有助于在终端中监控构建进度。
nh
Related Skills
相关技能
- nix: Use Nix for running applications without installation and evaluating Nix expressions.
- nix-flakes: Leverage Nix Flakes for reproducible builds and project isolation with nh.
- nix:使用Nix无需安装即可运行应用程序,并评估Nix表达式。
- nix-flakes:结合nh使用Nix Flakes实现可复现构建和项目隔离。