Why everyone is switching to NixOS ?

★ L0Wigh@sh.itjust.works to Linux@lemmy.ml – 15 points –

Hi everyone!

I saw that NixOS is getting popularity recently. I really have no idea why and how this OS works. Can you guys help me understanding all of this ?

Thanks !

84

I used NixOS for a couple of years. My experience is like this:

  1. It is a rolling release (mostly)
  2. You write a declarative configuration for your system, e.g., my config will say I want Neovim with certain plugins, and I can also include my Neovim configuration
  3. It is stable, and when it breaks it is easy to go back
  4. Packages are mostly bleeding edge

Note that there's both the rolling unstable channel and a bi-annual stable release channel.

The configuration stuff seems great. I guess it reduce the struggle of porting a full config from one pc to another right ?

Yes absolutely. It is really great. It is also a source of frustration, e.g., missing configuration options, non-obvious options and so on. Overall it works well.

You can even define configurations for different systems/hosts/users from a single place. I'ev atomized my config and I can reuse lots of parts for my different machines. Also my user config is nearly identical (except hardware specific things).

Important to note that NixOS has both a rolling release and point release version.

Are you still using it and happy with it? I've been increasingly using single purpose dev VMs in a server, and a declarative configuration system would make the process of spinning them up faster and more robust. My current shell script system is clunky, and I've been looking at Ansible.

Not using it anymore. Although I'm thinking about going back to it. The NixOS learning curve is a bit more steep than most other distros.

Here's the straightforward version of why I use it:

  1. The entire state of your operating system is defined in a config file, and changes are made by changing the config file. This makes it super easy to reproduce your exact system many times and to know where all the many different configuration elements that describe your system are located.

  2. Updates are applied atomically, so you don't have to worry about interrupting the update process and if it fails, the previous state of your system is still bootable. By default every time you change something, you get another option in the boot menu to roll back to.

  3. Making container-like sub systems is super easy when you're familiar with nix, so you can have as many different enclaves as you like for different software versions, development environments, desktop setups, whatever without taking a performance hit. Old versions of stuff are very accessible without breaking your new stuff.

  4. The package manager has a lot of software and accessing nonfree stuff is straightforward. Guix looks rad, but nix ended up being the more practical compromise for my usecase. I didn't want to have to package a heap of software the moment I made the switch.

This very much. I used to have lots of unchecked config and state files everywhere on Arch. Now everything is checked in and wiped on boot so if something breaks after a reboot i know what broke.

Like how the opengl rendering did due to nixpkgs version differences

I daily drive Guix instead, and I would strongly recommend any emacs and/or lisp enthusiasts interested in the benefits of functional, reproducible, declarative, and hackable system management to give it a try!

Do you run the gnu guix distro or just use the package manager? Because iirc it uses only free software, even for drivers. So I imagine it is not that easy to find compatible hardware.

I run the complete system. It's true that the standard iso comes with the linux-libre kernel and the standard channel (think repo) contains only free software. However there is the nonguix channel which comes with the full linux kernel, and all the proprietary drivers you could ask for.

Nonguix offer an iso with the full kernel too in case you have a proprietary wifi card and don't have ethernet for the initial setup. The nonguix README I think is pretty clear, but Systemcrafters also made an excellent guide for doing this.

My wifi card unfortunately requires proprietary drivers and I have personally never had an issue with guix + nonguix for all my software needs, proprietary and otherwise.

Hope that helps profligate!

Does it actually require proprietary drivers or just proprietary firmware? I don't know of any wifi cards that actually require proprietary drivers on Linux.

I have been using for years on servers. My lemmy instance is hosted on it.

Although for desktop I had too many issues back in 2019 so I ended up back to Arch Linux and then EndeavourOS

Would be fun to try again to use it on desktop

I think I will give it a try on a server first, I don’t have a playbook or script for a reproducible set up (yet), so I may as well use Nix to see if it’s worth the hype

NixOS is a fully declarative and reproducable system.

What this means is that you can create a single configuration.nix, which includes all of your applications, settings, aliases, environment variables, user account + groups, etc., and copy that over to another NixOS machine (including different architectures) and run nixos-rebuild boot to completely reproduce the system on that other machine.

The nix package manager is also really good at telling you if the configuration will break anything, where, and how, and refuses to apply until the issue is fixed.

Also every time you use nixos-rebuild, it creates a new generation of your NixOS install meaning if something ends up breaking, you can reboot into the old system.

So for example, I can theoretically have the exact same configuration across my desktop, laptop, phone, server, etc., minus the automatically generated hardware-configuration.nix, which is specific to the hardware.

