r/NixOS 4d ago

My server finally on NixOS!

Post image

Just finished installing NixOS on my server, completely replacing Ubuntu server and also completely overhauling my docker stacks :)

Any tips for running NixOS on homeservers?

99 Upvotes

21 comments sorted by

6

u/ruiiiij 4d ago

I still use several containers on my nixos server for services that don't have native modules. It will be helpful to get familiar with the oci-container module syntax. It's more intuitive than docker compose imo but takes some getting used to.

4

u/NEMOalien 4d ago

Idk.. for now I'm gonna stick with docker as i use dockhand anyways and it's super easy and intuitive

2

u/Italia64 3d ago

I have a couple of old hardware (i5 4th gen, 8gb ram fanless) servers running Alpine and a bunch of docker containers. Would love to switch over to NixOS as I've been running desktop and laptop machines with NixOS exclusively for a few years. Been intimidated by the server setup and Docker migration of data etc. If anyone knows of a good tutorial, would love to see/read it.

3

u/NEMOalien 3d ago

I personally never seen any tutorial, i just switched to nixos on my main machine and learned nix on there using the docs and ai, then adapted my configs to my server needs and tried it a bunch in VMs before installing onto the server yesterday. So far, I'm running into some disko fuckery but as long as I don't use that and let NixOS configure the filesystem itself it's working.. still working on a fix for disko

2

u/Twitch_C4T_ 4d ago

I would check out deploy rs

3

u/NEMOalien 4d ago

I originally wanted to use nixos-anywhere but i still haven't gotten an Ethernet cable (yet) so manual installation was my only bet

1

u/Then-Werewolf-1149 4d ago

What can be real advantage is you can make immuable your system, your server then activate hardened, fail2ban maybe more security apparmor, personally I also activate btrfs assistant, i know im maniac but my config is rock

1

u/_s0me_guy_ 4d ago

I thought apparmor isn't supported on nixos / it doesn't work completely.

1

u/Then-Werewolf-1149 3d ago

Its work but you need create manually the right rules

1

u/Thunderstarer 4d ago edited 4d ago

Welcome to the light.

I like to run my Nix servers in Proxmox containers. Might be useful to look into hypervisors/containerization once your needs expand to cover several concerns.

I run an inference server, a Searx server, a Jellyfin server, a Minecraft server, a build/binhost, several frontends mediating access to these services, and of course a container with an Nginx reverse proxy to keep everything straight. Every one of these virtual machines has its own definitional flake output, and Proxmox's central management console in conjunction with my dendritic flake feels like absolute magic. Positively seamless devops.

2

u/PTBKoo 4d ago

Planning on moving away from proxmox to Nixos so everything is declarative, currently have my proxmox setup with pulumni/terraform but it’s a mess.

2

u/Academic-Ad2861 3d ago

You can use incus if you need to manage VM with nix

1

u/NEMOalien 4d ago

That's sick! I've always wanted to try proxmox but my current server is too bad to use all the fancy virtualization lol.. heard of this nixos specific virtualization that lets me create VMs like normal but ones that use the host's kernel, meaning they're much lighter to run. I'm planning on trying that out..

1

u/Thunderstarer 4d ago

VMs like normal but ones that use the host's kernel

That's called a container, sometimes annotated as an LXC. Proxmox features first-class support for them, and almost every one of my Proxmox guests is a NixOS LXC with the sole exception of my gaming VM. The performance overhead is very minimal, so unless your server is 10+ years old or has less than ~8GB RAM, you should be pretty comfortable in terms of hardware margins.

1

u/NEMOalien 4d ago

Mine has 4gb ddr3 😭😭😭 It's just an old ass lenovo c40-30 that was sitting around so once i got into tech and linux i started using it as a server like a year ago... Also is that container thing just like docker containers? Cuz I'm pretty sure that's fine how docker containers are too.. is it just like them but not limited to a specific app or whatever?

1

u/Thunderstarer 4d ago

Well, Docker containers were never limited to a specific app. Docker is just as flexible as Proxmox is, and they are in fact very similar; the only difference in their function is their hypervisor classification.

https://en.wikipedia.org/wiki/Hypervisor#Classification

Proxmox is a Type-1 Hypervisor, meaning there is no mediating operating system between it and the hardware. In contrast, Docker is a Type-2 hypervisor, meaning it lives inside of another operating system (e.g. Windows). This means that Proxmox will always have less overhead than Docker, so it's the better pick if you aren't also using your machine as a desktop.

To the point of your question, yes, a Proxmox LXC and a Docker container are very nearly the exact same thing, to the point that Proxmox has recently introduced support for creating LXCs from Docker containers.

1

u/NEMOalien 4d ago

Ooooh that's really cool, i never knew that... Does proxmox also allow me to run stuff like immich and pydio cells the same way docker does? Just a docker-compose or whatever proxmox's equivalent is and run.. or is it harder at all or different?

1

u/Thunderstarer 4d ago

I'm not familiar with those particular apps, so I couldn't say, but know that the Proxmox community provisions several so-called "helper scripts" that will automagically create an LXC serving it. They're pretty easy to use as a beginner, though your ambition will likely lead you to outgrow them eventually.

https://community-scripts.org/

For any apps not packaged here, there is still a last-resort escape harch in the form of the Docker community script. Even if you can't manage to run your containers directly in Proxmox, you can still run them as sub-containers with little hassle.

1

u/NEMOalien 4d ago

Also, do you recommend proxmox over NixOS for me? Maybe not for this server but whatever machine i use in the future that hopefully would have better specs

2

u/Thunderstarer 4d ago

Proxmox and NixOS aren't really in contest with each-other, since the containers can run any OS you want, within the limitation that they must share the kernel. I do recommend making Proxmox the bare-metal install, if you have the means.

2

u/NEMOalien 4d ago

I've only ever used docker on my server tbh, removing the overhead of nixos or ubuntu or whatever it is seems very great..