July 25th, 2024

Switching from Arch to NixOS

The author discusses their transition from Arch Linux to NixOS, highlighting improved system configuration management, challenges with documentation, and a smooth setup process, while noting a steep initial learning curve.

Read original articleLink Icon
Switching from Arch to NixOS

The author shares their experience of migrating from Arch Linux to NixOS after a month of use. They were motivated to switch due to the need for a more efficient way to manage and automate system configurations, which they found cumbersome with the traditional "dotfiles" approach on Arch. The author highlights the challenges of maintaining a dotfiles repository, such as missing configuration files and issues arising from package updates. Nix, a package manager, and NixOS, a Linux distribution utilizing Nix, offer a solution by providing reliable and reproducible package management, isolating packages to prevent conflicts, and allowing users to configure their systems through Nix's programming language.

Initially, the author tested NixOS in a virtual machine to familiarize themselves with its unique user experience. They found the transition to be smooth, replicating their Arch setup in about four to five days. After a month of use, they noted that while the knowledge from traditional Linux distributions seemed less relevant, it was still applicable. The author appreciated the self-contained nature of Nix packages and the modular organization of configurations, which simplified their setup compared to Arch. However, they also pointed out the challenges of navigating NixOS's documentation and the abundance of options available for configuration. Overall, the author believes that Nix and NixOS are powerful tools for system management, though they feel the initial learning curve may not yet justify the time invested. They remain optimistic about the potential benefits as they continue to explore NixOS's features.

Link Icon 8 comments
By @rkangel - 4 months
I think there's too much focus on going whole-hog with NixOS, and not enough on just using Nix with home-manager on top of your existing distro.

As the sibling comment describes, Nix can get a bit gnarly once you're off the beaten path, and having your whole OS subject to that is a pain.

But as an alternative approach I run Fedora, and install key stuff through the OS using dnf in the normal way, but then I have a home-manager config that covers all my key config, and a lot of the extra applications.

Yes, I don't get the full "value" of a whole system under version control. But I have a very stable, well proven system with few surprises. And I also have good version control of my config and day to day apps.

Plus the extra Nix stuff - if I want to try out a program, or use it temporarily I can just launch a shell with it and it's not cluttering up my system for ever (e.g. when exa was on HN yesterday, I could just do `nix-shell -p exa` to get a shell with exa in it. At some point in the future it'll get garbage collected again).

By @aquova - 4 months
> In the end, I really think Nix and NixOS are very strong tools for achieving reliable and reproducible system configurations and package management. Unfortunately, though, I don’t think the benefits I’ve gotten in this one month of using NixOS so far justified the cost I’ve initially spent and continue to spend learning Nix and NixOS.

This largely reflects my experience with NixOS as well. I installed it for a few months on my laptop (on two separate occasions) and there are parts of the OS I love. Being able to simply define your packages and user setup in a single configuration file is incredible, and even now if I wanted to switch back to Nix, I could dig up my configuration.nix and pick up where I left off. Gone too are the piles of mysterious packages installed on my system but I can't recall why they're there or if I still need them.

Unfortunately, once you start stepping off the beaten path, Nix often became a source of frustration. If there's a well working package available in its repositories, great. If not I found creating my own Nix packages to be an experience of arcane incantations, even for the simplest things. Compare this to writing Arch AUR PKGBUILDs, which are simple, glorified shell scripts, and it quickly led to me growing frustrated with the OS.

I think what eventually did me in was trying to get Neovim LSPs installed correctly. For some reason I never really understood, where ever my Nvim plugin was installing them was certainly not where Nix wanted them, and I never resolved the issue. Things like this eventually drove me back to the comforts of Arch, although every once in a while I look back over and wonder what could've been. I think it's the only distro I've tried in recent years that really tempted me to switch permanently.

The ideas of NixOS are fascinating, and I really think it can create a new paradigm in the Linux space. However, I'm unsure whether it'll be Nix itself that really gets there.

