nixos-rebuild
TLDR
Build and switch to new configuration (make boot default)
SYNOPSIS
nixos-rebuild [switch|boot|test|build|build-vm] [--upgrade] [--rollback] [-p name]
DESCRIPTION
nixos-rebuild reconfigures a NixOS system by building a new configuration from /etc/nixos/configuration.nix and optionally activating it. NixOS uses a declarative configuration model where the entire system is described in Nix expressions.
Each build creates a new generation that can be selected at boot time. This allows safe rollback to previous working configurations if problems occur.
PARAMETERS
--upgrade
Update nixpkgs channel before building--rollback
Roll back to previous generation-p, --profile-name _name_
Name for the boot entry--flake _uri_
Build from flake reference--no-build-nix
Don't rebuild Nix during switch--fast
Skip rebuilding Nix and documentation--show-trace
Show detailed error traces
COMMANDS
switch
Build, activate, and make boot defaultboot
Build and make boot default without activatingtest
Build and activate without making boot entrybuild
Build configuration without activatingbuild-vm
Build and open configuration in virtual machinedry-build
Show what would be builtdry-activate
Show what would change on activationlist-generations
List available system generations
CAVEATS
Requires root privileges for most operations. Configuration errors prevent build completion. Large changes may require significant download and build time. The switch command restarts services that changed.
HISTORY
nixos-rebuild is part of NixOS, the Linux distribution based on the Nix package manager. NixOS was created by Eelco Dolstra and first released in 2003. It pioneered declarative system configuration and atomic upgrades with rollback capability.
SEE ALSO
nix(1), nix-env(1), nix-channel(1)