Also Nix supports package overlays, which means that you can modify an existing package while the maintainer still keeps it up to date.

Oh boy my two cents time!

I love the concept of NixOS. A fully declarative , reproduceable system from a single config repo! Sounds theoretically like it would be my kind of thing.

Sure, theoretically, I could have a fully reproduceable system. The time spent declaring that fully reproduceable system though... I remember the first time I was trying to get my usual disk setup of, a luks encrypted btrfs partition with multi-factor enabled decryption/authentication.

On a normal install it would take like a day at worse to install your distro. My first attempt with NixOS took me almost 4 days of screwing around in configs. 2 of those days were probably cumulatively spent waiting for the config option list of the nixos manual to search for text. And the number of redundant config options which all do the same thing! Or, are supposed to all do the same thing but in actuality, only one of them does the thing they are supposed to.

I really want to love NixOS but it always ends up feeling like an exercise in my patience and time to do even the simplest of things. As such I find myself asking the question of, am I going to spend so much time reinstalling my distro that it's ever worth this initial investment?

Anyways, rant over. I actually have been debating switching back over for another try again myself I just have some very frustrating memories of my first attempts with the distro.

Interesting, my first install of NixOS was done in a few hours and included a feature that I had not used in my previous Arch install, namely secure boot. It proved to be no issue whatsoever.

I do agree though that you're looking of lost without search.nixos.org, and documentation is lacking. E.g. did you know that enabling Plasma sets your main font to Noto, regardless if you're actually using Plasma or just have it as an option in your display manager? Or when to enable a program or service rather than adding it to your system packages? Or that if you install plain obs and some plugins, the plugins won't actually work?

I do understand why this is the way it is and I do think it's the better approach. But it's not perfect.

On the other hand, my system works very well in daily usage.

I switched around one and a half years ago. I must say, there are some hurdles to using NixOS. Mainly I dislike that it always takes around 20 times the effort to start and project. You make up for the initial time investment, because you end up with a far more stable setup, but still it does take some willpower to get things started.

I've been using it for over a year and love it. A config file for your entire system, and built in rollbacks anytime something goes wrong. One language to configure everything, although in practice that doesn't always work. But I love it.

Some others have started why it works, here is some how. Nixos completely disregards the fhs. Packages don't install to anywhere standard, every package and configuration change gets it's on directory in /nix/store but through smart use of tracking everything there, it symlinks all those files to proper places and sets up the environment for them to know where libraries are.

This is then also why you don't need sudo privileges to install things. Your profile has an environment that is aware of your users packages and configurations, the system itself isn't effected because everything is symlinked.

Then because every update means new directories in /nix/store you can role back to your last configuration because plasma broke something or whatever.

However, it's a LOT to learn. Best place I know of is https://piped.video/watch?v=AGVXJ-TIv3Y&t=0

This guy did a good job for me. Hope this helps!

nah

didn't have enough time during the last half a decade to learn yet another thing

might be better fit than my current debian setup - but how would I ever know, since my current thing is good enough?

Because it’s the latest Cool Nerd Thing™ like Arch before it, and Gentoo before that. Most of the people raving about it probably don’t have much use for its features.

The features themselves are very useful for basically any user. Whether they are worth the non-standardness and issues that come with it is another question.

Solution without a problem. A cool solution but yeah.

It's insanely stable but you have to have a lot of linux/programming knowledge to do even the simplest things like installing/updating your software or making little tweaks. I played with it for hours the other day and I'm just too dumb to figure it out lol I think it's just a super stable highly customizable distro for power users and a lot of people like that. If you can get over the learning curve it's a pretty powerful and unique os

It's kind of funny because I'd put NixOS on a complete newbies computer for sure, and recommend it to an expert... But I'm less sure if I'd tell a random mid-intermediate Linux user to switch.

Like if Grandma wants Linux on their computer to do some internet browsing for some reason... I'd absolutely put NixOS on it because it's easy to manage the system for them... But somebody who is a little familiar with Linux already might be more confused about the differences. It's kind of the ultimate beginner distro and the ultimate power-user distro, but a bit awkward between those extremes, haha.

It's true that it can be a powerful distro but I've also heard from some users that the advanced-level documentation is lacking and only limited to forums and source code. I think maybe if the documentation was more thorough I would try nixos.

you have to have a lot of linux/programming knowledge to do even the simplest things like installing/updating your software

So, pretty much like any other distro

Most mainstream distro's can do all of that without a CLI.

Weird, every distro I've tried either has no management, or doesn't work. Just spins around loading. "Uninstalling" packages does nothing but remove them from the package manager.

