Installing NIXOS - my experience so far.

Sometimes, I like to try new things. Some of them , have impressed me on first attempt, for example arch, qemu, lagrangians, etc while other have grown on me over the time, like Latex, Haskell, etc, and there are others which i vow never to use again (no, not gonna mention those abominations). Eventhough , I am curious to try new things, there is also a skeptical side which tries to reel in my curious-hyperactive self. So as a result, before trying new stuff, i usually like to do a bit of reading the wiki, hangout at subreddits, poke the anons, lurk at irc before i fully commit myself to trying. My latest gold was NIXOS, a declarative linux. 

Well if you wondering what the hell is a declarative Linux? then read on.

Traditionally, Linux distros have adopted two approaches. A release based model like the popular ubuntu, fedora, suse and the rolling model which includes my favourite Arch, majaro, gentoo and new to the list is kali. I have long enjoyed arch for most of my everyday and personal use and frankly i like the system. use a pacman -Syu to upgrade, browse the archwiki once a month to check for issues before runing the upgrade and you are fine to go. But I will not lie through my teeth and say that i never bricked my system while using arch. There have been a few very very rare situations. (emphasis is on the word very very rare). One of the instances, I could still clearly remember. I was runinng pacman -Syu on a old dell laptop , with no battery and the power blew up. Though this is not an arch specific issue, there are other times when i did an upgrade and wonder if i could go back to previous configuration. Though it was possible in principle , in practice it involved a bit of mental gymnastics with pacman.  Now Enter Nixos.

 

Enter NIXOS

The first time i read the name nixos was while browsing hackage. Most of the package there had a build release for Nixos. I never paid much attention to it until, a few months back when i saw the name mentioned reverently in haskell hangouts. Since my workhorse of a laptop was generating more than necessary amount of noise. Noise that triggers complaints from people around me. And an almost impossible to replace dead battery and a dead weight that gymrats would be proud of, I decided that i was time to get a second laptop, one that doesn't weigh a ton and has an easy battery replacement option. Along the way, I decided it was time to try Nixos on my new laptop as well.

The System

My two prime requirements for my new laptop was , one, it should not weigh a ton and second, should be cheap. In spirit of doing good data collection, i decide to check for a model that has compatibility in power management tools on the NIXOS side and on the hardware side,  it should have easily replaceable batteries. I finally found a cheap Thinkpad E series in fleabay. So after ordering the laptop, I had a week to read and prepare myself for the installation.

 

The Installation

Following the usual procedure, visited nixos download page. Got the 64 bit version, prepared a usb stick to get the image. Informed the bios to boot from the usb. The default had a nice KDE startup if one prefers a graphical display. I usually prefer terminal but it was nice to see that a graphical option is included. Especially, since I was installing it on a laptop where my preferred way of connecting to the internet is through a wifi, it was nice to use a networkmanager tool to establish a connection to the internet and proceed with the rest of the installation in text mode. Next came the boring task of creating partitions and mounting the filesystems. So everything was created and mounted to /mnt. Until now is the normal preparation which i would have done for any linux installation. Now comes the Nixos way.

The magic command is

 

nixos-generate-config

 

This generates a configuration file , configuration.nix, at a default location, /etc/nixos/ in mycase. After reading through the generated file , i commented a few services that i did would not miss (displaymanager for example) and enabled a few that i relied heavily on, (windowmanager and sshd). Additionally, I also added a few tools that i needed in environment.systemPackages . Plus a few install dependent questions like, bootloader and networking name had to be defined as well. Once I was satisfied with the configuration, it is time to do the install. The installation itself is a single command

 

nixos-install

 

And now, it was time to grab a well deserved (or not so well-deserved) cup of tea and wait for the installation to proceed.  Afterall, the installation only consist of two steps, generate a configuration file and run nixos-install on it. 

 

 

Post Installation

