How to switch to a specific specialisation

Now I’m using some specialisation in my configuration.nix

  specialisation = {
    minimal = {
      inheritParentConfig = false;
      configuration = {
       imports = [ xxx ];

And I can choose it in the boot menu to enter it, but after I do something like

nixos-rebuild switch

I find that my NixOS switchs to the default config instead of the specialisation.

So how can I tell nixos-rebuild to switch to the specialisation?


you may find this thread useful NixOS Specialisations - How do you use them? - #7 by nixinator

Usually they appearing in the boot menu, i.e you must reboot

I’ve not use them for a while, so this might be old news.

Thanks to this funny repo I discovered how specializations work.

You can:

  1. nixos-rebuild switch to make the specializations available
  2. Activate or test the specializations by running sudo /nix/var/nix/profiles/system/specialisation/name/bin/switch-to-configuration switch

Related issue: Feature request: add --specialization option to nixos-rebuild · Issue #174065 · NixOS/nixpkgs · GitHub

1 Like

So it’s possible to nixos-rebuild switch --specialisation=<name> now, thank you! :grinning: