This page is part of my digital garden.

This page might be unfinished or have typos. These pages are meant as part of a public living notebook to be edited over time. For more, visit the page explaining the concept of a digitial garden.

NixOS

NixOS is essentially a big nix function that takes some configuration from you and combines that with Nixpkgs to create a full Linux Distribution which can be easily built, cached, rebuilt, verified, and etc. all using Nix.

NixOS Link to heading

Given a configuration provide the set of boot loader, kernel, and File System Hierarchy you desire and Nix can provide it. Thanks to it having lazy evaluation and smart caching from hashing all the contents of the derivations building a different operating system configuration could take seconds.

NixOS’s minimal ISO is now fully reproducible1

Configuring NixOS Link to heading

Configuring NixOS is a little bit like feast or famine. Sometimes a very complicated thing is literally one line and always works and other times you need to dig deeply into the .nix files of nixpkgs to figure out how it even works and how you can, maybe, change it to work for you for now.

Typically you’re changing the /etc/nixos/configuration.nix file for system things and using home-manager and ~/.config/nixpkgs/home.nix for things related to your user.

Basically I use one for things like Chrome, Firefox, my editors, ssh config and etc related to my user and I use configuration.nix for system wide configuration like the Kernel, networking, essential utils, etc.

Boot Link to heading

Hiding the output while NixOS starts is as simple as adding boot.plymouth = { enable = true; }; to your configuration.

Dual Boot Windows Link to heading

On my desktop I have Windows installed on one drive and NixOS installed on another. I use zfs for my NixOS drive. To be able to boot Windows on another Disk you must use GRUB 1 instead of simply using systemd-boot (which is simpler and faster, but again doesn’t support this).

My config looks like this:

{
  boot.loader.systemd-boot.enable = false;
  boot.loader.efi.canTouchEfiVariables = true;
  boot.loader.efi.efiSysMountPoint = "/boot";
  boot.supportedFilesystems = [ "zfs" ];

  boot.loader.grub = {
  devices = [ "nodev" ];
  efiSupport = true;
  enable = true;
  version = 1;
  # useOSProber = false;
  extraEntries = ''
      menuentry "Windows" {
      insmod part_gpt
      insmod fat
      insmod search_fs_uuid
      insmod chain
      search --fs-uuid --set=root XXXX-XXXX
      chainloader /EFI/Microsoft/Boot/bootmgfw.efi
      }
  '';
  };
}

OS Prober did not work for me so I added an entry manually. When looking for the values to replace XXXX-XXXX make sure to pick the EFI volume (usually around 499MB and at the end of the drive) because otherwise it won’t work.

You can use something like lsblk -o name,label,partlabel,uuid,size to see what the UUID is for the partition you need.

Warning: I’ve heard that Windows can get confused when doing major updates and screw up the EFI for NixOS instead of updating the one on its drive if it’s not the one which gets tried by the BIOS first. I haven’t run in to this yet, but it’s a known issue. Hopefully I can write some notes about fixing Windows EFI partitions later.

Desktop Link to heading

Some packages and extensions to install:

  • xsel is a good tool for using clipboard from the terminal like pbcopy in macOS
  • ddcutil is a great tool for controlling your monitors.
    • This doesn’t work yet, but it probably will soon: Recommended to install gnomeExtensions.brightness-control-using-ddcutil to control from Gnome tray
  • gnomeExtensions.screenshot-tool is great, but requires gjs. Otherwise works really nicely for making screenshots quickly.

Networking Link to heading

While working on my NixOS Router project I’ve learned a lot about setting up networks via NixOS as well as needed Kernel modules to do things.

I will add some notes later on about things I learned trying to enable tc_cake, creating multiple IP networks, setting up NATs, and creating port forwards. There is also some stuff to write in here about managing BIND and DHCP for internal networking stuff.

Setup tc_cake Link to heading

tc_cake which I used for my NixOS router project to help improve my internet latency.

Was very difficult because I made my life difficult by configuring NixOS too securely making it hard to test changes without rebooting (and therefore kicking me out of my SSH session).

Configuring Nix for Hyper-V Link to heading


  1. Discussion on NixOS reproducibility https://news.ycombinator.com/item?id=27573393 ↩︎

Last updated on