Skip Navigation

NixOS is better because...

I've been curious about NixOS for quite some time. Reading about it I couldn't see how the config sharing capabilities, setup, or rollabck would be better than Arch and sharing the list of installed packages, using downgrade or chroot.

So I decided to run NixOS in a VM and I'm still confused. An advantage I can see for NixOS is its better use of cores and parallel processing for packages install.

It's clear that I'm missing something so please help me understand what it is.

Edit: Thank you to everyone in this great community! It's always so nice to have a constructive and sane discussion.
After reading so many comments, they all confirm what I've read before and I may realize that my real problem is already having a stable system and no need for the great NixOS options that are very neat but would not benefit my specific and simplistic needs. That being said I can't refrain myself from being curious and will continue testing NixOS.

The need for only 2 config files is the top of the iceberg but hiding more complex configuration to rely on. Not that I really have too much spare time but I do enjoy learning and tweaking NixOS. With its current development state, things are changing a lot so it can keep me busy for months. That's probably what I was mostly looking for: another toy to play with.

Along my journey I will learn a lot about NixOS and may find a feature that will motivate my switch to it. Thanks again for all your precious feedback!

I'll also take this opportunity to share the best help I've found so far to start with NixOS: https://github.com/MatthiasBenaets/nixos-config And his 3 hours (!) video: https://m.youtube.com/watch?v=AGVXJ-TIv3Y

