Agent skill

rebuild

Apply Nix configuration changes. Use when modifying .nix files, after flake updates, or when user asks to rebuild/apply dotfiles changes.

Stars 163
Forks 31

Install this agent skill to your Project

npx add-skill https://github.com/majiayu000/claude-skill-registry/tree/main/skills/data/rebuild

SKILL.md

<simple_rebuild> Primary method: ./bin/rebuild (or ~/bin/rebuild). Auto-detects platform and user dynamically. Sources nix-daemon.sh if needed. Handles backup naming.

NixOS: Runs sudo nixos-rebuild switch --flake ~/.dotfiles#$(whoami) Non-NixOS: Runs home-manager switch --flake ~/.dotfiles#$(whoami)@$(arch)-linux </simple_rebuild>

<nix_not_found> If nix: command not found: source the daemon profile first. . /nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh Then retry the rebuild command. </nix_not_found>

<dry_run> Validate configuration before applying. Substitute USER with actual username from session:

NixOS: nix build ~/.dotfiles#nixosConfigurations.USER.config.system.build.toplevel --dry-run Non-NixOS: home-manager build --flake ~/.dotfiles#USER@x86_64-linux --dry-run

Dry-run catches syntax errors, missing imports, and evaluation failures without modifying the system. </dry_run>

<platform_difference> NixOS: Full system rebuild with sudo nixos-rebuild switch --flake. Requires sudo. Affects system services, kernel, boot. Home-manager is integrated as a module.

Home-manager standalone: User-level only with home-manager switch --flake. No sudo needed. Affects user packages, dotfiles, services.

Detection: Check /etc/os-release for ID=nixos, or use OS from session-context. The bin/rebuild script handles this automatically. </platform_difference>

On NixOS: May need to ask user to run rebuild (requires sudo). On home-manager standalone: Execute directly, no sudo needed.

<post_rebuild> After rebuild, verify changes applied. Test it and check services are running, dotfiles updated, packages installed as expected. If issues arise, review rebuild output for errors. Re-run dry-run to catch config problems. </post_rebuild>

Didn't find tool you were looking for?

Be as detailed as possible for better results