The Joys of Nixos

My History with Linux

In 1999, I installed Fedora 5.2 on my parents' computer and started down the deep path of exploring technology in this fundamentally different alternative operating system.

I remember joining IRC:

Jevin: I remember typing in a password during the install, but what’s the username? Friendly Linux Person: Oh, your username is root.

Then I got started.

My progression of distros has looked something like this:

Fedora -> Slackware -> Gentoo -> Ubuntu -> (Back to MacOS) -> Arch -> NixOS

Each one had a different flavor to explore, as each had its own philosophy and approach.

Today, I want to talk about the joys I’m experiencing with NixOS.

NixOS - Starting Motivation

  • I love installing new packages to get the functionality I need.
  • I love tweaking my dot files to get them perfect.
  • I love trying out new tools and software to improve my workflow.

Why it Makes Me Happy

Keeping My Workflows Consistent Across Machines

At work, I use a MacBook, at home I use Linux laptops, and my homelab all have Linux installed.

Regardless of which machine I’m on, I have some baseline stuff that I need installed for me to be immediately productive:

  • Vim with my preferred plugins and setup
  • ZSH with Oh My Zsh and Powerlevel10k
  • Consistent username/password
  • Various command-line tools

Prior to Nix, I would build a mini-script that would just have a massive list of all the packages I needed:

sudo apt-get install vim ohmyzsh etc etc

Then I had a full GitHub repo with all my dot files that I would cherry-pick the dot files I needed.

Now, I have (though I need to clean up) a repo with all my dots and applications all put together in a flake.nix file that will detect if I’m on Mac, Linux, and if it’s a personal/work profile, then install the appropriate packages and the associated dot files.

Keeping My Tweaks Persistent

You know how you write these mini-aliases and scripts to do very random things? With Nix, I can do really helpful stuff like:

  home.shellAliases = {
    v = "${pkgs.neovide}/bin/neovide";
    pomodoro = "termdown 25m -s -b && ${pkgs.libnotify}/bin/notify-send 'Pomodoro complete. Take a break!'";
    s = "kitty +kitten ssh";
    colordropper = "grim -g \"$(slurp -p)\" -t ppm - | convert - -format '%[pixel:p{0,0}]' txt:-";
  };

This will install the associated package and run the command all in a single line.

Abstracting Dot Files

If I was a Bash user and wanted to convert over to Zsh, I would have to convert my .bashrc to .zshrc. With the above example for home.shellAliases, Nix has done the work to detect which shell you have installed and build those aliases in the respective dot file, with the appropriate configuration. This makes it really easy to try out new tools.

Rollbacks

Nix works entirely by putting packages in its own directory and using symlinks to update which package you’re using. Even further, whenever you apply a new system configuration change, say to your dotfiles, Nix using symlinks for basically your ENTIRE system. If you made a change that messed up your system, you can simply reboot and select the previous change, and you’re good to go!

Some Not So Great Things

It’s Not Opinionated

If you look at anyone’s NixOS definition, you will notice that they can all be structured very differently. While the flexibility is great, there are major benefits in locking down the developer user experience to make it far more consistent and structured. That way, when you need to do something, there is already a well-defined pattern established that everyone is using.

The Documentation is Lacking

It’s a common complaint on Reddit that the documentation isn’t great. While there is fair criticism there, when a system is so flexible, it’s really hard to teach everything about it to make people productive quickly. Yes, there are some boilerplate templates and some good tutorials, but I think that’s only going to take people so far.

Thankfully, ChatGPT is great to help debug and fix things.

The Debugging Messages Aren’t Great

If you make a mistake in your definition/config somewhere, the failure messages can be really cryptic. The only way I’ve been able to make this work would be to look at the change I made and try something different.

How You Can Try It Out

If this all sounds interesting, there are a number of different ways to try out Nix that I recommend.

Devenv

Devenv is a tool that will allow you to make development environments per project. You get the flexibility to pull in essentially any language, packages, and scripts to build and work in your project in just a few lines of config. In addition, when sharing this project with someone else, they can type devenv shell and have it do the right thing to create a reproducible, consistent experience across developers.

Home Manager

Home Manager uses Nix to manage the home directory. You can use this with more Mac and ANY Linux distribution. It’s a great way to get the power of Nix without having to commit to the whole NixOS. It has access to all the same packages that NixOS does.

NixOS

NixOS is the way to go if you want to fully immerse yourself in Nix. You can install it on your machine or in a VM. A word of caution, though, the learning curve is significant, so it may take a while to become proficient.

Conclusion

NixOS is making it a joy to use my machine again. My personal Nix config is public and regularly updated. You’re welcome to check it out and use whatever you want.