Experts insights Updates and releases

NixOS is now available on GandiCloud VPS

An illustration of a server stack floating on a purple background with stars. A laptop and a smartphone are floating nearby along an orbital path around the server stack.

It’s our pleasure to announce that we have added NixOS 21.11 as a new image supported by our GandiCloud VPS product. You can now deploy a new GandiCloud server with NixOS!

What is NixOS?

NixOS is a Linux distribution built from the package manager Nix. NixOS uses a declarative configuration and allows trustworthy system updates.

A NixOS server can be booted in just a few clicks on our web interface or by using the following command OpenStack CLI:

openstack server nixos-server --image NixOS \
    --flavor V-R2 \
    --boot-from-volume 20
Screen_EN_NixOS
We’ve added NixOS as a new supported image on our GandiCloud VPS product

Want to try NixOS?

Here’s an example of how to deploy a NixOS server using GandiCloud VPS.

Create a GandiCloud NixOS server, log in to it via SSH, and copy the file /etc/gandi/configuration.nix in /etc/nixos/gandicloud.nix:

cp /etc/gandi/configuration.nix /etc/nixos/gandicloud.nix

You can now update the file  /etc/nixos/configuration.nix according to your specific needs. For example, let’s add an Nginx configuration to serve a simple web page.

The file /etc/nixos/configuration.nix should now look like this:

 { pkgs, ... }: {
   imports = [ ./gandicloud.nix ];
   config = {
     services.nginx = {
       enable = true;
       virtualHosts = {
         "nixos.gandi.net" = {
           locations."/".root = pkgs.runCommand "web-root" {} ''
             mkdir $out
             echo 'NixOS @ gandi.net \o/' > $out/index.html
           '';
         };
       };
     };
     networking.firewall.allowedTCPPorts = [ 80 ];
   };
 }

This server configuration can then be deployed using the tool nixos-rebuild:

$ nixos-rebuild switch
building Nix...
activating the configuration...
reloading the following units: dbus.service, firewall.service
the following new units were started: nginx.service

The server configuration has been activated and Nginx will now be our static page:

$ curl YOUR-GANDICLOUD-SERVER
NixOS @ gandi.net \o/

This is just a basic example and many deployment tools that exist for efficiently deploying NixOS servers. In addition, thanks to the OpenStack public API, it’s also possible to use Terraform to create a NixOS server and configure it on GandiCloud.

Thank you NixOS community and happy deployment of your declarative servers!

This article is published under a Creative Commons Attribution 4.0 International license.