Framework NixOS (Linux) users self-help

To note for anyone running AMD, the nixos-hardware default module ‘framework’ sets nvme.noacpi=1 kernel param which is affecting standby. There’s some useful configuration in that module aside from that, so if you want to keep the module import you can force override the kernel param list with something like:

boot.kernelParams = lib.mkOverride 999 (builtins.filter (p: p != "nvme.noacpi=1") config.boot.kernelParams);

There’s also the common AMD cpu and gpu modules which are useful for import.

AFAIU it’s not a generic module, it’s a misnamed config specifically for the 11th Gen Intel version, retained under that name for backwards compatibility reasons. It also (via the generic “laptop” config) enables TLP, which Framework explicitly recommends against on the AMD version, so, I dunno.

Yeah, I just had it enabled since I migrated from the 11th gen. Just wanted to put it out there in case other people run into the same thing.

The framework folder definitely needs some restructuring, but obviously making necessary changes makes it backwards incompatible, which I guess is up to the maintainers. It will definitely need to change with the impending FW16 release.

I made PR #765 for nixos-hardware to add a 7040 config for now so other people can target it.

2 Likes

I didn’t bother with any harware specific configs on my 7040. Running the unstable channel and used the latest kernel with

 boot.kernelPackages = pkgs.linuxPackages_latest;

As far as I can tell, everything is working fine with KDE (with 3.03 BIOS everything is working great!). Up to 8 hours with light web browsing and screen at 25% brightness.

Edit: added “Up to” on the battery life as YMMV

Same - things have moved fast this week for sure. I hit a couple bumps but am happy on 3.03 beta, updated fingerprint firmware, and kernel 6.5.9 on Nix unstable.

In case it helps others, here’s some random bits from my config.

Firmware updates

services.fwupd.enable = true;

# this might be unnecessary, but I was having trouble with fwupdmgr hanging 🤷
# services.fwupd.daemonSettings.DisabledPlugins = [ "synaptics_mst" ];

# 3.03 is still in beta
services.fwupd.extraRemotes = [ "lvfs-testing" ];

Kernel

# 6.1 also worked fine
boot.kernelPackages = pkgs.linuxPackages_latest;

boot.kernelParams = [
  # reported to help with flashing display issues
  # "amdgpu.sg_display=0"

  # this is supposed to improve power-saving
  # but seems to cause a freeze on wake for me
  # "nvme.noacpi=1"
  
  # https://www.kernel.org/doc/html/latest/admin-guide/pm/amd-pstate.html#active-mode
  # note: if you're using 6.1, use "passive"
  "amd_pstate=active"
];

# https://git.exozy.me/a/zenpower3
boot.extraModulePackages = with config.boot.kernelPackages; [ zenpower ];

Power-saving
This isn’t really Framework-specific, and I’d interested to hear others’ configs, but this is a reasonable starting point IMO. See also the amd_pstate kernel param :arrow_double_up:

# https://github.com/AdnanHodzic/auto-cpufreq
services.auto-cpufreq.enable = true;
# auto-tune on start
powerManagement.powertop.enable = true;

Misc Hardware

# fingerprint reader
services.fprintd.enable = true;

# from nixos-hardware/common/pc/ssd
services.fstrim.enable = true;

# OpenCL / Vulkan
hardware.opengl.extraPackages = [ pkgs.rocm-opencl-icd pkgs.amdvlk ];
3 Likes

18 posts were merged into an existing topic: Framework NixOS (Linux) users self-help (Firmware/Patch discussion)

Hey guys :wave:
Followed some of the suggestions! Thanks for that!

Relatively newish to Linux so I can’t really make out dmesg gibberish yet. I have an issue where the Framework 13 7840U won’t resume from sleep correctly. I get thrown into GNOME with my display flashing white depending on how much action is on the screen. When I log out and in again, everything works.
Anyone got any ideas or maybe even the same problem?

Can provide more info if this is novel behaviour. Cheers guys

EDIT: Was able to fix this by using the correct drivers from GitHub - NixOS/nixos-hardware: A collection of NixOS modules covering hardware quirks.

Follow-Up question though: I’m getting a white screen as soon as I open gnome-video or smplayer in fullscreen by double-clicking on the video. Did anyone have the same problem?

EDIT: Also got that fixed by using the LTS kernel version:

❯ uname -srm
Linux 6.1.42 x86_64

Got the white screen failure on fullscreen with a kernel 6.4.x

2 Likes

My PR for nixos-hardware to add a config for the FW13 7040 AMD was merged, so the framework-13-7040-amd profile can be used as a target now.

