Updating NixOS: Difference between revisions

Roxwize (talk | contribs)
prepare for translation
Roxwize (talk | contribs)
Marked this version for translation
 
(One intermediate revision by the same user not shown)
Line 2: Line 2:


<translate>
<translate>
== Introduction ==
== Introduction == <!--T:1-->


<!--T:2-->
[[<tvar name="1">NixOS</tvar>|NixOS]] stands out due to its declarative configuration and atomic updates, which ensure that system updates are predictable, reversible, and don’t risk breaking the setup. This approach guarantees consistency across versions, allowing any changes to be easily rolled back. NixOS also offers flexibility, multi-version support, and advanced dependency management, making it an excellent choice for developers and system administrators.
[[<tvar name="1">NixOS</tvar>|NixOS]] stands out due to its declarative configuration and atomic updates, which ensure that system updates are predictable, reversible, and don’t risk breaking the setup. This approach guarantees consistency across versions, allowing any changes to be easily rolled back. NixOS also offers flexibility, multi-version support, and advanced dependency management, making it an excellent choice for developers and system administrators.


<!--T:3-->
As part of this process, only repository channels are updated or removed during updates. The system '''requires an Internet connection''' to download the latest changes, and users '''cannot''' directly modify the system. For optimal stability, security, and access to new features, regular updates — ideally '''once a week''' — are recommended.
As part of this process, only repository channels are updated or removed during updates. The system '''requires an Internet connection''' to download the latest changes, and users '''cannot''' directly modify the system. For optimal stability, security, and access to new features, regular updates — ideally '''once a week''' — are recommended.


== Rebuilding the system after editing configuration.nix file ==
== Rebuilding the system after editing configuration.nix file == <!--T:4-->


<!--T:5-->
To apply the configuration changes made in <code>/etc/nixos/configuration.nix</code> without updating the channels, [[<tvar name="1">Nixpkgs</tvar>|Nixpkgs]] and package versions. This is typically used when you've edited the system configuration, and you just want to apply those changes:
To apply the configuration changes made in <code>/etc/nixos/configuration.nix</code> without updating the channels, [[<tvar name="1">Nixpkgs</tvar>|Nixpkgs]] and package versions. This is typically used when you've edited the system configuration, and you just want to apply those changes:
</translate>
</translate>
Line 18: Line 21:


<translate>
<translate>
== For non-flake configurations ==
== For non-flake configurations == <!--T:6-->


<!--T:7-->
What follows is a short set of instructions. Further details can be found in the [<tvar name="1">https://nixos.org/manual/nixos/stable/#sec-upgrading</tvar> NixOS Manual.]
What follows is a short set of instructions. Further details can be found in the [<tvar name="1">https://nixos.org/manual/nixos/stable/#sec-upgrading</tvar> NixOS Manual.]


=== Updating NixOS channels ===
=== Updating NixOS channels === <!--T:8-->
</translate>
</translate>


Line 30: Line 34:


<translate>
<translate>
<!--T:9-->
For more information on channels, see the main [[<tvar name="1">Channel branches</tvar>|Channel branches]] page.  
For more information on channels, see the main [[<tvar name="1">Channel branches</tvar>|Channel branches]] page.  


=== Rebuilding the system after updating channels ===
=== Rebuilding the system after updating channels === <!--T:10-->


<!--T:11-->
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:
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:
</translate>
</translate>
Line 44: Line 50:


<translate>
<translate>
=== Updating channel and rebuilding the system ===
=== Updating channel and rebuilding the system === <!--T:12-->


<!--T:13-->
The below command is a shortcut equivalent to running '''nix-channel --update nixos; nixos-rebuild switch''' previously described:
The below command is a shortcut equivalent to running '''nix-channel --update nixos; nixos-rebuild switch''' previously described:
</translate>
</translate>
Line 54: Line 61:


<translate>
<translate>
=== Changing Nixpkgs version ===
=== Changing Nixpkgs version === <!--T:14-->


<!--T:15-->
To see what is the latest channel available, see <tvar name="1">https://channels.nixos.org/</tvar>.
To see what is the latest channel available, see <tvar name="1">https://channels.nixos.org/</tvar>.
</translate>
</translate>
Line 61: Line 69:
<syntaxhighlight lang="console"># nix-channel --add https://channels.nixos.org/nixos-<version> nixos</syntaxhighlight>
<syntaxhighlight lang="console"># nix-channel --add https://channels.nixos.org/nixos-<version> nixos</syntaxhighlight>


=== <translate>Deleting old generations</translate> ===
<translate>=== Deleting old generations === <!--T:16--></translate>


<syntaxhighlight lang="console">
<syntaxhighlight lang="console">
Line 67: Line 75:
</syntaxhighlight>
</syntaxhighlight>


=== <translate>Example of a system update</translate> ===
<translate>=== Example of a system update === <!--T:17--></translate>


<syntaxhighlight lang="console">
<syntaxhighlight lang="console">
Line 74: Line 82:


<translate>
<translate>
== For flake based configurations ==
== For flake based configurations == <!--T:18-->


<!--T:19-->
Because [[<tvar name="1">Flakes</tvar>|Flakes]] do not use channels and instead rely on explicitly defined inputs, updating a configuration involves modifying the system’s <code>flake.nix</code> to reference the desired versions of inputs. For example:
Because [[<tvar name="1">Flakes</tvar>|Flakes]] do not use channels and instead rely on explicitly defined inputs, updating a configuration involves modifying the system’s <code>flake.nix</code> to reference the desired versions of inputs. For example:
</translate>
</translate>
Line 92: Line 101:


<translate>
<translate>
<!--T:20-->
Once the input URLs have been updated, refresh the flake lockfile with:
Once the input URLs have been updated, refresh the flake lockfile with:
</translate>
</translate>
Line 100: Line 110:


<translate>
<translate>
<!--T:21-->
Finally, rebuild the system configuration to apply the changes:
Finally, rebuild the system configuration to apply the changes:
</translate>
</translate>
Line 108: Line 119:


<translate>
<translate>
== Tips and tricks ==
== Tips and tricks == <!--T:22-->


=== Limiting the maximum number of running jobs ===
=== Limiting the maximum number of running jobs === <!--T:23-->


<!--T:24-->
Sometimes, the update process may hang when the system CPU has a high number of cores. You can limit the maximum number of running jobs:
Sometimes, the update process may hang when the system CPU has a high number of cores. You can limit the maximum number of running jobs:
</translate>
</translate>