What exactly is the use case of NixOS?
I'm an Arch user (CachyOS now) and I've gotten used to doing things a certain way. Anyway, I have another computer with a fresh Windows 11 install. After literally 5 hours of troubleshooting, I still could not get the fuckass wi-fi drivers installed. People who say Windows is easy clearly never had to install it. I eventually said fuck it and decided to install NixOS. I'm used to Arch based distros so I wanted to try something new. I'm very confused about how it works and what it's intended use case is. I spent an hour trying to figure out how to install micro permanently. I did RTFM but It didn't really help. I guess I'm hoping someone can share some words of encouragement and/or convince and/or bully me into sticking with this weird ass distro.
12 replies
I've been using NixOS for years now (the 1st commit is from 2020). The benefits I particularly enjoy:
If a software update goes south, just reboot into the last known good one, until you have time to figure out what broke. This only applies to OS config, it doesn't apply to data, so if you need to migrate your Postgres to a new on-disk format, or such, you still need a snapshot or backup of some sort.
It's very easy to keep config in Git - I'm aware of
etckeeper, but NixOS treats your Git repo as the primary source of truth, not a tacked-on addition.It's possible to write parametric configurations, to loop over machines, etc. For example, here's how I import the module that enables and unfirewalls Prometheus exporters, in one particular machine:
Other machines don't have
knotorredis, so I just omit them from the list.Here's a simplified snippet of the implementation:
This thing above produces approximately this NixOS config:
Edit: I forgot about overlays. You can patch software, or switch to forks, much more easily with NixOS. For example, here I'm applying some mods to my laptop:
and here's its definition - nothing could be simpler.
The patch itself is generated by
git diffin the source of wlvncc. Alternatively, I could have switched to a fork, here's how: https://wiki.nixos.org/wiki/Overlays#Overriding_a_versionNot sure what exactly you have in mind, but in case you're not aware, you can roll out via SSH to a remote NixOS host by passing
--target-hosttonixos-rebuild.The first steps are rather rough, yeah. Once you have your workflow, it takes like 30 seconds to permanently install a program. Never as straightforward as an
apt install micro, but well, that's where we come to the point of NixOS.Personally, I like NixOS, because:
apt install microages ago and then I neverapt purged it when I stopped using it.git revertit. Maybe I set myEDITORenv when I switched to Micro and it'd be a good idea to set that back. By having a Git history, I can't forget stuff like that.I'm on nixos now for several years: Don't stick with it if you don't have the issues it's solving! Nix is an own language, literally - and you'd have to learn it to really get comfortable with it.
To give you the personal anecdote:
I'm running arch an my desktop and laptop and nixos on my server. The main reason for nixos me is "protection from myself": with having the generations and deterministic definitions allows me to test something and discard it without any leftovers.
It's just a completely different mindset. For my server I want to first define my system and then build it. On my client I want to quickly install something.
And to make it worse: reading the manual is mockery in my opinion, created by the Linux equivalent of the Cenobites who ravel in our suffering. In my opinion, documentation quality reaches from arch simi on the one hand to the nixos... thing on the other.
I have a shell script for that.
Need Gimp? Run
nix-shell -p gimpand you have Gimp in your $PATH.Yeah you're right! That approach is ephemeral though - you still have to then update your build config if you like it.
And it's just ... I don't know, it doesn't match my nixos mental model. But that again could be caused by me having it only on server environments. Perhaps I'll give nixos on a client a shot at my next job (currently locked in MacOS mainly which is such an annoying pain it's ...)
Oh and something that's different than from many other distros for me: upstream management is quite a bit slower, even on unstable:
a generation switch takes around 30 minutes for me - ironically hm switch even longer with flake updates.
Both are caused by software I follow upstream so close though that I have to compile it myself, that's not "normal" for most nixos users I assume :)
So it is. However, I find it easier to think "now where was that text file that holds my list of desired packages" than "now which package manager was I using in this machine? Was it Alpine/apk or Ubuntu/apt" - and I haven't used any RPM-based distros for decades, now, so I'd have to look up a newb guide for these...
Well, yeah, if you have to recompile a package every time, then it's gonna take time :) I can't see how it could be faster on Arch, though. Unless your package also pulls in beta dependencies, so you'll have a whole dependency tree to recompile.
Aur is following upstream way closer than nixos unstable. But I apologize if I have implied that this is nixos' fault, I just wanted to give OP a bit of everyday insights from a nixos user - I really enjoy nixos!
I’m just tacking on to the existing responses, but for me, the huge benefit I get that no one else has hit on yet is automated setup of partitions, LUKS, ZFS on root, and zswap (mostly via disko).
https://github.com/nix-community/disko
It’s sooooo much nicer than wiring those up by hand.
And I have a custom USB iso based on the nixos installer, with has an ssh server running by default, with my pubkey already wired up. So I can plug in a USB to a new device, boot from it, run recon remotely to figure out how I want to set up the disks, then run a full install from my laptop over SSH with a single command (via nixos-anywhere).
https://github.com/nix-community/nixos-anywhere
NixOS is an absolute gem.
I've been running NixOS for about a year now (servers+desktop+laptop) and I love it!
I config sometging once, push it to Git and all other devices follow.
Everything is in one place and everything uses NixOS/HomeManager modules, so everything is configured using the same syntax/language.
It is quite difficult to get started with, but it is so nice when you get the hang of it.
Also, I work in IT with declarative tools like Kubernetes and Terraform. NixOS lets me treat my machines the same way with declarative code, so it is actually pretty intuitive to me.
I am in no way an expert on the matter, but I will gladly try to answer any questions you may have :)
NixOS really is my endgame OS and after having tried many different distros, this is what I will be sticking with for the forseable future :)
I have not used NixOS, but heavily use their package manager at work. In the package manager context, there are two big benefits:
Glancing at NixOS, it looks like it follows the same pattern but at the OS layer. If you like declarative configuration that could be an upside. The bigger upside would come if you have multiple machines that you want to behave the same.
/etc/nixos config file . fill it in and run nixos rebuild switch and that becomes your new default system.
https://search.nixos.org/packages
This link helps you find packages, and the options give you the command to add to your config, install it adhoc or install into the current session.
If you have a broadcom WiFi card you may need to add a few lines to your hardware config, but normally you don't touch it.