54
54 comments
  • The appeal of it, to me, is the same as why Docker containers are really good. You write your definition, save it to git, for example, and if you ever need to setup your computer from scratch, if you restore that config, it'll setup your computer exactly like it was before. But even besides that, being able to roll back if something goes wrong, is a big plus

    26
    • That's what I keep reading and why I would like to give it a try. For now I'm still confused how this is easier/more efficient than sharing your list of packages, restoring a backup, or using downgrade in Arch. I'm really interested because I like to try new stuff, especially if they bring something of interest.

      I really have hard time to see the difference for now after my first setup in a VM but also because imaging my full Arch system on a new machine 2 years ago only took me an hour and less than 10 command lines.

      Again, I'm genuinely trying to understand what I'm missing. From my reading NixOS seems to be the only distro I could switch to.

      9
  • for me personally I like to be able to install software temporarily using nix-shell command it's awesome. the installed program will be gone once you leave the nix-shell. It's just awesome for me.

    15
  • Better in some ways, but it has the worst documentation of any distro I've seen so far. https://nixlang.wiki is trying to improve that

    CC BY-NC-SA 4.0

    14
    • How to read NixOS documentation:

      1. Go to wiki, see if topic exists
      2. If it does, notice how it doesn't cover your case
      3. Use the hints from the wiki to get your search engine redirect you to https://ryantm.github.io/nixpkgs/
      4. Notice it still doesn't cover your use case
      5. Use search engine again, this time with the hints from aforementioned page, to arrive in the proper code in the nixpkgs repository
      6. Read annotated source code to see what actually happens

      Yeah, this is how I found https://github.com/NixOS/nixpkgs/blob/master/pkgs/build-support/setup-hooks/make-wrapper.sh yesterday because I wanted to install some shell scripts that needed to be adapted.

      Don't get me wrong, maintaining a distribution the way NixOS is a huge effort and I can't praise the maintainers and developers enough. The ecosystem they've built is unlike I've seen anywhere, and the technical foundation is sound – in fact I'd wager more sound than what commercial distributions offer. The latter just have more grease. But I do understand the criticism about lacking documentation. But human labor is scarce, and I mean look at me posting this here instead of improving it.

      There's also no good guidance or best practices for packages in nixpkgs and stuff is permanently changing (which in my opinion is good). E.g. did you know that new derivations should be sorted by letters, not categories, and not go into all-packages.nix? At least if your derivation doesn't require fancy attributes (pardon me if that is not the correct term). Or that stdenv.mkDerivation rec {…} is not best practice, but rather stdenv.mkDerivation (finalAttrs: {…})? And why the latter even works?

      Writing good documentation for a system, especially one that's permanently evolving, is not easy, and I prefer all efforts going to actually maintaining and evolving the system itself than trying to get the perfect documentation that's outdated in a matter of time. And without trying to gatekeep it, NixOS is a distribution for advanced users. I recommend it to everyone who has a solid understanding of how a Linux system is composed because I think it's important what NixOS abstracts away from you. And as an advanced user, reading commented code once in a while is fine in my opinion.

      12
      • The problems with nix/nixos documentation are:

        • documentation isn't sexy so not many want to do it
        • documentation is difficult to be written by beginners because... they're beginners
        • nix/nixos maintainers undervalue documentation efforts - I've tried to get in pull requests, but they just stall (not reviewed, nitpicked to death, simply not merged, etc.)
        • it isn't generated from source code

        Also, the very top heavy decision making process harms the community. Some person with hundreds of commits can push through nearly any change (good or bad) relatively quickly, unless other frequent contributors are really really against it. However, fresher contributor with a great change is forced to go through a never-ending process and few stay to actually finalize it.
        Pushing to master was not seldom for a long time and IINM it isn't possible anymore. But maintainers can simply (and do) create a PR, make a change and merge it.

        These difficulties just make me want to fork nixos. For documentation, at least there's https://nixlang.wiki

        CC BY-NC-SA 4.0

        5
  • What is good about NixOS (and GuixOS) is that they apply to package management the same principles that Git applies to managing source code. The Nix store is basically an append-only database (you might even call it a "blockchain") of inter-dependent packages.

    So from an individual computer user's point of view, it is much safer to install and roll-back software with Nix than with an ordinary package manager that might allow you to accidentally delete package dependencies and break your system. With Nix, you can install packages that actually do break your system, but because of the append-only nature, you can actually roll-back the install automatically right from the Grub boot menu, no need to re-install anything.

    Another advantage of NixOS, though this is more from a system operator's point of view, is that you can guarantee reproducible builds. If the package you have installed has the same hash on all of your computers, that is a simple, human-verifiable proof that all of those systems are running the exact same build of the software. You can probably see that this is very useful for people running servers, like compute clusters, or doing things like A-B testing.

    12
  • I think if you have no answer, it could be that NixOS doesn't solve any problem for you. In effect, it's not better. Don't buy into social media hype. It's just a tool like any other.

    9
    • You're spot on and that's what this discussion helped me figure out: I have no problem. I knew that but I also thought that NixOS would bring something new to improve my Linux usage. So far I still see such improvements for servers or deployment on several machines but not for a single user with standard needs (and this statement may be wrong and due to my limited experience with NixOS).

      But NixOS approach is quite different from others and I feel like I may discover something of interest to me once I learn more about it. Also, just for the sake of learning and discovering, I will continue experimenting with it for a while.

      2
  • For me it's the fact that I have one source of truth for my whole system config that I can stick in git

    If I want to clean up software I don't need anymore I just remove them from the package list and they're gone next rebuild

    Also means when I reinstall or setup a new system I just run the installer, do a git pull, rebuild and I've instantly got all my tools, configured just how I like them

    Also, if I want to make a big change I can build my system in a VM first to make sure it works first (not that I do that because it also lets me revert to an earlier build from grub if I need to)

    I've also got both my laptop and my PC on basically identical configurations from the same git repo with each of them having a smaller config file for hardware specific stuff

    8
  • I'm currently working on rebuilding a Debian web server that's been around for 10 years and accrued configuration over that time in NixOS. It's nice to have one single easy to understand file that fully defines the server and can be used to rebuild it if needed.

    4
    • I can see that from a server maintenance point of view. After having read so many great things about NixOS, I may have exaggerated my expectation and I may be the problem for being a user with too limited needs to get the full benefits of NixOS.

      For me this single config file doesn't save that much additional files and most of them would be files you configure only once during installation. Nonetheless I can see how "easier" it would be to save one file instead of 3 to reproduce your system and I can only imagine how much better it is from a server point of view.

      3
      • You might be selling it a bit short. I am not a Nix user, but like you I've played around in a vm. The value proposition I see for "normal" users is when you end up tuning and configuring your system just the way you want it (everyone knows what I'm talking about--it happens over months or even years). In nix, you have to do those changes in the config so you can literally take that one file, plop it somewhere else and it's your computer.

        Likewise, I've been on this install of Pop for years and for several upgrade cycles. The amount of cruft; things I've installed and don't use, config changes I made while following a tutorial then forgot about, manual tweaks for things that have been officially patched, etc. it would all be in a nix config for me to just... remove.

        So I see that as the benefits of it.

        That said, it definitely gives me vim vibes. Where the learning curve is pretty steep but once you master it, it's close to tech Nirvana. Again, since I don't use it I can't say that for sure. Maybe one day I'll have enough time to devote to it to really dive in. Right now, it's frustrating to use because everything is harder and there aren't many guides on how to do basic things like get dash-to-dock plugin working on popshell. Or even install and configure neovim. Ain't nobody got time for that right now.

        4
  • So, it's like this. Your operating system is an environment. It has it's paths, it's got it's file system. In many ways said system can have plenty of conflicts and issues regarding dependencies, runtime and permissions, even cruft that it will accrue over the years even.

    This is where nix comes in. Nix creates sterile, reproducible environments. With flakes, the reproducibility is 1:1. It can also manage several environments, all isolated from each other.

    Not only that, but technically speaking, nix can build anything, as it's a build system of build systems. You don't have to rely on nixpkgs or NixOS. You still get the environmental magic, along with whatever nix evaluations you put into it, so you could make your own nixpkgs (or recipes, really).

    Personaly I want to go deeper, so I was thinking of how I could beat make my own package set by getting all the SRPM's of say RockyLinux to create rockypkgs, which is just the Rocky Linux selection of packages and patches built into nix environments.

    Maybe you could then also have ubupkgs, fedpkgs, rhelpkgs... mix and match packages lol Yeah, it really is that insane.

    Imho Nix has not reached it's potential yet because of some stuff that needs to be fixed, but restructuring and refactoring is underway. Nix as a command will become more streamlined and central for ease of use, and nixpkgs needs a bit of recajiggering to get the package layering just right - or so I've heard (find us, in the Matrix chats).

    LETS GO, RFC136!!!

    3
  • If I didn't already have my relevant configurations tracked in git and my (quite simple) post-install script to copy the configs to relevant dirs, I guess I'd use Nix. I don't see the appeal when I have the same functionality on a distro I am familiar with.

    3
  • NixOS puts your full system configuration in a portable set of files. You can easily reproduce the same configuration on another machine. I also like that instead of accumulating a growing list of packages that I don't remember why I installed I have package lists specified in files with comments, and split into modules that I can enable or disable.

    IMO NixOS works best when you also use Home Manager to apply the same benefits to your user app configurations and such. (OTOH you can use Home Manager to get those benefits without NixOS. But I like that I get consistency between the OS-level and user-level configurations, and that both use the same set of packages.) I use Home Manager to manage my list of installed packages, my dot files, Gnome settings, Firefox about:config settings, and so on.

    You might be installing packages imperatively with nix profile install or with nix env -i. If that's the case you're not going to see the full benefits of a declarative system in my opinion. I prefer to install packages by editing my Home Manager configuration and running home-manager switch.

    I like that NixOS + Home Manager automates stuff that I used to do by hand. A couple of the things that I do or have done are to,

    • test an experimental window manager, Niri
    • use Neovide (a GUI frontend for Neovim) with a custom patch to tweak font rendering

    Now I have that kind of stuff automated:

    • Since there was no packaging for Niri when I started trying it I wrote my own in my NixOS config with a NixOS module to set up a systemd unit to run it. Because Nix packages are effectively build scripts, whenever I update Nix automatically pulls the latest version of Niri and compiles it without me having to think about it anymore.
    • I use the Neovide package from nixpkgs with an override to compile with my custom patch. Like with Niri my configuration automatically gets the latest Neovide version and builds it with my patch when I update, and I don't have to think about it anymore. I use this overlay to do that:
    modifications = final: prev: {
      neovide = final.neovide.overrideAttrs (oldAttrs: {
        patches = (oldAttrs.patches or [ ]) ++ [ ./neovide-font-customization.patch ];
      });
    };
    

    You can see that I compile some things from source. That's fine on my desktop, but takes a while on my travel laptop. But I don't need to compile on my laptop because I can use Nix's binary cache feature. I push my NixOS and Home Manager configurations to Github, and I have Garnix build everything that I push. Garnix stores everything it builds in a binary cache. So when I pull my latest configuration version on my laptop it downloads binaries from that cache.

    1
  • Just wait until you mess up something like DNS or delete every text editor and you'll be grateful for rollbacks.

    0
  • You'll understand when you're older, son

    -2
    • Or maybe I'm already too old for so much tech. But thanks for letting me think that I'm still a young boy ^^ Not helping with my question but pretty self satisfactory.

      6
  • NixOS is better because...

    ...broken link ... or non-existent reasoning?

    @wwwgem

    -5
    • This is a text post, so the OP wrote text corresponding to the title. You should be able to see it at the top of the post. (Spoiler, OP is basically asking the community why NixOS is better, because they don't quite understand the advantages of using NixOS.)

      1
You've viewed 54 comments.