/nixos_on_surface_go

Installing nixos on a surface go tablet

Primary LanguageNix

NixOs on a Surface Go

These are some brief notes on installing and running NixOs on a Surface Go. It assumes you are familiar with linux.

This repo also has my configuration, dotfiles and any other tweaks I find useful for this tablet.

Disclaimer: I’m new to NixOs. I switch distributions frequently though and I’ve used all the main ones. My favourite by far is Arch but keeping up with the changes is a little too intense for a secondary machine.

Prep

The firmware for the wireless (QCA6174 Ath10k) will not work for the install (NixOs 19.09) and the tablet has a single USB-C port so you will need a USB hub with an ethernet connection and a USB drive port.

  • Create a liveCD image and copy it to a USB drive https://nixos.org/nixos/download.html
  • In UEFI Menu, turn off Secure Boot and move the usb storage up the list for boot order
  • Boot into the install media

Partition and format disk

I’m completely removing Microsoft OS in this install, I’ve tried dual booting on the surface go and found I never booted into the MS side so it’s a waste of space.

Went for a simple four primary-partitions scheme:

UEFIFAT247 Mb
SwapSwap10 Gb
/homeext440 Gb
/ext469 Gb

Follow the instructions in NixOs Manual: partitioning, I used cfdisk. Reformat the partitions according to manual.

Initial install

Mount the partitions following the manual. Also mount /home to /mnt/home, and use swapon.

Run

# nixos-generate-config --root /mnt

The partitioning and swap with be detected by the script and configured, which is why you should mount all the partitions and turn on swap.

You’ll have either vim or nano available depending on install media so go ahead and add a user and some packages to the config:

# vim /mnt/etc/nixos/configuration.nix

Do the installation

# nixos-install

Set the root password and reboot.

WiFi

We’ll setup nix to replace the wireless firmware on builds. Added the following script in /etc/nixos/:

# qca6174_firmware.nix
{stdenv, pkgs}:
stdenv.mkDerivation {
  name = "surface-wifi-firmware";
  src = ./surface-wifi;
  priority = 1;
  installPhase = ''
    mkdir -p $out/lib/firmware/ath10k
    cp -r $src/* $out/lib/firmware/ath10k
  '';
}

then grabbed firmware files from https://github.com/mexisme/sboehler-nixos-config into the directory surface-wifi/.

Inside configuration.nix call the function with

hardware.firmware = with pkgs; [
  (callPackage ./qca6174_firmware.nix {})
];