Starting work on NixOS Template

Hello there !

I’m just trying to gather some advice and opinions before trying to create a NixOS qubes template.

Having an available NixOS template would be incredibly beneficial for software developers using the platform and I’m looking to contribute. Either by starting the project from scratch or working with others who already started going down that path.

Basically the goal here would be to “automate” and standardize framework specific developer environments.

I’m looking for any advice, opinions about this project. Anybody created a template before ? How long / complex was the endeavor ? Things I should be aware of ? Possible blockers ?

I already looked at this post: Building a TemplateVM for a new OS wondering if there might be any other resources that would be helpful.

Thank you in advance for your answers !
eject_cosmos

3 Likes

There is probably some useful stuff in older threads like this:

I bet @solene has some good info.

install nix and compiling all necessary packages using nix are two different things. I think https://discourse.nixos.org/ is a good place to get help.

How far did you get with this? I want to start with NixOS in the near future so it would be great if making a template is possible.

Hi. I’m working on a Guix template which is based on the same underlying technology as NixOS, so I’ll share where I’m at right now. It’s not very far.

Packaging Xen and Linux with QubesOS patches was fairly straightforward, as you might expect. I’ve also packaged qubes-db and started qubes-linux-utils, and again these were easy to package. I have a networking service that sets up the virtual interface correctly based on QubesDB and this was not too complicated, although I’ve had some problems with losing networking state if I disconnect my ethernet cable. Restarting the networking service fixes that. QubesDB has a function for monitoring changes to entries which might help solve that problem but I haven’t looked into it too much. Right now it’s just “run ip addr add/ip route add/etc on service start, equivalent delete commands on service stop, do nothing while the service is ‘running’”.

I’m currently working on booting my HVM Guix install in PVH mode. I’m starting with booting a Fedora-based template with a kernel built by Guix. Which is fine for the most part but memory ballooning isn’t working properly so I have to give the VM a lot of min memory. Otherwise it seems to work fine, the VM boots and I can do things in it. The next thing I need to tackle (aside from the ballooning bug) is starting the correct init in Guix. I assume that Nix will have a similar issue. In Guix, there is a list of bootloader entries pointing to different profiles in the kernel command line which is used during initialization. The problem is that the command line arguments live in dom0 when booting in PVH mode. Maybe some dom0 script could read the bootloader configuration and ask the user, but having dom0 parse VM data seems like a bad idea. So it would probably be better to have a separate init in Guix that asks the user which profile to use separately from the bootloader.

Anyway I’m short on time so that was just what I remember. Some of the pages in my personal note are relevant to my effort to build a Guix template and they might be helpful here as well. You can also see my current progress in my channel.

Good luck!

3 Likes

awesome!

why don’t you just boot on the latest system version? it has a fixed name IIRC

I might do that temporarily, but I want the ability to roll back to previous configurations on boot. I tend to do strange things to my computer and sometimes completely break everything. :upside_down_face:

Qubes OS provides a pretty similar feature, not as practical though, but you can revert the qube disk to its last state, the number of stored states can be configured.

See Volume backup and revert | Qubes OS