Updating NixOS: Difference between revisions

follow commands template
Pigs (talk | contribs)
Add section on updating nixos if you are using flakes
Line 9: Line 9:
</syntaxhighlight>
</syntaxhighlight>


== Updating channels and rebuilding the system ==
== For non-flake configurations ==


=== Updating NixOS channels ===
=== Updating NixOS channels ===
Line 36: Line 36:
</syntaxhighlight>
</syntaxhighlight>


== Limiting the maximum number of running jobs ==
== For flake based configurations ==
 
Because [[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:
 
{{file|flake.nix|nix|
<nowiki>
{
  inputs = {
    nixpkgs.url = "github:nixos/nixpkgs/nixos-25.05"; # update version
    ...
  };
  ...
}
</nowiki>
}}
 
Once the input URLs have been updated, refresh the flake lockfile with:
 
<syntaxhighlight lang="console">
# nix flake update
</syntaxhighlight>
 
Finally, rebuild the system configuration to apply the changes:
 
<syntaxhighlight lang="console">
# nixos-rebuild switch
</syntaxhighlight>
 
== Tips and tricks ==
 
=== Limiting 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:
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:


Line 48: Line 79:
};
};
</syntaxhighlight>
</syntaxhighlight>
[[Category:NixOS]]
[[Category:NixOS]]