I will switch as soon as I can get proprietary Nvidia drivers to work on my laptop.

That is the main reason I can't use my laptop with linux. It has a 3060 in it. I work as a dev and need to use 2-3 external displays with my laptop. The driver combined with x or wayland is atrocious, I tried 20 distros and I can't get it to work. The saddest thing is that none of the tech is exotic in any way. It's just HDMIs and AOC 24 inch monitors...

SYMLINKS

SYMLINKS EVERYWHERE

(also 6000 packages intalled on my system for some reason lol)

Well, Nix has a very liberal definition of a "package". Your web browser, its wrapper script, a service file, a config file; those are all technically "packages" (or "derivation" as Nix calls them).

Doesn't it have a garbage collector like guix does (guix gc), which cleans up everything in the store that isn't needed anymore?

Yep, Nix-store -gc or some such will do something like this.

I keep seeing trends with Linux distribution like teenager looking for new fashion.

I think it’s mostly the very young Linux user who hope from one distribution to the another over and over whereas many just stick with what they got : Ubuntu, Debian, mint, maybe fedora.

NixOS is certainly interesting tho.

Atleast NixOS isnt one of the countless Arch based distros emerged since pandemic

I tried it about a year ago and I don't know it did not convince me. Yeah it might be great for some niche developer oriented needs or deployment but for a normal OS usage, meh. I kind of see it as a current hype, just like crypto/NFT before, and AI now. For normal everyday usage I find openSUSE Tumblweed much more suitable and much more widely applicable.

For those who like a video format, I found this introduction quite informative.

Thanks for this, it was definitely a nice overview. Not the first time I'd heard of NixOS, but I do seem to be seeing more frequent and more substantial discussions of it.

What I'm getting from all this, is that it looks to be a great way to set up reproducible desktop environments. And servers too, I suppose.

What I'm not getting from this: a compelling reason to switch from established players like RHEL and Ubuntu in combination with cloud-init and Terraform and the likes of Chef/Puppet/Ansible/Salt to spin up a cluster in the cloud, reconfigure, tear down, etc.

In case anyone is misreading me: this is not a dig at NixOS. It definitely looks interesting. Like, to the point that I'll at least spin up a VM on my Manjaro laptop and see whether I should perhaps consider wiping and reinstalling with NixOS. The "configuration through code" is extremely appealing here.

My concern here is corporate inertia. And before anyone gets gets ready to launch a diatribe about how corporations don't decide what the best tech is, I will agree with you. I've been around a while, and excitedly watched as Unix ramped up and displaced platforms like VAX/VMS and AOS/VS, using smaller and faster hardware. Then along came Linux and the battle for which distros would dominate.

As for configuration through code, I've been keeping a keen eye on things (tinkering when it's been possible to do so) since the days of cfengine and Jumpstart. I used to share this site with anyone that would listen to me; it's dated now, but the underlying principles are (were?) solid: http://infrastructures.org/

So for now, I think I'll have to limit my professional NixOS usage to tinkering and potentially useful side projects. For personal usage? Yeah, it might become my daily driver, but I need to find the time to tinker.

I will say that I'm presently involved in an effort to test something out that has my company's product available using rpm-tree. Not my decision, this is all being driven by a customer that has a lot of clout; they really, really want to use rpm-tree. It's proven to be a bit onerous at times.

What this NixOS discussion has managed to do for me is to have me wondering whether a NixOS approach would have worked out better; my sense is that yeah, maybe it would have. But my feelings here might simply be the result of "woo, shiny new object", which has definitely colored my opinions of things in my career of ~35 years. Something that I've had to restrain my excitement over, pending corporate sanity checks.

Having the option to have multiple versions of a dependency without needing to have duplicates of the same version alá flatpak seems like it should've been a no-brainer on any linux distro.
With that said I'm very comfortable with my current system, so definitely not until I get majorly fucked by my life-choices
Definitely sounds like a competent player in comparison to most distros though.

And I feel like the terminal isn't as big a barrier as everyone makes it out to be (part of why I say that is because I think the entire concept of "beginner friendly distros" only makes the terminal seem more impenetrable through that wording)

All-in-one config is definitely something I would've hoped Arch had as well, and as a bonus I would love a system that kept all things related to the user in /home (I'm not completely sure Nix does but I may as well throw that in) (homed does not do that as it still has entities outside of /home that you better back up, in fact you'll risk being locked out of your user if you don't)

What about Nix's financial issues? Have they been resolved yet?

To get it out of the way first: There are no financial issues. There are more than enough funds to continue operations as they are for a sufficiently long time.

