Switching to NixOS

Posted on February 17, 2019

There was lot of traction about NixOS in the haskell community and i have decided to try it out. The switch to NixOS has proven me benificial. NixOS is a Linux distribution built on top of Nix Package Manager, a declarative style functiona package manager with a unique approach to package and configuration management.

we would explore the benifits and also some of the obstacles i have encountered while using NixOS.

Installation:

i would consider the installation process of Nix OS as medium hard and suggestions mentioned in qfpl, Chris Martin’s blog and nixos manual has helped me a lot with the installation process. The Grub Loader did not turn up immediately after installation.

i have encountered two problems

  • My hard drive was detected as sdb and usb drive as sda during installation, and on restarting of laptop after os installation the boot loader did not turn up after removing the usb. This i have fixed by changing the boot sequence in bios and restarted my installation again.

  • Secondly if you are installing in UEFI system setup it would be required to change some of the bios settings. on my hp folio 9480m laptop , i have to select the custom boot option and provide path to the EFI file, also i have set the time delay to show the bootloader screen to zero as shown below.

i would recommend the above blogs for reference to installation process.

The NIXos is built on top of nix package manager and one can install nix package manager on any linux variant or mac os.

Pros

  • The os is lightweight (lighter than most of the docker linux distributions). you exactly do have the control of each and every software or library installed and it is bloat free unlike other linux distro.
  • The OS and software installation is completly reproducible.if you want to reproduce the environment all you need is share the nix configuration files and rebuild using the nixos-rebuild switch.
  • one does not need sudo access to install software or library, multiple users can install packages without any issue or conflict.
  • installing new desktop environment or upgrading the kernel was never so easy and is just modifying a couple of lines in configuration file and giving a rebuild.
  • Rolling back to previous state can be done easily and it restores exact original state. upgrades and rollbacks are atomic.
  • you can also test your software without installing using nix-shell and this i found it amazing especially when developing software. ( we will see how it helps in setting up development environment in a separate post)
  • you can have multiple versions of software installed without interfering with each other and without corrupting the global configuration as packages are stored separately in nix store (/nix/store/-library) and the system can never be in inconsistent state. For details on how nix manages packages kindly go through the wiki.

Cons

  • not every package is readily available when compared to other package managers , you have to write your own package and writing yourself package is little bit hard for me.
  • some of the programs may not work outright where the paths to certain programs are hardcoded. e.g you would’nt find any binaries in /usr or /bin location. ( you will find only /usr/bin/env and /bin/sh and not any others in /usr & /bin respectively).
  • it can eat up memory as uninstallation of package does not remove the package from the system ( it makes easier to rollback), to clear the space you have to call the nix-collect-garbage.