Jump to content

Install NixOS on Oracle Cloud

From NixOS Wiki

This guide describes how to install NixOS on Oracle Cloud, including IPv6 configuration.

Installation

Create the instance with Oracle Linux 9 as base image. Then follow the steps in Install NixOS on a Server With a Different Filesystem.

There are other methods that may also work, see this Discourse thread.

Configuration

Bootloader

systemd-boot works well. net.ifnames=0 is optional, but recommended for more predictable interface names.

boot.loader.systemd-boot.enable = true;
boot.loader.efi.canTouchEfiVariables = true;
boot.kernelParams = [ "net.ifnames=0" ];

Networking

Oracle Cloud web interface

IPv4 setup is handled by the configuration wizard.

To set up IPv6, your Virtual Cloud Network (VCN) must have an IPv6 prefix assigned.

The VCN's Route Table(s) must have an entry for IPv6 traffic.

The VCN's subnet for your instance must have an IPv6 prefix assigned.

Make sure your security list has equivalent rules for IPv4 and IPv6 if you want your services to be reachable via both versions.

NixOS configuration.nix

networking = {
  hostName = "(your hostname here)";
  defaultGateway = "10.0.0.1";
  # Use Quad9's DNS (or replace by your preferred DNS provider)
  nameservers = [
    "9.9.9.9"
    "149.112.112.112"
    "2620:fe::fe"
    "2620:fe::9"
  ];
  interfaces.eth0 = {
    ipv4.addresses = [
      {
        # Use IP address configured in the Oracle Cloud web interface
        address = "10.0.0.90";
        prefixLength = 24;
      }
    ];
    # Only "required" for IPv6, can be false if only IPv4 is needed
    useDHCP = true;
  };
  # Note: you also need to configure open ports in the Oracle Cloud web interface
  # (Virtual Cloud Network -> Security Lists -> Ingress Rules)
  firewall = {
    # (both optional)
    logRefusedConnections = false;
    rejectPackets = true;
  };
};