I submitted another PR (#776) to rearrange the folder structure for better consistency and shared configuration. It adds a framework-11th-gen-intel profile as well to replace the framework base profile that was used for the 11th gen.

9 Likes

I’m new to NixOS-- is it possible to experiment with the FW13 7040 AMD config in a VM? Or does it not work because the virutalized hardware is not the same as the host hardware?

The root question is how can I experiment with this config without fully committing to running NixOS directly on hardware? Ideally I’d like to play with a config in the VM environment, and be able to just use that same config on the FW13 7040 AMD hardware.

I mean in general, NixOS allows you to do exactly that very easily, except for the part where this specific configuration module is dealing exclusively with the hardware compatibility, so… it kinda doesn’t really make sense to “test” it on a VM rather than on the actual device. How exactly were you planning to play with it?

If you just want to play with NixOS, you can just play with vanilla NixOS in a VM / container, and then, once you decide that you like it, switch to real hardware keeping you configuration + adding that module, which will (ideally) do nothing else but guarantee that everything is smooth.

If, however, you want to experiment specifically with those hardware-related settings, I guess, you real options are installing onto a separate partition or, like, onto a USB drive / microSD / external drive and booting from there.

@gaben I’ve been running NixOS in VMware on an M1 Macbook Air for the last year or so following https://github.com/mitchellh/nixos-config’s configs. I wanted to exit from the Apple ecosystem, so I got a Framework 13 AMD. Knowing the hardware was super new, I decided to once again run NixOS via virtualization on a Framework Ubuntu Host for stability. Here’s some notes to hopefully get you started - Let me know if you have any questions, I’m happy to help – I feel I’m always going to be a nix newbie lol. I’m close to finally ironing out all the issues I’ve experienced in this setup. (Though now with the above PR merged, I’m likely to go full bare metal install with NixOS…)

VMware - I tried this initially as I was using this on MacOS; however, I hit too many performance and odd issues, so decided to try VirtualBox out.

Wayland is just kinda a no-go it seems on any virtualization program, so I switched from sway wm back to i3wm.

VirtualBox - After setting the below configs in the host and inside the VM… it’s ‘mostly’ stable and relatively performant, though I’m still trying to debug, what I expect, is a video acceleration issue (dmesg shows [drm:vmw_msg_ioctl [vmwgfx]] ERROR Failed to open channel) and performance isn’t as good as on Ubuntu when compiling or transcribing via local whisper.cpp projects I’m working on.

VirtualBox Host:

  • Setup as described in my README.md below. (You’ll need to portforward on VB 2222 host to 22 guest, if you want to install like I’m doing in my nixos-config)
  • Increase video ram (VB has a max of 128MB in the GUI and 256MB in a cli config): VBoxManage modifyvm “Name of VM” --vram 256
  • 8 core // 10GB ram
  • set display scaling to 133% (when using my resolution set, see GitHub link below)

NixOS Guest:
You can follow some of my latest commits here: GitHub - nodu/nixos-config: My NixOS configurations. Specifically looking at the machine/vm-shared.nix config:
https://github.com/nodu/nixos-config/blob/main/machines/vm-shared.nix#L72 for display resolution in xserver.

Good luck!

1 Like

fwiw, I made a video of installing NixOS on a Framework. It’s too long, badly edited, contains mistakes which I fix, and doesn’t have the fingerprint reader working yet. But it does show setting up the system with a Flake and adding the hardware quirks and SSD optimisation.

I dunno, might be useful for anyone who likes to see it to believe it.

The (very simple) config is here if you want to “skip to the end”, as it were:

6 Likes

Not sure who else this will help, but I was having wifi issues and not getting the expected performance from my hardware.

$ lspci | rg -i wireless
01:00.0 Network controller: MEDIATEK Corp. MT7922 802.11ax PCI Express Wireless Network Adapter

I perused the Arch Linux wiki and found this note:

For the MediaTek chip, you will be limited to 802.11n (WiFi 4) and 2.4GHz bands if you do not configure the regulatory domain

Which led me to this nixpkgs issue with the solution:

So I added this to my nixos config:

hardware.wirelessRegulatoryDatabase = true;
boot.extraModprobeConfig = ''
  options cfg80211 ieee80211_regdom="US"
'';

Naturally, you will want to use whatever regdomain code is relevant for your regulatory domain. After this, I’m getting much faster speeds according to fast.com and dropping no packets while doing so.

3 Likes

Since the regulatory domain would require an argument based on the user’s domain, I’m not sure exactly how we would add it there. Maybe I’ll poke around and see if there are other modules that take arguments and submit a similar PR.

1 Like

Any KDE people? I’m finding plasma5 with default KWin is chopping up my firefox window, at both default compositor settings and `switching compositor off. I want to try KDE, it’s the only time I’ve seen screentearing outside of gaming though. Is there anything we know about intel? the framework is a 13 from batch 5 (2 years old), but mainboard updated to 13th gen a couple months ago.

┬─[qd@grindenstern:~/o/p/arct]─[10:21:57 AM]─[G:main>]
╰─>$ nix-shell -p neofetch --run neofetch
          ▗▄▄▄       ▗▄▄▄▄    ▄▄▄▖            qd@grindenstern 
          ▜███▙       ▜███▙  ▟███▛            --------------- 
           ▜███▙       ▜███▙▟███▛             OS: NixOS 23.11.20231116.7414e9e (Tapir) x86_64 
            ▜███▙       ▜██████▛              Host: Framework FRANMCCP07 
     ▟█████████████████▙ ▜████▛     ▟▙        Kernel: 6.1.62 
    ▟███████████████████▙ ▜███▙    ▟██▙       Uptime: 49 mins 
           ▄▄▄▄▖           ▜███▙  ▟███▛       Packages: 2247 (nix-system), 6708 (nix-user) 
          ▟███▛             ▜██▛ ▟███▛        Shell: bash 5.2.15 
         ▟███▛               ▜▛ ▟███▛         Resolution: 2256x1504, 1920x1080 
▟███████████▛                  ▟██████████▙   DE: Plasma 5.27.9 
▜██████████▛                  ▟███████████▛   WM: KWin 
      ▟███▛ ▟▙               ▟███▛            Theme: Adwaita-dark [GTK2/3] 
     ▟███▛ ▟██▙             ▟███▛             Icons: breeze-dark [GTK2/3] 
    ▟███▛  ▜███▙           ▝▀▀▀▀              Terminal: emacs 
    ▜██▛    ▜███▙ ▜██████████████████▛        CPU: 13th Gen Intel i7-1370P (20) @ 5.000GHz 
     ▜▛     ▟████▙ ▜████████████████▛         GPU: Intel Raptor Lake-P [Iris Xe Graphics] 
           ▟██████▙       ▜███▙               Memory: 4868MiB / 64027MiB 
          ▟███▛▜███▙       ▜███▙
         ▟███▛  ▜███▙       ▜███▙                                     
         ▝▀▀▀    ▀▀▀▀▘       ▀▀▀▘                                     

The basic on-rails plasma5

{
  # imports = [ ./../greeter.nix ];
  services.xserver = {
    enable = true;

    desktopManager.plasma5.enable = true;
    displayManager.sddm.enable = true;
  };
  qt.platformTheme = "kde";
}

note: for World of Warcraft (through lutris) in particular, KDE is the least finicky desktop with respect to screentear in my experiments. I tried services.picom.enable = true; and it may haev made the WoW usecase slightly worse, but I didn’t check choppiness/tear in firefox (it could be a different question). I’m also uncertain how often I should be relogging / rebooting to test stuff like turning the compositor off and on.

The other thing about KDE is that my fan has literally not stopped running once, even when I’m on a light computational load.

also its odd that I run fwupdmgr update about once a month, it always tells me there’s nothing. Then today I do it and it offers a jump from 33 to 371 on UEFI dbx.

╔══════════════════════════════════════════════════════════════════════════════╗
║ Upgrade UEFI dbx from 33 to 371?                                             ║
╠══════════════════════════════════════════════════════════════════════════════╣
║ Insecure versions of the Microsoft Windows boot manager affected by Black    ║
║ Lotus were added to the list of forbidden signatures due to a discovered     ║
║ security problem.This updates the dbx to the latest release from Microsoft.  ║
║                                                                              ║
║ Before installing the update, fwupd will check for any affected executables  ║
║ in the ESP and will refuse to update if it finds any boot binaries signed    ║
║ with any of the forbidden signatures.Applying this update may also cause     ║
║ some Windows install media to not start correctly.                           ║
║                                                                              ║
╚══════════════════════════════════════════════════════════════════════════════╝

Any downside to letting this run (it asked me yes or no)? I’ve never had fwupdmgr return any possible updates before.

Update: I ran it, rebooted, everything seems fine no noticeable difference. Still odd that it jumped from 33 to 371 so quickly, maybe the local index was wrong before.

Oh wow, what a small world. Have you tried it with wayland?

About fan — services.thermald.enable = true

I’m searching nixos options for a way to activate wayland under plasma, closest I found is programs.xwayland.enable = true;. It seems to have worked quite well, though!

EDIT: Found this on nixos wiki services.xserver.displayManager.defaultSession = "plasmawayland";

Thanks for thermald! Hadn’t seen that around.

1 Like

I made my own notes on nix, after a few months in, because the documentation is chaotic.

Hope it’d be useful here :slight_smile:

1 Like