By @peter_d_sherman - 4 months
The greatest feature of NixOS (in my opinion) is the ability to run what are called "ephemeral shells" -- that is, to be able to download and run software in an isolated environment without initially installing it; without it changing or damaging the main environment in any way.

This is accomplished via the shell command:

'$ nix-shell -p <name of software>'"

i.e.,

$ nix-shell -p vim

Where <name of software> can be found from over 100,000 packages (here):

https://search.nixos.org/

Functionally, the above is the equivalent of what Google Play Store, Apple App Store or Microsoft Store or what other Linux package managers are to their respective platforms...

To install software permanently, edit /etc/nixos/configuration.nix to include the name from above (typically under environment.systemPackages), and follow up with:

$ sudo nixos-rebuild switch

Also, it's not too difficult to undo those changes should that be wished, but that's beyond the scope of a simple HN post...

Anyway, in my opinion, NixOS is probably the most Software Developer friendly evolution of Unix since Linux itself.

Well worth a try for technical people -- but there is a learning curve when trying to do very specific esoteric things with it(!)... but that's sort of the case with anything technological...

That being said, there's lot more documentation about NixOS on the web these days than there was in the early days... so it may be worth a look!

By @dabber21 - 4 months
There are attempts to make create more user friendly Nix bases OSes, I submitted one to hackernews a a while ago: https://snowflakeos.org/ (https://news.ycombinator.com/item?id=39831027)

But I don't know what the current state of it is as of now

By @teekert - 4 months
I did the same but opted to install NixOS as primary OS on my work laptop immediately (I came from EndeavourOS). And the experience was actually very smooth. You can install a KDE or Gnome desktop from an iso graphical installer, add your packages to configuration.nix and start being productive.

Yes this is the start of a very steep learning curve but I have been taking it very slow and it has been working for me since day 1. I think it’s pretty brilliant that the entry level is so low.

Experimentation is cheap (just use grub to boot into your previous env if you mess up, try packages with nix-shell), and I have had great help in the Jupiter Broadcasting Nixnerds Matrix channel. Some great people are in there.

By @jasonriddle - 4 months
I'm of the mindset that NixOS is too much, all at once. I understand the power of the Nix ecosystem, but the barrier of entry remains too high to enter.

I've switched to using devenv[1] as a first step. This at least allows me to experiment with using nix to configure my dev environment in a per directory fashion, while allowing me to use the Linux distro of my choice.

[1]: https://github.com/cachix/devenv

By @madamelic - 4 months
Augh.

Sounds like having NPM as an OS. Absolutely no thanks.

I'll stick with "difficult" package managers that seem to resolve things simply rather than having 27 different copies of the same thing and having to worry about things I didn't before. If, for whatever reason, I need two disparate versions of something I'll figure it out myself rather than abstracting it away.

In my mind, this move seems to be moving from 'high potential energy' to 'low potential energy' where you don't have any room to escape; you have locked yourself at the bottom of a pit and you just have to hope things don't roll over the top because you are at the whims of what NixOS has decided. If you were in a 'high potential energy' situation (ie: Basically any other distro), you would have room to fix it yourself or even take your widely compatible dotfiles and move to a different OS. Even if you are allowed to do configuration outside of NixOS as written, I am going to guess that NixOS isn't a huge fan of it and that configuration is fragile.

> However, after using NixOS for a while, I realized this was not true. The abstraction that NixOS packages provide doesn’t hide everything from the user to avoid confusion with irrelevant details. Instead, it offers a way to configure your environment the Nix way, so the resulting configuration files are created by Nix.

I'd rather beat my head against a wall for a day figuring out how to configure something than get locked into an OS-specific configuration that I can't move elsewhere.

Also when you combine it with this:

> The documentation is not in great shape.

Absolutely no thanks. You are telling me I have to do things the "NixOS way" but also your documentation is bad / inferior? Absolutely no thanks.