Updating NixOS: Difference between revisions
Add section on updating nixos if you are using flakes |
Reference to NixOS manual and re-introduce nixos-rebuild switch --upgrade as a shortcut. |
||
| (2 intermediate revisions by 2 users not shown) | |||
| Line 10: | Line 10: | ||
== For non-flake configurations == | == For non-flake configurations == | ||
What follows is a short set of instructions. Further details can be found in the [https://nixos.org/manual/nixos/stable/#sec-upgrading NixOS Manual.] | |||
=== Updating NixOS channels === | === Updating NixOS channels === | ||
<syntaxhighlight lang="console"> | <syntaxhighlight lang="console"> | ||
# nix-channel --update | # nix-channel --update | ||
</syntaxhighlight> | </syntaxhighlight> | ||
For more information on channels, see the main [[Channel branches]] page. | |||
=== Rebuilding the system after updating channels === | === Rebuilding the system after updating channels === | ||
If you want to not only apply your configuration changes but also update the packages and system environment to the latest versions available from the Nixpkgs repository. This is typically used when you want to ensure you are using the latest versions of your software and system services:<syntaxhighlight lang="console"> | If you want to not only apply your configuration changes but also update the packages and system environment to the latest versions available from the Nixpkgs repository. This is typically used when you want to ensure you are using the latest versions of your software and system services:<syntaxhighlight lang="console"> | ||
# nixos-rebuild switch | |||
</syntaxhighlight>To apply configuration changes and new package updates only '''after''' rebooting the system, use the following command instead:<syntaxhighlight lang="console"> | |||
# nixos-rebuild boot | |||
</syntaxhighlight> | |||
=== Updating channel and rebuilding the system === | |||
The below command is a shortcut equivalent to running '''nix-channel --update nixos; nixos-rebuild switch''' previously described: | |||
<syntaxhighlight lang="console"> | |||
# nixos-rebuild switch --upgrade | # nixos-rebuild switch --upgrade | ||
</syntaxhighlight> | </syntaxhighlight> | ||
| Line 33: | Line 46: | ||
=== Example of a system update === | === Example of a system update === | ||
<syntaxhighlight lang="console"> | <syntaxhighlight lang="console"> | ||
# nix-channel --update && nixos-rebuild switch | # nix-channel --update && nixos-rebuild switch && reboot | ||
</syntaxhighlight> | </syntaxhighlight> | ||