NixOS / nixpkgs

Nix Packages collection & NixOS
MIT License
17.46k stars 13.66k forks source link

nixos manual: missing warning about firmware #163586

Open bgohla opened 2 years ago

bgohla commented 2 years ago

I followed the instructions in the installation section of the NixOs manual to install using the lustration method. I ended up with a bootable system, but no network access. This turned out to be due to missing firmware for my wifi card.

After some trial and error I was able to figure out that adding

  hardware.enableRedistributableFirmware = true;

to the generated /etc/nixos/configuration.nix is crucial for making the firmware drivers available for loading.

I would submit a PR myself, but I am unsure which section it should be in, i.e., https://nixos.org/manual/nixos/stable/index.html#sec-installing-from-other-distro or further up.

Artturin commented 2 years ago

nixos-generate-config usually adds this by importing a another module

Please send the contents of /etc/nixos/hardware-configuration.nix

What wireless card do you have?

bgohla commented 2 years ago

nixos-generate-config usually adds this by importing a another module

Please send the contents of /etc/nixos/hardware-configuration.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 = [ ];

  boot.initrd.availableKernelModules = [ "xhci_pci" "nvme" "usbhid" "usb_storage" "sd_mod" ];
  boot.initrd.kernelModules = [ ];
  boot.kernelModules = [ "kvm-intel" ];
  boot.extraModulePackages = [ ];

  fileSystems."/" =
    { device = "/dev/disk/by-uuid/c0903bce-ce81-429c-b934-2a129879b686";
      fsType = "ext4";
    };

  fileSystems."/var/lib/docker" =
    { device = "/var/lib/docker";
      fsType = "none";
      options = [ "bind" ];
    };

  fileSystems."/boot" =
    { device = "/dev/disk/by-uuid/9894-2987";
      fsType = "vfat";
    };

  swapDevices = [ ];

  powerManagement.cpuFreqGovernor = lib.mkDefault "powersave";
  hardware.cpu.intel.updateMicrocode = lib.mkDefault config.hardware.enableRedistributableFirmware;
}

What wireless card do you have?

02:00.0 Network controller: Intel Corporation Wireless 8265 / 8275 (rev 78)

Note though that firmware drivers for several other devices also failed (I don't remember with certainty which ones), it just so happened that wifi was the bottleneck.

Artturin commented 2 years ago

weird, the not-detected.nix(which enables nonfree firmware) should be added to imports when not in a virtual machine snippet from nixos-generate-config.pl

# Provide firmware for devices that are not detected by this script,
# unless we're in a VM/container.
push @imports, "(modulesPath + \"/installer/scan/not-detected.nix\")"
    if $virt eq "none";

and none of the other virtualization options have been added

my $virt = `@detectvirt@`;
chomp $virt;

# Check if we're a VirtualBox guest.  If so, enable the guest
# additions.
if ($virt eq "oracle") {
    push @attrs, "virtualisation.virtualbox.guest.enable = true;"
}

# Likewise for QEMU.
if ($virt eq "qemu" || $virt eq "kvm" || $virt eq "bochs") {
    push @imports, "(modulesPath + \"/profiles/qemu-guest.nix\")";
}

# Also for Hyper-V.
if ($virt eq "microsoft") {
    push @attrs, "virtualisation.hypervGuest.enable = true;"
}

# Pull in NixOS configuration for containers.
if ($virt eq "systemd-nspawn") {
    push @attrs, "boot.isContainer = true;";

the command used to detect virtualization is systemd-detect-virt

please send the output of nixos-generate-config --show-hardware-config

bgohla commented 2 years ago

nixos-generate-config --show-hardware-config

# 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")
    ];

  boot.initrd.availableKernelModules = [ "xhci_pci" "nvme" "usbhid" "usb_storage" "sd_mod" ];
  boot.initrd.kernelModules = [ ];
  boot.kernelModules = [ "kvm-intel" ];
  boot.extraModulePackages = [ ];

  fileSystems."/" =
    { device = "/dev/disk/by-uuid/c0903bce-ce81-429c-b934-2a129879b686";
      fsType = "ext4";
    };

  fileSystems."/var/lib/docker" =
    { device = "/var/lib/docker";
      fsType = "none";
      options = [ "bind" ];
    };

  fileSystems."/boot" =
    { device = "/dev/disk/by-uuid/9894-2987";
      fsType = "vfat";
    };

  swapDevices = [ ];

  powerManagement.cpuFreqGovernor = lib.mkDefault "powersave";
  hardware.cpu.intel.updateMicrocode = lib.mkDefault config.hardware.enableRedistributableFirmware;
}

It does look different.

FYI, I have this:

$ readlink `which nixos-generate-config`
/nix/store/aay0cp59k9krsx361bnhwk8c0mg8d8dc-nixos-install-tools-21.11pre-git/bin/nixos-generate-config
Artturin commented 2 years ago

How did you install nixos? Only thing that I can think of is that you installed from a container or a vm that the script doesn't handle

bgohla commented 2 years ago

No, there were no containers or VMs involved. Like I wrote in the description, I used the lustration method, as described in the manual. Hardware is a Lenovo Thinkpad, that was running Gentoo.

Artturin commented 2 years ago

what init system?

bgohla commented 2 years ago

I was using OpenRC. Could that be the culprit?

Artturin commented 2 years ago

yeah thats probably it, i'll take a look at the systemd source and see what it does when there's no systemd

cherusk commented 1 year ago

Had similar issue during upgrade from 22.05 -> 22.11, resolved by adding the flag @bgohla provided.

My init-system is systemd though.