My Framework + NixOS Setup

Posted on Oct 11, 2022

I recently purchased a Framework laptop, and decided to install NixOS on it. I’ve been using Nix the package manager for some time now, and I’ve been enjoying it. I’ve also installed NixOS on the server that runs my mastodon, and it frankly ROCKS.

Installing NixOS on this laptop has been… less enjoyable. To be clear, I don’t blame either framework or NixOS for any of the issues. Even for linux, I’m running a very very niche setup. However, I suffered through a lot of the problems, and so I hope to help others in their journey.

Before we get too far into things, some info:

  • I’m using a 12th generation Framework laptop, with an i7 processor
  • I’m installing NixOS 22.05 stable here.

In the installer

I used the minimal installation ISO and followed the steps in the manual. Notably, I found that the installer didn’t include networkmanager, and instead used wpa_supplicant. I used the following steps to connect to my home’s WiFi:

$ iwconfig # gives the interface name, mine was wlp166s0
$ wpa_passphrase 'SSID' 'password' | sudo tee /etc/wpa_supplicant.conf
$ wpa_supplicant -B -i <interface> -c /etc/wpa_supplicant.conf

The Arch Wiki gives an example where you use shell substitution to do this in one step, and without an intermediate file. I couldn’t get this to work?

From there I ran the installer as normal.

My Configuration

Networking

It is very, very, very important that you enable networking before you exit the installer. I forgot to do this and got myself into a bit of a pickle.

  networking.networkmanager.enable = true;

A User

I would also recommend setting yourself up with a user at this stage - I’m not sure what the consequences of forgetting this are, but it’s easy enough to do now:

  users.users.quail = {
    isNormalUser = true;
    home = "/home/quail";
    extraGroups = ["audio" "wheel" "networkmanager"];
    initialHashedPassword = "";
    shell = pkgs.zsh;
  };

Note that you’ll want to update your password immediately using passwd on first login.

A UI

I like i3, the relevant configuration for your display manager is in the manual.

Note that the 150 dpi is what my eyes find comfortable - you might fiddle with it.

  services.xserver = {
    enable = true;
    dpi = 150;

    layout = "us";

    windowManager = {
      i3.enable = true;
    };
    displayManager = {
      defaultSession = "none+i3";
      autoLogin.enable = true;
      autoLogin.user = "quail";
    };
  };

Getting external monitors working

This was an adventure, to put it mildly. The below information is fairly Framework-specific, since it’s all about the specific graphics card that comes on board.

First, NixOS 22.05 uses linux 5.15 by default. The latest kernel has some improvements with the intel drivers:

  boot.kernelPackages = pkgs.linuxPackages_latest;

DO NOT APPLY THIS STANDALONE - While it doesn’t break anything, your next boot will have a lot of UI sluggishness. I suspect this is because xorg guesses the modesetting wrong. You want to do it in conjunction with:

  boot.kernelParams = ["i915.enable_psr=0"];

Which does… I’m not sure what, but it fixed my issues :)

From that point, use xrandr or arandr to configure your monitors.

Sound

I have both sound output and input working. Note that the framework laptop has… lacking quality for both the microphone and the speakers. I’d recommend using a real microphone and headset.

I decided to use pipewire - originally I was using regular pulseaudio but had issues with microphone input.

  security.rtkit.enable = true;

  services.pipewire = {
    enable = true;
    alsa.enable = true;
    alsa.support32Bit = true;
    pulse.enable = true;
  };