How to use NixOS with GandiCloud

This page will show you how to use NixOS on the GandiCloud platform.

What is NixOS?

NixOS is an operating system that takes a unique approach to package management and system configuration.

Learn more about NixOS on their website.


Initial configurations

SSH into the server, and copy the file /etc/gandi/configuration.nix to /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. However, be sure to include the gandicloud.nix file in your imports section, as this is needed for the OS to run properly on our platform.

imports = [ ./gandicloud.nix ];

Nginx example

Let’s add an Nginx configuration to serve a simple web page. The file /etc/nixos/configuration.nix should look like this:

{ pkgs, ... }: {
  imports = [ ./gandicloud.nix ];
  config = {
    services.nginx = {
      enable = true;
      virtualHosts = {
        "" = {
          locations."/".root = pkgs.runCommand "web-root" {} ''
            mkdir $out
            echo 'NixOS @ \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 serve our static page:

NixOS @ \o/