< Articles

Notes on Nixos After a Week

| 612 Words | Tags: NixOS, Linux, HomeLab

Motivation

I migrated my Home-Lab-Server from Ubuntu LTS to NixOS about a week ago. The Journey was and still is quite interesting. I very much like the idea behind NixOS. Declerative system wide configuration management, atomic updates, rollbacks, reproducability, just getting the config to another machine and getting the exact same system…? Sounds like a Dream come true to me, especially in regards to servers. Thankfully, the transition went relatively smoothly. Altough in general the state of NixOS’s documentation leaves much to be desired - especially if you’re used to Arch - the installation docs were actually pretty good. So after two or three hours and me fighting the container-data dirs permissions that got messed up in the process, the Server was up and running again, so far so good.

Thougts on it after a week

I like it so far. Nix (package-manager & programming language) and NixOS are definetly a rabbithole and it will take a good while until I’m familiar enough with all of them until I really feel at home but that is really part of the fun. It still feels very adventurous and everything is new and shiny. Let’s see how long it stays that way. Currently I’m daily driving Fedora-Asahi-Remix on my macbook and Arch (btw) on my Desktop. I am considering using NixOS on my Desktop in the future. That would accelorate the learning process by a lot probably, but we will see about that.

Also: Nvidia GPUs work great. Before in Ubuntu it was such a pain i t A dealing with the nvidia graphics card, but now it was literally just one line of code. One line. And another line for making it available to the docker Containers. Thats just crazy imo.

Currently im still running my Containers using docker-compose and it works just as well as before, but I heard NixOs does virtualisation of OCI containers natively very good and I am considering migrating, although that will probably take a while. But then again I only heard lots of good things about it (except for the migration process). There is an elegant way of Secrets handling (agenix) and the whole reproducability and rollback stuff reaches another level. Also it keeps you from doing stupid things like skipping a major Nextcloud release (which I have done (…two times)). I’ll definetly do a follow up after more time has passed.

Whats a Flake?

That is the Question it seemed I would never get a definitive answer for and maybe there really just isn’t only one. Or at least it depends on who you ask and how complete the answer should be. I found this one after a good while which I found tangible:

“A Nix flake is a directory with a flake.nix and flake.lock at the root that outputs Nix expressions that others can use to do things like build packages, run programs, use development environments, or stand up NixOS systems. If necessary, flakes can use the outputs of other flakes as inputs.” ~ Zero to Nix (see below)

Tips and Ressources

  • you can symlink the configuration, so you can use git
    bash
    1sudo mv /etc/nixos /etc/nixos.bak  # Backup original configuration
    2sudo ln -s ~/nixos-config /etc/nixos
  • you can keep configuration for a whole army of Hosts in 1 Repo, using Flake.nix and modulisation
    txt
     1# example tree
     2~/nixos-config/
     3├── flake.lock
     4├── flake.nix
     5├── common/
     6├── hosts/
     7│   ├── host1/
     8│   │   ├── configuration.nix
     9│   │   ├── hardware-configuration.nix
    10│   │   └── services
    11│   └── host2/
    12└── modules/
    13    ├── common-system.nix
    14    └── packages/
    15        ├── common.nix
    16        └── server.nix
  • Ressources: