diff --git a/README.md b/README.md index 207f4ca..4f00d86 100644 --- a/README.md +++ b/README.md @@ -82,6 +82,7 @@ See code for all available configurations. | [Apple MacBook Pro 14,1](apple/macbook-pro/14-1) | `` | | [Apple MacMini (2010, Intel, Nvidia)](apple/macmini/4) | `` | | [Apple Macs with a T2 Chip](apple/t2) | `` | +| [Asus Pro WS X570-ACE](asus/pro-ws-x570-ace) | `` | | [Asus ROG Ally RC71L (2023)](asus/ally/rc71l) | `` | | [Asus ROG Strix G513IM](asus/rog-strix/g513im) | `` | | [Asus ROG Strix G733QS](asus/rog-strix/g733qs) | `` | diff --git a/apple/t2/default.nix b/apple/t2/default.nix index 33658d6..abe9cac 100644 --- a/apple/t2/default.nix +++ b/apple/t2/default.nix @@ -24,6 +24,8 @@ let pipewirePackage = overrideAudioFiles pkgs.pipewire "spa/plugins/"; + tiny-dfrPackage = pkgs.callPackage ./pkgs/tiny-dfr.nix { }; + apple-set-os-loader-installer = pkgs.stdenv.mkDerivation { name = "apple-set-os-loader-installer-1.0"; src = pkgs.fetchFromGitHub { @@ -60,9 +62,10 @@ in boot.kernelPackages = pkgs.linuxPackagesFor (pkgs.callPackage ./pkgs/linux-t2.nix { }); boot.initrd.kernelModules = [ "apple-bce" ]; + services.udev.packages = [ audioFilesUdevRules tiny-dfrPackage ]; + # For audio boot.kernelParams = [ "pcie_ports=compat" "intel_iommu=on" "iommu=pt" ]; - services.udev.packages = [ audioFilesUdevRules ]; hardware.pulseaudio.package = overrideAudioFiles pkgs.pulseaudio "src/modules/"; @@ -71,18 +74,25 @@ in pipewire = pipewirePackage; }; + # For tiny-dfr + systemd.services.tiny-dfr = { + enable = true; + description = "Tiny Apple silicon touch bar daemon"; + after = [ "systemd-user-sessions.service" "getty@tty1.service" "plymouth-quit.service" "systemd-logind.service" ]; + bindsTo = [ "dev-tiny_dfr_display.device" "dev-tiny_dfr_backlight.device" ]; + startLimitIntervalSec = 30; + startLimitBurst = 2; + script = "${tiny-dfrPackage}/bin/tiny-dfr"; + restartTriggers = [ tiny-dfrPackage ]; + }; + + environment.etc."tiny-dfr/config.toml" = { + source = "${tiny-dfrPackage}/share/tiny-dfr/config.toml"; + }; + # Make sure post-resume.service exists powerManagement.enable = true; - systemd.services.fix-keyboard-backlight-and-touchbar = { - path = [ pkgs.kmod ]; - serviceConfig.ExecStart = ''${pkgs.systemd}/bin/systemd-inhibit --what=sleep --why="fixing keyboard backlight and touchbar must finish before sleep" --mode=delay ${./fix-keyboard-backlight-and-touchbar.sh}''; - serviceConfig.Type = "oneshot"; - description = "reload touchbar driver and restart upower"; - wantedBy = [ "display-manager.service" "post-resume.target" ]; - after = [ "post-resume.target" ]; - }; - # Activation script to install apple-set-os-loader in order to unlock the iGPU system.activationScripts.appleSetOsLoader = lib.optionalString t2Cfg.enableAppleSetOsLoader '' if [[ -e /boot/efi/efi/boot/bootx64_original.efi ]]; then diff --git a/apple/t2/fix-keyboard-backlight-and-touchbar.sh b/apple/t2/fix-keyboard-backlight-and-touchbar.sh deleted file mode 100755 index c8c6a09..0000000 --- a/apple/t2/fix-keyboard-backlight-and-touchbar.sh +++ /dev/null @@ -1,28 +0,0 @@ -#!/bin/sh - -set -eux - -unload () { - if modprobe -r "$1" 2>&1; - then echo ok - else echo fail - fi -} - -wait_unload() { - while sleep 1; do - output="$(unload "$1")" - case "$output" in - *is\ in\ use*) :;; - *ok*) return 0;; - *) echo "modprobe said: $output"; echo giving up; return 1; - esac - done -} - -wait_unload apple_touchbar -modprobe apple_touchbar - -# After suspend, the inode for the backlight device has changed. This service -# simply restarts upower to inform it of that change. -systemctl restart upower.service diff --git a/apple/t2/pkgs/linux-t2.nix b/apple/t2/pkgs/linux-t2.nix index 40371fe..1838fb9 100644 --- a/apple/t2/pkgs/linux-t2.nix +++ b/apple/t2/pkgs/linux-t2.nix @@ -5,11 +5,11 @@ let patchRepo = fetchFromGitHub { owner = "t2linux"; repo = "linux-t2-patches"; - rev = "46dd873d1d9d12b26916790045008a91a95d0c11"; - hash = "sha256-YGUGuzsAJFtZYjIW9d2XU4eGKNvMKCaWXqgqJn5TdeY="; + rev = "7cd298e227e95bac9a704ffc8f5ff5e89a1bf4d7"; + hash = "sha256-Oi3CwQl0IwdVc9w+pbmJjBnyqwLFhbqFwxs5o0mqtbE="; }; - version = "6.5"; + version = "6.7.7"; majorVersion = with lib; (elemAt (take 1 (splitVersion version)) 0); in buildLinux (args // { @@ -22,7 +22,7 @@ buildLinux (args // { src = runCommand "patched-source" {} '' cp -r ${fetchzip { url = "mirror://kernel/linux/kernel/v${majorVersion}.x/linux-${version}.tar.xz"; - hash = "sha256-qJmVSju69WcvDIbgrbtMyCi+OXUNTzNX2G+/0zwsPR4="; + hash = "sha256-j+Ufl6C1Mqjthk18GPt2e7j+i7viauOgNnVy9dJSgaM="; }} $out chmod -R u+w $out cd $out @@ -40,10 +40,11 @@ buildLinux (args // { BT_HCIBCM4377 = module; BT_HCIUART_BCM = yes; BT_HCIUART = module; - HID_APPLE_IBRIDGE = module; + HID_APPLETB_BL = module; + HID_APPLETB_KBD = module; HID_APPLE = module; + DRM_APPLETBDRM = module; HID_APPLE_MAGIC_BACKLIGHT = module; - HID_APPLE_TOUCHBAR = module; HID_SENSOR_ALS = module; SND_PCM = module; STAGING = yes; diff --git a/apple/t2/pkgs/tiny-dfr.nix b/apple/t2/pkgs/tiny-dfr.nix new file mode 100644 index 0000000..ce4be0f --- /dev/null +++ b/apple/t2/pkgs/tiny-dfr.nix @@ -0,0 +1,51 @@ +{ pkgs, fetchFromGitHub, rustPlatform, ... }: + +let + repo = fetchFromGitHub { + owner = "kekrby"; + repo = "tiny-dfr"; + rev = "8a5d413cb1dbe2a25b77a9e7f3cb5b9c88ef3ffb"; + hash = "sha256-l4D7aePz/CYpkRorrvsgIYrvSzoZl59OGcFGJqqJftk="; + }; + +in +rustPlatform.buildRustPackage rec { + pname = "tiny-dfr"; + version = repo.rev; + + src = repo; + + cargoLock.lockFile = "${src}/Cargo.lock"; + + nativeBuildInputs = with pkgs; [ + pkg-config + ]; + + buildInputs = with pkgs; [ + udev + glib + pango + cairo + gdk-pixbuf + libxml2 + libinput + ]; + + postPatch = '' + substituteInPlace src/main.rs --replace "/usr/share/tiny-dfr/" "$out/share/tiny-dfr/" + ''; + + postInstall = '' + mkdir -p $out/etc $out/share + + cp -r etc/udev $out/etc/ + cp -r share/tiny-dfr $out/share/ + ''; + + meta = with pkgs.lib; { + description = "The most basic dynamic function row daemon possible"; + homepage = "https://github.com/kekrby/tiny-dfr"; + license = with licenses; [ asl20 bsd3 cc0 isc lgpl21Plus mit mpl20 unicode-dfs-2016 asl20 asl20-llvm mit unlicense ]; + maintainers = []; + }; +} diff --git a/asus/pro-ws-x570-ace/README.wiki b/asus/pro-ws-x570-ace/README.wiki new file mode 100644 index 0000000..33ecf52 --- /dev/null +++ b/asus/pro-ws-x570-ace/README.wiki @@ -0,0 +1,29 @@ += ASUS Pro WS X570-ACE = + +== Firmware issues == + +=== BIOS === + +BIOS version 4805 (and possibly older) has broken X2APIC mode, which in turn breaks amd-pstate support. +Other possible config values for APIC are Compatibility, Auto and XAPIC; best results were observed with XAPIC. + +This is the error in dmesg when X2APIC is enabled: + + +amd_pstate: the _CPC object is not present in SBIOS or ACPI disabled + + +=== IPMI === + +The IPMI is half-baked and for the most part unusable in a pure Linux environment, see https://forum.level1techs.com/t/remote-management-on-the-asus-pro-ws-x570-ace-under-linux + +== Firmware features == + +=== IOMMU === + +The groups are great, it's a good board for VFIO. + +=== ECC Memory === + +As stated on the product page, it works; explicitly enabling in BIOS might be required. +Tested with M391A2K43BB1-CTD. diff --git a/asus/pro-ws-x570-ace/default.nix b/asus/pro-ws-x570-ace/default.nix new file mode 100644 index 0000000..0fcde58 --- /dev/null +++ b/asus/pro-ws-x570-ace/default.nix @@ -0,0 +1,19 @@ +{ + imports = [ + ../../common/pc + ../../common/pc/ssd + ../../common/cpu/amd/pstate.nix + ]; + + boot.kernelModules = [ + # Nuvoton NCT6798D - temperature, voltage and RPM + "nct6775" + + # a single "temp1" sensor, always at "+31.9°C" + # commented because it's not useful, but left here for reference + # Bus `SMBus PIIX4 adapter port 1 at 0b20' + # Busdriver `i2c_piix4', I2C address 0x4f + # Chip `ds75' + # "lm75" + ]; +} 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 + ]; + } ]; } diff --git a/flake.nix b/flake.nix index cabdabc..d68cdc0 100644 --- a/flake.nix +++ b/flake.nix @@ -19,6 +19,7 @@ asus-ally-rc71l = import ./asus/ally/rc71l; asus-fx504gd = import ./asus/fx504gd; asus-fa507rm = import ./asus/fa507rm; + asus-pro-ws-x570-ace = import ./asus/pro-ws-x570-ace; asus-rog-strix-g513im = import ./asus/rog-strix/g513im; asus-rog-strix-g733qs = import ./asus/rog-strix/g733qs; asus-zephyrus-ga401 = import ./asus/zephyrus/ga401; 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/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/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 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" ]; + }; +} diff --git a/starfive/visionfive/v2/uboot.nix b/starfive/visionfive/v2/uboot.nix index 9c0eb7a..ef92cce 100644 --- a/starfive/visionfive/v2/uboot.nix +++ b/starfive/visionfive/v2/uboot.nix @@ -1,29 +1,9 @@ -{ lib -, fetchFromGitHub -, buildUBoot -, buildPackages +{ buildUBoot , opensbi }: -buildUBoot rec { - version = "2024.01"; - - src = fetchFromGitHub { - owner = "u-boot"; - repo = "u-boot"; - rev = "refs/tags/v${version}"; - hash = "sha256-0Da7Czy9cpQ+D5EICc3/QSZhAdCBsmeMvBgykYhAQFw="; - }; - - # workaround for https://github.com/NixOS/nixpkgs/pull/146634 - # uboot: only apply raspberry pi patches to raspberry pi builds - patches = [ ]; - +buildUBoot { extraMakeFlags = [ - # workaround for https://github.com/NixOS/nixpkgs/pull/277997 - # buildUBoot: specify absolute path of dtc, fix building u-boot 2023.10+ - "DTC=${lib.getExe buildPackages.dtc}" - "OPENSBI=${opensbi}/share/opensbi/lp64/generic/firmware/fw_dynamic.bin" ];