NixOS despises my hardware, help

Either I, my config or my laptop is cursed by the nixos gods.

This is my nixos config, which is still a hot mess and it’s unusable by anyone but me, https://github.com/First-Non-Interesting-Username/NixOS-config

I know it is full of bad practices or things that need an improvement, but it’s still work in progress. Feel free to point it here or create an issue if you find something blatantly wrong.

Okay so NixOS HATES my laptop. I have thinkpad L14 G4 with ryzen 7330U, Vega 7 and MT7921. I had no issues with it whatsoever on any distro I tried, except for not having wifi on Ubuntu 18.04, but even there display was working. Outside of it, every distro worked OOTB, even basic NixOS, with this:

    # Do not modify this file!  It was generated by ‘nixas hardware-config.nix.
    # Do not modify this file!  It was generated by ‘nixos-generate-config’
    # and may be overwritten by future invocations.  Please make changes
    # to /etc/nixos/configuration.nix instead.
    { config, lib, pkgs, modulesPath, ... }:
    {
      imports =
        [ (modulesPath + "/installer/scan/not-detected.nix")
           #evaluates to `hardware.enableRedistributableFirmware = lib.mkDefault True;`
        ];
      boot.initrd.availableKernelModules = [ "nvme" "xhci_pci" "usb_storage" "sd_mod" "rtsx_pci_sdmmc" ];
      boot.initrd.kernelModules = [ ];
      boot.kernelModules = [ "kvm-amd" ];
      boot.extraModulePackages = [ ];
      fileSystems."/" =
        { device = "/dev/disk/by-uuid/42bda7be-6e27-40be-bfb9-b76b763289ea";
          fsType = "ext4";
        };
      fileSystems."/boot" =
        { device = "/dev/disk/by-uuid/FE17-114F";
          fsType = "vfat";
          options = [ "fmask=0077" "dmask=0077" ];
        };
      swapDevices = [ ];
      nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux";
      hardware.cpu.amd.updateMicrocode = lib.mkDefault config.hardware.enableRedistributableFirmware;
    }

as hardware-configuration.nix.

For my config I wanted to go with “modern” route and use only nixos facter and nixos hardware, instead of doing things the old way. I factered my laptop, added the result to the config; I found “right” module for my laptop and I imported it in my config. I foolishly thought that would be enough, so I installed the system. Without nomodeset I was getting only black screen. I couldn’t find my wireless interface in both ways (nmtui and ip link show) I know how to do it.

I tried other things, such as adding mt7921e and amdgpu kernel modules, enabling firmware in both ways or playing with disabling and enabling those settings. Best results I got was getting to plasma (I knew that because of cursor and hot corner) with black screen, with no progress on wifi.

Finally I decided to copy over the hardware-configuration.nix from fresh nixos installation. Result was still the same, getting to plasma and no wifi at all. Yes, I tried enabling everything, I had to use nomodeset to even get display. The current version of the config has it set like that, this is the relevant file: NixOS-config/modules/hardware/Laptop/hardware.nix at 5b8cc1ca058143c3458883c9cc0e448c41f4eb70 · First-Non-Interesting-Username/NixOS-config · GitHub

I genuinely don’t know what to do. I bet there must be a fundamental mistake in either my config that makes it impossible to have both display and wifi. I don’t what it may be, and at this point it can be anything. If anybody has stumbled upon similar issue before, please let me know what the fix may be.

Sorry if the fix is trivially easy, I’m still learning.

My facter result if anyone is interested: NixOS-config/modules/hardware/Laptop/facter.json at main · First-Non-Interesting-Username/NixOS-config · GitHub

Your pastebin is offline. Could you drop it simply in a code block? Those are scrollable and take a fair bit of data.

Given it all works, both with presumably the NixOS installer as well as a simpler config, have you considered just using the default, generated configuration.nix?

If you can boot that, you can add back bits of config slowly until you hit what’s causing the issues.

I’ll separately have a browse through your config and see if I see mistakes that could lead to this, and match it up with your hardware once you fix your paste, but this might be one of those times it’s easier to teach you how to fish than give you one.

You’ve done a very good job obfuscating, it’s a bit hard to follow what’s going on thanks to all the “modern” abstractions… I really would recommend not getting too swiped up by the hype, many of the abstractions you use exist just because they can. A lot of what you’re doing is just making yourself type more.

That’s probably what I will do next, thanks for help.

I’ll update you if I find a solution.

Update: I got wifi to work. I didn’t do what you recommended, instead I enabled what I felt like in hardware.nix and it worked. I will work on resolving the GPU issue now

1 Like