From 0335d1a093dc3e2c577e2243a192775db23485ba Mon Sep 17 00:00:00 2001 From: Sebastian Sellmeier Date: Sun, 7 Apr 2024 21:28:11 +0200 Subject: [PATCH 1/3] common/gpu/intel: Make initrd - i915 an option --- common/gpu/intel/default.nix | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/common/gpu/intel/default.nix b/common/gpu/intel/default.nix index ed76057..b8ab823 100644 --- a/common/gpu/intel/default.nix +++ b/common/gpu/intel/default.nix @@ -1,15 +1,26 @@ { config, lib, pkgs, ... }: { - boot.initrd.kernelModules = [ "i915" ]; - - environment.variables = { - VDPAU_DRIVER = lib.mkIf config.hardware.opengl.enable (lib.mkDefault "va_gl"); + options.hardware.intelgpu.loadInInitrd = lib.mkEnableOption (lib.mdDoc + "loading `i195` kernelModule at stage 1. (Add `i915` to `boot.initrd.kernelModules`)" + ) // { + default = true; }; - hardware.opengl.extraPackages = with pkgs; [ - (if (lib.versionOlder (lib.versions.majorMinor lib.version) "23.11") then vaapiIntel else intel-vaapi-driver) - libvdpau-va-gl - intel-media-driver + config = lib.mkMerge [ + (lib.mkIf config.hardware.intelgpu.loadInInitrd { + boot.initrd.kernelModules = [ "i915" ]; + }) + { + environment.variables = { + VDPAU_DRIVER = lib.mkIf config.hardware.opengl.enable (lib.mkDefault "va_gl"); + }; + + hardware.opengl.extraPackages = with pkgs; [ + (if (lib.versionOlder (lib.versions.majorMinor lib.version) "23.11") then vaapiIntel else intel-vaapi-driver) + libvdpau-va-gl + intel-media-driver + ]; + } ]; } From f8e89e4e847d25f32c68adccf61e3ad42967847b Mon Sep 17 00:00:00 2001 From: Sebastian Sellmeier Date: Sun, 7 Apr 2024 21:31:18 +0200 Subject: [PATCH 2/3] framework: Add framework-laptop-kmod as default for NixOS >= 24.05 --- framework/13-inch/common/default.nix | 1 + framework/kmod.nix | 17 +++++++++++++++++ 2 files changed, 18 insertions(+) create mode 100644 framework/kmod.nix diff --git a/framework/13-inch/common/default.nix b/framework/13-inch/common/default.nix index c79061a..b7b961d 100644 --- a/framework/13-inch/common/default.nix +++ b/framework/13-inch/common/default.nix @@ -2,6 +2,7 @@ imports = [ ../../../common/pc/laptop ../../../common/pc/laptop/ssd + ../../kmod.nix ]; # Fix TRRS headphones missing a mic diff --git a/framework/kmod.nix b/framework/kmod.nix new file mode 100644 index 0000000..81ce37a --- /dev/null +++ b/framework/kmod.nix @@ -0,0 +1,17 @@ +{ config, lib, ... }: +{ + options.hardware.framework.enableKmod = lib.mkEnableOption (lib.mdDoc + "Enable the community created Framework kernel module that allows interacting with the embedded controller from sysfs." + ) // { + # Enable by default if on new enough version of NixOS + default = (lib.versionAtLeast (lib.versions.majorMinor lib.version) "24.05"); + }; + + config = lib.mkIf config.hardware.framework.enableKmod { + boot.extraModulePackages = with config.boot.kernelPackages; [ + framework-laptop-kmod + ]; + # https://github.com/DHowett/framework-laptop-kmod?tab=readme-ov-file#usage + boot.kernelModules = [ "cros_ec" "cros_ec_lpcs" ]; + }; +} From 8cde8633d4f93659856695189fa3ead28b7a839b Mon Sep 17 00:00:00 2001 From: Sebastian Sellmeier Date: Mon, 8 Apr 2024 09:53:42 +0200 Subject: [PATCH 3/3] framework/12th-gen-intel: Refactor module https://github.com/NixOS/nixos-hardware/pull/897 https://github.com/NixOS/nixos-hardware/pull/846 https://github.com/NixOS/nixos-hardware/issues/894 --- framework/13-inch/12th-gen-intel/default.nix | 100 ++++++++++--------- framework/13-inch/common/intel.nix | 12 ++- 2 files changed, 62 insertions(+), 50 deletions(-) diff --git a/framework/13-inch/12th-gen-intel/default.nix b/framework/13-inch/12th-gen-intel/default.nix index b16dc1d..e2fdcfd 100644 --- a/framework/13-inch/12th-gen-intel/default.nix +++ b/framework/13-inch/12th-gen-intel/default.nix @@ -1,52 +1,62 @@ -{ lib, pkgs, ... }: { +{ config, lib, pkgs, ... }: +{ imports = [ ../common ../common/intel.nix ]; - boot.kernelParams = [ - # For Power consumption - # https://kvark.github.io/linux/framework/2021/10/17/framework-nixos.html - "mem_sleep_default=deep" - # Workaround iGPU hangs - # https://discourse.nixos.org/t/intel-12th-gen-igpu-freezes/21768/4 - "i915.enable_psr=1" + config = lib.mkMerge [ + { + hardware.intelgpu.loadInInitrd = lib.versionOlder config.boot.kernelPackages.kernel.version "6.2"; + } + # https://community.frame.work/t/tracking-hard-freezing-on-fedora-36-with-the-new-12th-gen-system/20675/391 + (lib.mkIf (lib.versionOlder config.boot.kernelPackages.kernel.version "6.2") { + boot.kernelParams = [ + # Workaround iGPU hangs + # https://discourse.nixos.org/t/intel-12th-gen-igpu-freezes/21768/4 + "i915.enable_psr=1" + ]; + }) + (lib.mkIf (lib.versionOlder config.boot.kernelPackages.kernel.version "6.8") { + boot.blacklistedKernelModules = [ + # This enables the brightness and airplane mode keys to work + # https://community.frame.work/t/12th-gen-not-sending-xf86monbrightnessup-down/20605/11 + "hid-sensor-hub" + # This fixes controller crashes during sleep + # https://community.frame.work/t/tracking-fn-key-stops-working-on-popos-after-a-while/21208/32 + (lib.mkIf (config.hardware.framework.enableKmod == false) "cros_ec_lpcs") + ]; + + boot.kernelParams = [ + # For Power consumption + # https://kvark.github.io/linux/framework/2021/10/17/framework-nixos.html + # Update 04/2024: Combined with acpi_osi from framework-intel it increases the idle power-usage in my test (SebTM) + # (see: https://github.com/NixOS/nixos-hardware/pull/903#issuecomment-2068146658) + "mem_sleep_default=deep" + ]; + + # Further tweak to ensure the brightness and airplane mode keys work + # https://community.frame.work/t/responded-12th-gen-not-sending-xf86monbrightnessup-down/20605/67 + systemd.services.bind-keys-driver = { + description = "Bind brightness and airplane mode keys to their driver"; + wantedBy = [ "default.target" ]; + after = [ "network.target" ]; + serviceConfig = { + Type = "oneshot"; + User = "root"; + }; + script = '' + ls -lad /sys/bus/i2c/devices/i2c-*:* /sys/bus/i2c/drivers/i2c_hid_acpi/i2c-*:* + if [ -e /sys/bus/i2c/devices/i2c-FRMW0001:00 -a ! -e /sys/bus/i2c/drivers/i2c_hid_acpi/i2c-FRMW0001:00 ]; then + echo fixing + echo i2c-FRMW0001:00 > /sys/bus/i2c/drivers/i2c_hid_acpi/bind + ls -lad /sys/bus/i2c/devices/i2c-*:* /sys/bus/i2c/drivers/i2c_hid_acpi/i2c-*:* + echo done + else + echo no fix needed + fi + ''; + }; + }) ]; - - boot.blacklistedKernelModules = [ - # This enables the brightness and airplane mode keys to work - # https://community.frame.work/t/12th-gen-not-sending-xf86monbrightnessup-down/20605/11 - "hid-sensor-hub" - # This fixes controller crashes during sleep - # https://community.frame.work/t/tracking-fn-key-stops-working-on-popos-after-a-while/21208/32 - "cros_ec_lpcs" - ]; - - # Further tweak to ensure the brightness and airplane mode keys work - # https://community.frame.work/t/responded-12th-gen-not-sending-xf86monbrightnessup-down/20605/67 - systemd.services.bind-keys-driver = { - description = "Bind brightness and airplane mode keys to their driver"; - wantedBy = [ "default.target" ]; - after = [ "network.target" ]; - serviceConfig = { - Type = "oneshot"; - User = "root"; - }; - script = '' - ls -lad /sys/bus/i2c/devices/i2c-*:* /sys/bus/i2c/drivers/i2c_hid_acpi/i2c-*:* - if [ -e /sys/bus/i2c/devices/i2c-FRMW0001:00 -a ! -e /sys/bus/i2c/drivers/i2c_hid_acpi/i2c-FRMW0001:00 ]; then - echo fixing - echo i2c-FRMW0001:00 > /sys/bus/i2c/drivers/i2c_hid_acpi/bind - ls -lad /sys/bus/i2c/devices/i2c-*:* /sys/bus/i2c/drivers/i2c_hid_acpi/i2c-*:* - echo done - else - echo no fix needed - fi - ''; - }; - - # Alder Lake CPUs benefit from kernel 5.18 for ThreadDirector - # https://www.tomshardware.com/news/intel-thread-director-coming-to-linux-5-18 - boot.kernelPackages = lib.mkIf (lib.versionOlder pkgs.linux.version "5.18") (lib.mkDefault pkgs.linuxPackages_latest); - } diff --git a/framework/13-inch/common/intel.nix b/framework/13-inch/common/intel.nix index fb5c4ce..96bbec9 100644 --- a/framework/13-inch/common/intel.nix +++ b/framework/13-inch/common/intel.nix @@ -1,15 +1,17 @@ -{ lib, pkgs, ... }: { +{ config, lib, pkgs, ... }: { imports = [ ../../../common/cpu/intel ]; - boot.kernelParams = [ - # Fixes a regression in s2idle, making it more power efficient than deep sleep - "acpi_osi=\"!Windows 2020\"" + boot.kernelParams = [ # For Power consumption # https://community.frame.work/t/linux-battery-life-tuning/6665/156 "nvme.noacpi=1" - ]; + ] + # Fixes a regression in s2idle, making it more power efficient than deep sleep + # Update 04/2024: It appears that s2idle-regression got fixed in newer kernel-versions (SebTM) + # (see: https://github.com/NixOS/nixos-hardware/pull/903#discussion_r1556096657) + ++ lib.lists.optional (lib.versionOlder config.boot.kernelPackages.kernel.version "6.8") "acpi_osi=\"!Windows 2020\""; # Requires at least 5.16 for working wi-fi and bluetooth. # https://community.frame.work/t/using-the-ax210-with-linux-on-the-framework-laptop/1844/89