LinuxCommandLibrary

nixos-rebuild

TLDR

Build and switch to new configuration (make boot default)

$ sudo nixos-rebuild switch
copy
Build and switch with custom profile name
$ sudo nixos-rebuild switch -p [name]
copy
Build, switch, and install updates
$ sudo nixos-rebuild switch --upgrade
copy
Rollback to previous generation
$ sudo nixos-rebuild switch --rollback
copy
Build and make boot default without activating
$ sudo nixos-rebuild boot
copy
Build and test without making boot entry
$ sudo nixos-rebuild test
copy
Build configuration and run in virtual machine
$ sudo nixos-rebuild build-vm
copy
List available generations
$ nixos-rebuild list-generations
copy

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 default
boot
Build and make boot default without activating
test
Build and activate without making boot entry
build
Build configuration without activating
build-vm
Build and open configuration in virtual machine
dry-build
Show what would be built
dry-activate
Show what would change on activation
list-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)

> TERMINAL_GEAR

Curated for the Linux community

Lenovo Gen 13 ThinkPad X1 Carbon Touchscreen Laptop with Intel Ultra 7 265U Processor, 14" WUXGA 100% sRGB, 32GB DDR5 RAM, 1TB NVMe Performance SSD, FHD+ IR+ RGB Camera, and Windows 11 Pro

Lenovo Gen 13 ThinkPad X1 Carbon Touchscreen Laptop with Intel Ultra 7 265U Processor, 14" WUXGA 100% sRGB, 32GB DDR5 RAM, 1TB NVMe Performance SSD, FHD+ IR+ RGB Camera, and Windows 11 Pro

$1,589.00
Raspberry Pi 5 8GB

Raspberry Pi 5 8GB

$134.50
GMKtec Gaming PC, K11 AMD Ryzen 9 8945HS, 32GB DDR5 RAM 1TB Mini PC Desktop Computer, Oculink, Dual NIC 2.5GbE LAN, HDMI/DisplayPort/USB4*2

GMKtec Gaming PC, K11 AMD Ryzen 9 8945HS, 32GB DDR5 RAM 1TB Mini PC Desktop Computer, Oculink, Dual NIC 2.5GbE LAN, HDMI/DisplayPort/USB4*2

$739.99
Copied to clipboard

> TERMINAL_GEAR

Curated for the Linux community

BOSGAME Mini PC N95, Intel 12th Mini Computers| 16GB DDR4 RAM| 512GB M.2 2280 SSD| 4K 60HZ Triple Displays by Dual HDMI+Type-C, 6W TDP Quiet Mini PC, WIFI5, BT 5.0 Office

BOSGAME Mini PC N95, Intel 12th Mini Computers| 16GB DDR4 RAM| 512GB M.2 2280 SSD| 4K 60HZ Triple Displays by Dual HDMI+Type-C, 6W TDP Quiet Mini PC, WIFI5, BT 5.0 Office

$239.99
GMKtec Gaming PC, K11 AMD Ryzen 9 8945HS, 32GB DDR5 RAM 1TB Mini PC Desktop Computer, Oculink, Dual NIC 2.5GbE LAN, HDMI/DisplayPort/USB4*2

GMKtec Gaming PC, K11 AMD Ryzen 9 8945HS, 32GB DDR5 RAM 1TB Mini PC Desktop Computer, Oculink, Dual NIC 2.5GbE LAN, HDMI/DisplayPort/USB4*2

$739.99
Raspberry Pi 5 8GB

Raspberry Pi 5 8GB

$134.50