Nix OS on a headless system

Hey there,

I am currently looking into setting up a homeserver and am debating using NixOS, but I have a few questions:

  1. How hard is NixOS for a windows user (I currently use a server with Debian so i am not totally new to Linux)
  2. Does NixOS make sense on a headless System (i have read that you loose the ability to roll back configurations i case of a failed boot)
  3. Im want to use Docker for most applications i host on the server are there any issues (between nxi and docker) i should be aware of?

As you can see in the title I am most interested in question 2
I am very gratefull for any Answers.
(sorry for any mistakes english is not my first language)

  1. i would say its hard because it is hard for Linux users :stuck_out_tongue:
  2. NixOS is good for headless systems. there are various ways to install NixOS depending on the context with more, little, or nearly no interaction with the computer NixOS is installed on. whats your context?
1 Like

My current plan is to run it on a raspi 3B for now and later swap to a mashine thats more capable.
The server is going to run a few homemade smarthome applications (garage opening/ Inventory keeping). Most of them I created as docker containers.

My goal for now would be to ssh into it and copy the files over.

I hope this was the kind of context you needed :smiley:

if you have monitor/keyboard access to it for installation purpose you can follow this tutorial: Installing NixOS on a Raspberry Pi — nix.dev documentation

if you don’t have access to it you would need to build your own sd-image you will find some hints here:
https://nixos.wiki/wiki/NixOS_on_ARM
but you would need a computer running nix already.

Presumably that is a reference to not having a graphical boot menu, so you can’t get to the boot entry selection and therefore “can’t” roll back.

This is a half-truth, and NixOS is no worse than other OSes in this regard.

Most headless machines still have some way to access your boot menu, albeit sometimes an awkward way. Worst case you can use GRUB, which supports working over the serial port.

For an rpi that’s all completely moot anyway because you can just connect a monitor over HDMI if push comes to shove.

Anyway, if you can successfully boot, and are keeping your config in git, you can trivially just redeploy the previous commit, so it’s hard to get NixOS so borked you need rollback at boot time. At least once you’re in maintenance mode and have disconnected the monitor.

No, but personally I tend to avoid it because docker adds another layer of semi-“package”-management which needs to be maintained separately.

NixOS eventually becomes streamlined enough that the additional maintenance overhead feels annoying, especially because you can achieve almost everything docker can do through nix+systemd, making a container runtime feel completely superfluous.

Unlike other distros writing downstream packages is so completely trivial that you really notice when you’re not using distro tooling for something where you absolutely could.

That’s not to say you can’t use docker. In the intermediate term it’s probably a good idea. It takes a while to learn nix, and this can really help tide you over.

If you have zero programming experience, good luck.

It looks like you have some though. The learning curve is steep, understanding systemd can be helpful, as can knowing roughly what basic packages are and do.

But if you’ve packaged up your own docker containers with reasonable knowledge of what you’re doing, I think you’ll be just fine.

I’d still recommend getting a NixOS installation on a second machine that actually has a monitor and keyboard most of the time, so you can make use of nixos-rebuild build-vm as well as its remote deployment features (or those of deploy-rs).

2 Likes

Thanks for the comprehensive answer. It seems to me that getting a VM with Nix OS for creating my image is the best choice rn. (Can you run nix via WSL?)

Also the main reason I wanted to use docker is because I like to use C# (altho not exclusively) and setting up mono was very tedius last time i did.

deploy-rs seems very interesting and helpfull.

Thanks again for the helpfull Answers @olaf too. I am going to look more into how exactly building a nix image goes.

Yes, nix (as in the package manager/build tool) will run even under MacOS

But some NixOS (as in the distro that uses nix for package management) features only work under NixOS I believe. Specifically, I think you can’t use the nixos-rebuild build-vm command, which might otherwise be really useful to you.

Seeing how far you get with WSL is probably fine, you might not actually need build-vm.

build-vm is a convenient “take my configuration and create an equivalent virtual machine that I can just start for testing without hardware” command. It needs a NixOS host because it bind mounts some things into place for convenient package sharing, iirc.

1 Like

Re C#, packaging C# libraries and applications in Nix has been pretty easy in my experience; much better than Java has been, at least, and almost as good as native C things. The wiki is helpful for getting started.

1 Like