Instead of doing the usual of setting up a user account and configuring one of the display managers, this time i decided to go with a windowmanager. My choice of window manager is XMONAD. Maybe i will do another post on xmonad configuration for my personal setup. But for time being, my primary reason was to have a simple and configurable display wherein i had more space for terminal but at the same time i could do monitoring. Conky + terminator + screen was my preferred solution but since the display was smaller than my usual laptop, it was time to improvise and hence conky+terminator got replaced with xmonad + xmobar. (that and i was browsing unixporn)

Now it has been 2 months since i installed it on my thinkpad, so i believe any installation issues/bug would have been sorted out. I use it fairly for ssh access to my servers, latex, and a bit of haskell programming. upgrading is easier as runing pacman -Syu, though there is a concept of channels that one should keep track of.  There is one interesting aspect of the upgrade that stood out. Nixos controlls everything through configuration.nix. So everytime any change has been made to the configuration file, nixos-rebuild has to be run and for upgrading nixos-rebuild switch --upgrade has to be run for upgrading. Upon rebooting, the bootloader presents the present configuration plus all the previous configuration. Rollback to a previous version was never this easy. As some one who had to wrestle occasionally with pacman to get back old configurations this is a cherry on top of a cheesecake.

Analysing objectively, it is necessary to see not only the merits but also demerits and here is a set of pros and cons that i could see with NIXOS.

Pros

  1. Since everything is controlled through a simple .nix file, it was easy to add/share the configuration through git and voila, now everywhere  i can get my default setup installed. Way back i would not have cared much about having the same configuration but nowadays since i move between various places and occasionally, i forced to use a windows machine with vmware, having a NIXOS configuration helped me a lot to quickly setup my own customised work environment.
  2. The rollback option is nice, since i could just check new configuration or services without having to spend time doing compatibility research . Install , reboot and see if it works. if not, boot to the previous configuration.
  3. The community is nice, especially the folks who answered my questions in irc. (and just for the record, i did manage to ask some insanely stupid questions.)

 

Cons

  1. The wiki contents (or lack of) . As i mentioned in the begining, my preferred linux is still arch and as such, i am used to having the wiki holding my ublical cord and feeding me. The Nixos wiki felt more like a dry landscape.
  2. Since everything is configured through .nix files, nixos provides a level of abstraction. Depending of needs / knowledge level of the user, this might be a boon or bane. There are moments where i thought the abstraction was nice and other time times i had to struggle a bit. Once after the installation, the ip to name resolution failed. In my arch machines, i would have simply installed avahi and edited the resolution order in nsswitch.conf but nixos would allow no such thing. The nixos way of solving the problem involved with passing the correct option to .nix to allow nixos-rebuild to generate the required nsswitch.conf syntax. So yes, sometimes abstraction can be distracting.
  3. Some friends i discussed nixos with shared an aversion to the format of configuration.nix and compared it to a domain specific language. Coming with a few experience with haskell programming, there was not any difficulty for me but well ymmv.
  4. Everything is controlled through a .nix file, as someone who hated suse when they started to push with  yast2 to administer everything, the idea of having only one way to do things, still leaves a bad taste in mouth.
  5. Haskell packages seem to be a snowflake, eventhough escaping the cabal hell is appealing, documentation on the nix-shell and cabal environment seems to be buried deep in the wiki. Personally, I learnt more about it from irc pointers and blogs.

Final Thoughts

So far I am contented with the whole installation and upgrading process, though i have no intention of moving away fully from arch. Maybe for my future laptops and  if i have to reproduce or clone a system frequently then i would definitely go with NIXOS.

 

 

Add new comment

The content of this field is kept private and will not be shown publicly.

Restricted HTML

  • Allowed HTML tags: <a href hreflang> <em> <strong> <cite> <blockquote cite> <code> <ul type> <ol start type> <li> <dl> <dt> <dd> <h2 id> <h3 id> <h4 id> <h5 id> <h6 id>
  • Lines and paragraphs break automatically.
  • Web page addresses and email addresses turn into links automatically.