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 :

1 Like

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

@rudesome Regarding 452: Out of range pointer: 0x100010, did you figure out what exactly that means and which program emits that error message (e.g. is it a bootloader or the Linux kernel)?

I’m also observing it after an upgrade and reboot into NixOS 24.05 on Azure specifically.

No, not what causes it, i have a working vm with the setup as i have described in my github repo but it is using a GEN2 VM

1 Like

I had a similarly problem. I solved it with upgrade to a bigger VM size for the rebuild.

I tried today to replicate the issue on another Azure VM (both are V1), but failed to reproduce it there.

This error seems to come from GRUB2, with code here:

Googling GRUB Out of range pointer, this issue also happened for some Ubuntu and Arch users, e.g. here.

Some report that just re-installing GRUB from a chroot fixes it for them.

Love this one. I forked it and added Arion to the mix :slight_smile:

See: erwinkramer/nixos-on-azure: Run nixos on Azure GEN 2 VM