Specialisation: Difference between revisions

Sandro (talk | contribs)
m lowquality
 
(3 intermediate revisions by 2 users not shown)
Line 1: Line 1:
{{Expansion|Configuration with and for GRUB could use explaining here}}
{{Expansion|Configuration with and for GRUB could use explaining here}}
{{low quality|References need to use <nowiki><cite></nowiki> instead of just being numbers in brackets.}}


Specialisations allow you to define variations of your config within itself (even completely different ones). Within a generation of your config, you can then choose between specialisations at boot-time or switch them at runtime using activation scripts.
Specialisations allow you to define variations of your system configuration. For instance, if you don't usually use GPU, you might create a base system with your GPU disabled and create a dedicated specialization with Nvidia/AMD drivers installed - later, during boot, you can choose which configuration you want to boot into this time.
 
Previously this feature was called "children" because a specialised configuration is defined by its "parent" configuration. Later, it was called "nesting", because this feature essentially allows nested configurations. Finally, it was renamed to todays "specialisation". [2]


== Config ==
== Config ==
Line 57: Line 56:
</syntaxHighlight>
</syntaxHighlight>


== Boot entries ==
However, if there are no specialisations defined, then <code>config.specialisation != {}</code> always evaluate to <code>false</code>.


For every generation of your config, a boot menu entry is generated. When using specialisations, an additional entry is generated for it, per generation.
== Activating a specialization ==


TODO: how to use grub submenus
After rebuilding your system, you can choose a specialisation during boot; it's also possible to switch into a specialisation at runtime - following the example above, we'd run:


== Runtime activation ==
<syntaxHighlight lang=console>
$ nixos-rebuild switch --specialisation chani
</syntaxHighlight>


Taking the <code>chani</code> specialisation from our example, we can activate it at runtime (comparable to <code>nixos-rebuild switch</code>), by running <code>/run/current-system/specialisation/chani/bin/switch-to-configuration switch</code>. <code>nixos-rebuild switch</code> also supports a <code>--specialisation</code> flag, which we can use like this: <code>nixos-rebuild switch --specialisation chani</code>.
Note that not all configurations can be fully switched into at runtime - e.g. if your specialization uses a different kernel, switching into it will not actually reload the kernel (but if you were to restart your computer and pick the specialisation from the boot menu, the alternative kernel would get loaded).


== Further reading ==
== Further reading ==