NixOS on the Framework Laptop 16

That’s impressive, so far my powertop observations haven’t seen me below 10w and usually more like 14w. I haven’t been able to find any processes that are doing any work. Research continues.

Recently it’s gotten a bit higher but still around 8W while idle. One major thing that contributes to energy saving is enabling vrr in Hyprland or whatever other Compositor you use.
In order to enable it, you have to be on the latest kernel provided by nixos-unstable, otherwise it won’t work.

Using OpenZFS, so I’m probably behind a bit on kernel versions. Looking forward to getting that retested when 6.9 rolls around. Thanks!

1 Like

I’m usually around 15W too, but with the dGPU attached, I’ll test without it.
Like @CodeMichael I’m using ZFS, but in the meantime I think it can be mitigated by setting a lower refresh rate on the screen.

You could also backport the patches to your specific kernel like I did here

For the people that don’t know, the Framework 16 has a wiki page on the official NixOS wiki. The page is currently marked incomplete and doesn’t have a lot of content. Community contributions to the wiki page are greatly appreciated, especially any older things that have been mentioned in this thread.
https://wiki.nixos.org/wiki/Hardware/Framework/Laptop_16

3 Likes

Are you also noticing a high rate of discharge when suspended ?
Sometimes it can be several percents each hour…

yeah, me too.

For your information, I found the following wiki page.

https://wiki.nixos.org/wiki/Hardware/Framework/Laptop_16

Just wanted to share my Nix config since it’s starting to really come together. I’m a complete newcomer to Nix, Wayland, and Hyprland so there has been a lot to learn, but I’ve used Linux for more than 2 decades so that background helped

I created a readme in the machines/framework folder that may be helpful for people setting up encrypted boot drives and secure boot as it covers the process (as best as I can remember) that I did.

Other feature I have is that everything is built from source and optimized for the processor rather than using the binary builds. There are a few build problems for different packages, but everything seems to be able to be worked around.

3 Likes

Thank you! This is very useful, the readme was great c:

I’m going to start playing with nix in a vm this weekend. What I want is secureboot on (and not shimmed if possible, so it’ll verify my boot code), encrypted disks, sleep-to-hibernate to an encrypted partition/swap file…

I have never succeeded in doing this before with Linux but I’m basically going for the same boot and disk security Windows would have if Microsoft didn’t constantly leak it’s keys.

Anyone got a guide on this?

Some of that is what I outlined here in my above GitHub (look for the readme in machines/framework, can’t link it here since it would exceed 2 links in a post)

I followed a couple of guides including lanzaboote/docs/QUICK_START.md at master · nix-community/lanzaboote · GitHub and https://www.reddit.com/r/NixOS/comments/xrgszw/comment/iqf1gps/?utm_source=share&utm_medium=web3x&utm_name=web3xcss&utm_term=1&utm_content=share_button

I can confirm with my config that I can hibernate to the encrypted swap and restore, but I did have problems connecting to WiFi afterward which I haven’t tracked down yet. Otherwise I was pleasantly surprised how easy it all ways and how well it worked.

1 Like

Great thanks. I’ll check it out.

I see you have framework-laptop-kmod and framework-tool.

I’m having trouble getting framework_tool to work, at least for setting charge limits. Is it working for you? I know the kmod is waiting for kernel 6.9, but I’m unsure if the same is true for the first party util.

Also, excellent config! Thanks for sharing.

Unfortunately I have not gotten anything with ec working. I see in dmesg “cros_ec_lpcs cros_ec_lpcs.0: EC ID not detected” and I assume that indicates things are not working. It looks like I’d need the patches or wait for Kernel 6.9 to get cros_ec / cros_ec_lpcs to work on the laptop. If I get some time I’ll add the patches to my config, but I probably will just wait for 6.9.

I’ve added the patches to my repository and can confirm that /dev/cros_ec shows up now. Some of the framework_tool commands like inputmodules work fine, but some like kblight fail for some reason. I also don’t see the the objects added to /sys that the kmod should have added and I don’t see the mod in lsmod nor am I able to modprobe it so it may not be configured / installed correctly.

Edit: Fixed now. I was loading the kernel module in my config the wrong way. I can now see the charge_control_end_threshold and framework_laptop::kbd_backlight objects.

1 Like

Wow, you figured that out fast! I had tried apply the patches using

    patch = (fetchurl {
      url = "https://lore.kernel.org/chrome-platform/2fba7925-f22a-4ea9-9368-57e50d2bddda@t-8ch.de/t.mbox.gz";
      hash = "sha256-...";
    });

but it kept failing to build iirc. Is it perhaps that I had to get just the v3 files somehow instead of the whole thread?

I’m not sure exactly how NixOS applies patches so I just went with the patch format I’m most familiar with. It is possible the patches could apply just fine from the mbox, but you probably need to use the right thread since that link included the v1 and v2 patches as well.

For fun I tried it with the series mbox link (https://patchwork.kernel.org/series/840830/mbox/) from [v3,0/4] platform/chrome: cros_ec_lpc: add support for AMD Framework Laptops - Patchwork. I didn’t finish building the kernel, just enough that it looks like the patch applied correctly:

  boot.kernelPatches = [
    {
      name = "cros_ec_lpc";
      patch = (pkgs.fetchpatch {
        url = "https://patchwork.kernel.org/series/840830/mbox/";
        sha256 = lib.fakeSha256; # Replace with the real hash, don't trust hashes people put in posts :-) - especially for kernel patches
      });
    }

FYI - if you want to look at the contents of the mbox link you had, you can run curl <url> | gunzip | less. That will show that it has the earlier versions of the patches which is probably why you had an issue.

1 Like

I have a package of the latest version of fw-ectool here: isz/nix/pkgs/fw-ectool/default.nix at main · quentinmit/isz · GitHub

It works for me on kernel 6.8.6 with no kernel patches.