What is actually happening is that a long time sponsor has indicated that they (understandably) no longer want to foot the huge bill of hosting the entire archive of binary caches ($9000/mo). Finding a more sustainable setup is what the community is currently concerned with.
There is no risk of operations shutting down any time soon, the NixOS foundation has funds set aside to continue even this unsustainable setup for at least a year. We just want to be more efficient with our and others resources going forwards.

That's what all this you might have heard of is about.

Btw, even if the binary cache were to go poof, we don't technically need it. NixOS is a source-based distro like Gentoo and source hosting is not a concern. The binary cache is immensely helpful though which is why we'd obviously prefer to keep it.

I think AWS Gave them 12 months of free credit to host cache

Yes, AWS gracefully sponsored 12 months of our S3 bill which gives us even more time to enact change.

That's just the short term resolution though, the Nix community is still looking into more sustainable long-term solutions.

$9,000/mo? Have you considered not using the most ridiculously expensive method possible?

Thinking about this further..

I can purchase 10GE fiber, at home, for $299/mo.

I can purchase a solid 16 bay Supermixro server for around $5k

16TB drives are $168. There's $3,700 left so let's buy 21 drives (336TB, 235TB usable under raidz3 zfs). We'll leave that last $170 for .. electricity.

Leasing all of this from a regular hosting provider woul be much more cost effective. I work for one, what the heck are you doing man?

You aren't a reputable public hoster with AWS-class uptime. That has a price too. AWS is likely overpriced though, hence the nix community still looking for better alternatives.

the Nix community is still looking into more sustainable long-term solutions.

I don't get the hype. I'm staying with Arch, as Nix seems to be mainly for developers.

NixOS has benefits not just for developers, altough being familiar with programming is helpful.

For me the main benefit of NixOS is being able to keep multiple systems in sync. For that I have 3 config files, the first containing all general config and packages I want to have installed. The other two are for my laptop and pc respectively, which allows me to make system-specific changes. E.g. tlp is only enabled and configured on my laptop.

And NixOS isn't just rolling release, it also has bi-annual stable releases, which is great for servers.

Rollbacks are also awesome, altough I used btrfs snapshots a few years back with Arch for a similar result. With a bit of setup they are bootable from grub.

I've been looking at it after numerous times I update Fedora only to have some tool break that I use daily. Then I spend a chunk of the day getting Virtualbox working again so I can do my job (write code for websites).

I haven't made the jump, but it looks very interesting.

I've made the jump twice, and jumped back twice.

Conda and any other reproducible computing library that relies on LHS Linux filesystem just doesn't work on it (okay it does, but more as an obstacle)

I'm okay with having nix the package manager on my default arch system though, since it is incredibly useful for cross compiling, and it let's me modify my system however I want.

Have you tried putting it into a buildFHSUserEnv?

I also often put the "dirty" packaged AI/python stuff (which is unfortunately quite a lot) into Dockerfiles if I don't want to package it cleanly with Nix.

I did, but it still doesn't quite act right, especially if I need to build extra packages within the environment

I'm using Void Linux and see no reason to move over to NixOS. The concept seems cool though.

The nice thing about nix and guix is that they're package managers, and so you get most of the benefits even if you're using a different OS.

I'm currently transitioning from Doom Emacs to my own config that's using guix. So far I've got a single manifest that contains all of the Emacs and Linux packages that are needed to run the config.

The guix part is really simple, but it allows me to reproduce my config on any Linux distro by cloning a repo and running a guix one liner. A different one liner can run it in a containerised environment. Also, I can roll back to any previous time I've updated something through that manifest, or pin a specific version of a package.

And that's just scratching the surface of what you can do.

All I year about from the linux community is NixOS and btrfs, neither of which I have any interest in. It almost feels like someone with an agenda is promoting these two with how prevelant they are.

I like using btrfs with Arch because of the snapshots. If an update breaks something I can just boot into a snapshot from grub keep using my PC and solve the problem later. It's very useful... yes... very... you should try it... come... try btrfs... it's warm and cozy... INSTALL IT!

I have tried btrfs in the past and when it goes wrong you are utterly shafted. You can't even mount it as a read only file system, it will just lock you out entirely. And the support isn't great, I ended up finding something that had a disclaimer along the lines of "only run this if you really know what you're doing", but obviously I didn't as the documentation didn't tell me enough to know. So the only people who could possibly know are the developers of the file system themselves. Anyway, I was 2 days in to trying to recover my data by this point so I gave it a go, nothing to lose - it refused to do anything. Great.

So in summary I'm not going to try it again.

