NixOS images on Azure

Here’s a minimal working example:

Gonna upstream this into nixpkgs, at some point when I have a bit of time over.

7 Likes

Tangentially related: Started re-reading Azure’s Virtual Machines Documentation, and this (well-buried) part is a deal breaker as I wanted to deploy it for a job:

The Azure platform SLA applies to virtual machines running the Linux OS only when one of the endorsed distributions is used.

(SLA for Virtual Machines)

I want to run a nixos machine on a azure vm. What’s the current status? Is plommonsorbets minimal example the way to go or has this been upstreamed into nixpkgs?

As far as I understand by now, it works like this:

Azure supports two kinds of VM images: v1 and v2. The main difference is that v1 use BIOS and v2 boot with UEFI. v2 has some more security features and neither v1 nor v2 are supported by all instance types Azure V1 vs V2.

Support to generate images for v1 is in nixpkgs / nixos here. The example from plommonsorbets shows how to create a v2 image.

Once you have an image there is the question on how to get it into azure. Which seems kind of journey in itself (most of Azures documentation wants to stuff Azure Image Gallery down your throat). But the azure-new script shows you how to get from a vhd to an image.

1 Like

There was (is?) an attempt at making azure-new more user friendly:
(The background stuff in the readme can be ignored.)

It’s basically azure-new extracted from Nixpkgs to allow personal experimentation without being embedded in a huge repo. The section 2. Usage gives a good overview, and there are more comments in the shell scripts.

Took me a while, because uploading the image always timed out due to my rather slow internet connection at home, but

[azureuser@localhost:~]$ cat /etc/issue 

<<< Welcome to NixOS 23.11.20230801.9e1960b (\m) - \l >>>

The stock v1 images in nixpkgs work like a charm :slight_smile:

1 Like

Hi, am trying to run nixos in Azure and using the v1 image build of azure-new. It successfully runs after deploy but as soon as i do a nixos-rebuild and reboot the VM i get the error: 452: Out of range pointer: 0x100010

am i not supposed to run a nixos-rebuild or what am i missing here?

So i did some testing and finally got a working image which i can rebuild and reboot without any issues on gen 2.
I combined the 2 repositories azure-new and plommonsorbets with some extra config on cloud-init and networking.

If anyone is interested :

Works like a charm. Thanks for this. ( you are my hero for today.)

I did this recently fairly trivially using nixos generators. I generated the vhd using the default settings, then:

  1. creating storage using az storage account create
  2. Uploaded the image to storage thru the UI
  3. Created an image in the ui from the storage
  4. launched an azure instance from the newly created image in the ui