can confirm, I've recently had my btrfs partition on NixOS go permanently read-only because it ran out of metadata space (which you can't extend without write access, even though btrfs does reserve 0.5GB of metadata space) so I've switched to bcachefs

Glancing over the website, I thought it's an immutable OS, like Fedora Silverblue. I could imagine that it might be cool to use with Ansible and stuff. But for an average user? I can't really see the advantages in respect to the work you have to put in.

It is an immutable distro, altough it isn't image-based like Fedora's rpm-ostree.

NixOS basically replaces Ansible because the Nix package manager achieves the same goals already (configuration, deployment, ...).

But I agree, the work necessary to put into this non-standard distro makes it hard to recommend for a casual user.

I'm really not sure of where this would be anymore usefull than a simple bash script to install all packages you need since it doesn't do configs and that rollbacks are supported by some filesystems already. Also Having version specific dependencies is already a thing for flatpacks and such

A simple bash script is not reproducible or deterministic. Also a filesystem rollback is not the same as NixOS's generation based rollback.

Also, NixOS doesn't just install packages, all system configuration is done declaratively, which would be a very bad idea to do via a bash script.

I have to check a little harder on what it does since I saw in a vid that you still needed to add your own if statement to get it working I assumed a simple

pacman -Qk xorg-xrtrop 2> /dev/null && sudo pacman --noconfirm -S package1 package2 package3 || echo 'I aint got no x, idiot'

would do the job as well

I'd recommend reading some more; especially w.r.t. imperative vs. declarative.

In NixOS, you'd do something like this:

{ config, ... }:

{
  environment.systemPackages = if config.services.xserver.enabled then [
    package1
    package2
    package3
  ] else [
    # You could optionally make headless packages available here
  ];
}

You don't need to understand the exact semantics here but you can look at it like JSON but with functions. This is not a "program", the end-result is just data. You're not modifying some stateful system state with new state from an uncontrolled source (i.e. the Arch repos) but rather just "outputting" a different dataset.
NixOS then builds a concrete system out of this pure data specification. In this concrete system, those packages' executables are available in the "global" PATH.

You say "I want a system where x y z are installed" and it does it for you in a standardised manner. With the bash script, you explicitly tell it each step ("install x; install y; install z"). This pure data nature is what's meant by declarative.
This distinction rules out whole classes of issues you simply cannot run into with NixOS.

Another aspect is that, as long as you use the same revision of Nixpkgs and the same config file, you can re-create the exact same system (almost bit-for-bit). If you were to run your bash script in a year's time however, you'd get an entirely different system with totally different revisions of software and therefore possibly entirely different behaviour.
This is what's meant by reproducibility.

You can achieve some of the same things NixOS does using imperative tools but nowhere near the same quality.

Part of the purpose of NixOS is providing a means to build a reproducible environment that's easy to configure, migrate, and rollout. You can absolutely handle configuration of many different programs using either flakes or the native modules provided by nix. You can customize your entire system from firewall entries, to users and their shells, to the kernel itself and the kernel modules you'd want it to load, all in a single file or multiple files. If you want to try doing all those things in bash scripts, good luck and please share your experiences but don't expect it to be as easy as the Nix ecosystem.

so it does handle more than just conditional packages like the other zealots make it sound like

Wayyy more. You can move all of your dotfiles to Nix config. And deploy it with Nix based infrastructure.

They're not but nixos users are REALLY loud, as in, they can't spend a single day without talking about it.

New Arch. Both still worse than Silverblue.

Agreed, Silverblue is great. I would love a declarative system, but Nix just doesn't make it easy with its sprawling documentation and mix of new and old parts. I was trying to follow a guide for Home Manager, but couldn't use it because they were using flakes, I was still on the "old" configuration.nix style.

You can't make all things declarative either. If I can only have things 50% declarative, it kinda defeats the point.

I also still tried to use flatpaks since nix doesn't have sandboxing and is slower on updates, but its font configuration was broken.

Nix overall feels like it's requires a lot of workarounds, moreso than Silverblue.

But hey, at least if I ever want to try it out again, I just need to copy in my configuration.nix and make things work from there.

Yup, I did the same thing. I really wanted to make it work but I think it just needs some time to mature. Once it has some clean documentation and polishing it'll be really cool.

I really liked how NixOS has a hardware config repo. I have a Framework, used the config, and everything just worked. I mean it usually does on other distros too but it's nice to know that if there's a config it'll be guaranteed to work.

I'm currently really enjoying kinoite. I think it also has some documentation issues but it's also not as radically different from your average distro as NixOS..