diff --git a/CODEOWNERS b/CODEOWNERS index f0a1b5a4..6ccf8247 100644 --- a/CODEOWNERS +++ b/CODEOWNERS @@ -8,6 +8,7 @@ pcengines/apu @yegortimoshenko pine64/rockpro64 @tomfitzhenry pine64/star64 @fgaz purism/librem/13v3 @yegortimoshenko +raspberry-pi @doronbehar system76/darp6 @khumba framework @emiller88 @johnazoidberg tuxedo/pulse/15/gen2 @trueNAHO diff --git a/README.md b/README.md index d4896266..ab42a62e 100644 --- a/README.md +++ b/README.md @@ -233,6 +233,7 @@ See code for all available configurations. | [Gigabyte B550](gigabyte/b550) | `` | `gigabyte-b550` | | [Gigabyte B650](gigabyte/b650) | `` | `gigabyte-b650` | | [GMKtec NucBox G3 Plus](gmktec/nucbox/g3-plus) | `` | `gmktec-nucbox-g3-plus` | +| [GPD Duo](gpd/duo) | `` | `gpd-duo` | | [GPD MicroPC](gpd/micropc) | `` | `gpd-micropc` | | [GPD P2 Max](gpd/p2-max) | `` | `gpd-p2-max` | | [GPD Pocket 3](gpd/pocket-3) | `` | `gpd-pocket-3` | @@ -307,6 +308,8 @@ See code for all available configurations. | [Lenovo ThinkPad L14 (Intel)](lenovo/thinkpad/l14/intel) | `` | `lenovo-thinkpad-l14-intel` | | [Lenovo ThinkPad L480](lenovo/thinkpad/l480) | `` | `lenovo-thinkpad-l480` | | [Lenovo ThinkPad P1 Gen 3](lenovo/thinkpad/p1/3th-gen) | `` | `lenovo-thinkpad-p1-gen3` | +| [Lenovo ThinkPad P1 Gen 5](lenovo/thinkpad/p1/gen5) | `` | `lenovo-thinkpad-p1-gen5` | +| [Lenovo ThinkPad P1 Gen 5 (Nvidia)](lenovo/thinkpad/p1/gen5/nvidia) | `` | `lenovo-thinkpad-p1-gen5-nvidia` | | [Lenovo ThinkPad P14s AMD Gen 1](lenovo/thinkpad/p14s/amd/gen1) | `` | `lenovo-thinkpad-p14s-amd-gen1` | | [Lenovo ThinkPad P14s AMD Gen 2](lenovo/thinkpad/p14s/amd/gen2) | `` | `lenovo-thinkpad-p14s-amd-gen2` | | [Lenovo ThinkPad P14s AMD Gen 3](lenovo/thinkpad/p14s/amd/gen3) | `` | `lenovo-thinkpad-p14s-amd-gen3` | diff --git a/apple/t2/pkgs/brcm-firmware/default.nix b/apple/t2/pkgs/brcm-firmware/default.nix index 742d6ff6..e444e4f6 100644 --- a/apple/t2/pkgs/brcm-firmware/default.nix +++ b/apple/t2/pkgs/brcm-firmware/default.nix @@ -2,10 +2,7 @@ lib, stdenvNoCC, callPackage, - vmTools, - util-linux, - linux, - kmod, + _7zz, version, }: @@ -38,52 +35,44 @@ let }; in -vmTools.runInLinuxVM ( - stdenvNoCC.mkDerivation { - pname = "brcm-firmware"; - inherit version; +stdenvNoCC.mkDerivation { + pname = "brcm-firmware"; + inherit version; - src = fetchmacos { - name = version; - inherit (boards.${version}) - boardId - mlb - osType - hash - ; - }; - dontUnpack = true; + src = fetchmacos { + name = version; + inherit (boards.${version}) + boardId + mlb + osType + hash + ; + }; + dontUnpack = true; - nativeBuildInputs = [ - util-linux - get-firmware - ]; - buildPhase = '' - ln -s ${linux}/lib /lib - ${kmod}/bin/modprobe loop - ${kmod}/bin/modprobe hfsplus + nativeBuildInputs = [ + _7zz + get-firmware + ]; + buildPhase = '' + 7zz x -bd -bso0 -bsp0 $src \ + "macOS Base System/usr/share/firmware/bluetooth/*" \ + "macOS Base System/usr/share/firmware/wifi/*" - imgdir=$(mktemp -d) - loopdev=$(losetup -f | cut -d "/" -f 3) - losetup -P $loopdev $src - loopdev_partition=/dev/$(lsblk -o KNAME,TYPE,MOUNTPOINT -n | grep $loopdev | tail -1 | awk '{print $1}') - mount $loopdev_partition $imgdir + get-bluetooth "macOS Base System/usr/share/firmware/bluetooth" bluetooth/ + get-wifi "macOS Base System/usr/share/firmware/wifi" wifi/ + ''; - get-bluetooth $imgdir/usr/share/firmware/bluetooth bluetooth/ - get-wifi $imgdir/usr/share/firmware/wifi wifi/ - ''; + installPhase = '' + mkdir -p $out/lib/firmware/brcm + cp bluetooth/brcm/* $out/lib/firmware/brcm/ + cp wifi/brcm/* $out/lib/firmware/brcm/ + ''; - installPhase = '' - mkdir -p $out/lib/firmware/brcm - cp bluetooth/brcm/* $out/lib/firmware/brcm/ - cp wifi/brcm/* $out/lib/firmware/brcm/ - ''; - - meta = with lib; { - description = "Wi-Fi and Bluetooth firmware for T2 Macs"; - license = licenses.unfree; - maintainers = with maintainers; [ mkorje ]; - platforms = platforms.linux; - }; - } -) + meta = with lib; { + description = "Wi-Fi and Bluetooth firmware for T2 Macs"; + license = licenses.unfree; + maintainers = with maintainers; [ mkorje ]; + platforms = platforms.linux; + }; +} diff --git a/common/gpu/amd/dc-debug-mask.nix b/common/gpu/amd/dc-debug-mask.nix new file mode 100644 index 00000000..5c73dfc7 --- /dev/null +++ b/common/gpu/amd/dc-debug-mask.nix @@ -0,0 +1,36 @@ +# Flag values from drivers/gpu/drm/amd/include/amd_shared.h +{ config, lib, ... }: +let + flags = { + disablePipeSplit = 1; + disableStutter = 2; + disableDsc = 4; + disableClockGating = 8; + disablePsr = 16; + disableMpo = 64; + disablePsrSu = 512; + disableReplay = 1024; + disableIps = 2048; + }; + + cfg = config.hardware.amdgpu.dcDebugMask; + + mask = lib.foldlAttrs ( + acc: name: bit: + if cfg.${name} then lib.bitOr acc bit else acc + ) 0 flags; +in +{ + options.hardware.amdgpu.dcDebugMask = lib.mapAttrs ( + _name: bit: + lib.mkOption { + type = lib.types.bool; + default = false; + description = "Set flag 0x${lib.toHexString bit} in amdgpu.dcdebugmask."; + } + ) flags; + + config = lib.mkIf (mask != 0) { + boot.kernelParams = [ "amdgpu.dcdebugmask=0x${lib.toHexString mask}" ]; + }; +} diff --git a/common/gpu/amd/default.nix b/common/gpu/amd/default.nix index f6903d9e..5bb4546e 100644 --- a/common/gpu/amd/default.nix +++ b/common/gpu/amd/default.nix @@ -1,6 +1,8 @@ { lib, ... }: { + imports = [ ./dc-debug-mask.nix ]; + config = { services.xserver.videoDrivers = lib.mkDefault [ "modesetting" ]; diff --git a/flake.lock b/flake.lock index 67a1708d..1187da68 100644 --- a/flake.lock +++ b/flake.lock @@ -2,11 +2,11 @@ "nodes": { "nixpkgs": { "locked": { - "lastModified": 1767892417, - "narHash": "sha256-8bW3q88CEg2u4hSP66Vf4lpbLonHz7hqDNBMcCY7E9U=", - "rev": "3497aa5c9457a9d88d71fa93a4a8368816fbeeba", + "lastModified": 1789546076, + "narHash": "sha256-vWkSk5bbfTqdtMoSgD9FshACO8JCvXTFi+3cqEp0mH0=", + "rev": "b1b875982b17dabde9b4a37f3e229e74913e6db3", "type": "tarball", - "url": "https://releases.nixos.org/nixos/unstable/nixos-26.05pre924538.3497aa5c9457/nixexprs.tar.xz" + "url": "https://releases.nixos.org/nixos/unstable/nixos-26.11pre1074753.b1b875982b17/nixexprs.tar.xz" }, "original": { "type": "tarball", diff --git a/flake.nix b/flake.nix index e0b52f61..e3abf465 100644 --- a/flake.nix +++ b/flake.nix @@ -195,6 +195,7 @@ google-pixelbook = import ./google/pixelbook; google-brya = import ./google/brya; google-rex = import ./google/rex; + gpd-duo = import ./gpd/duo; gpd-micropc = import ./gpd/micropc; gpd-p2-max = import ./gpd/p2-max; gpd-pocket-3 = import ./gpd/pocket-3; @@ -266,6 +267,8 @@ lenovo-thinkpad-l480 = import ./lenovo/thinkpad/l480; lenovo-thinkpad-p1 = import ./lenovo/thinkpad/p1; lenovo-thinkpad-p1-gen3 = import ./lenovo/thinkpad/p1/3th-gen; + lenovo-thinkpad-p1-gen5 = import ./lenovo/thinkpad/p1/gen5; + lenovo-thinkpad-p1-gen5-nvidia = import ./lenovo/thinkpad/p1/gen5/nvidia; lenovo-thinkpad-p14s-amd-gen1 = import ./lenovo/thinkpad/p14s/amd/gen1; lenovo-thinkpad-p14s-amd-gen2 = import ./lenovo/thinkpad/p14s/amd/gen2; lenovo-thinkpad-p14s-amd-gen3 = import ./lenovo/thinkpad/p14s/amd/gen3; diff --git a/framework/13-inch/common/amd.nix b/framework/13-inch/common/amd.nix index 4a89f8da..fc34d3dc 100644 --- a/framework/13-inch/common/amd.nix +++ b/framework/13-inch/common/amd.nix @@ -6,18 +6,18 @@ ../../../common/gpu/amd ]; - boot.kernelParams = [ - # There seems to be an issue with panel self-refresh (PSR) that - # causes hangs for users. - # - # https://community.frame.work/t/fedora-kde-becomes-suddenly-slow/58459 - # https://gitlab.freedesktop.org/drm/amd/-/issues/3647 - "amdgpu.dcdebugmask=0x10" - ] - # Workaround for SuspendThenHibernate: https://lore.kernel.org/linux-kernel/20231106162310.85711-1-mario.limonciello@amd.com/ - ++ lib.optionals (lib.versionOlder config.boot.kernelPackages.kernel.version "6.8") [ - "rtc_cmos.use_acpi_alarm=1" - ]; + # There seems to be an issue with panel self-refresh (PSR) that + # causes hangs for users. + # + # https://community.frame.work/t/fedora-kde-becomes-suddenly-slow/58459 + # https://gitlab.freedesktop.org/drm/amd/-/issues/3647 + hardware.amdgpu.dcDebugMask.disablePsr = lib.mkDefault true; + + boot.kernelParams = + # Workaround for SuspendThenHibernate: https://lore.kernel.org/linux-kernel/20231106162310.85711-1-mario.limonciello@amd.com/ + lib.optionals (lib.versionOlder config.boot.kernelPackages.kernel.version "6.8") [ + "rtc_cmos.use_acpi_alarm=1" + ]; # AMD has better battery life with PPD over TLP: # https://community.frame.work/t/responded-amd-7040-sleep-states/38101/13 diff --git a/framework/13-inch/common/classic-audio.nix b/framework/13-inch/common/classic-audio.nix index db60c52b..e0d41bdc 100644 --- a/framework/13-inch/common/classic-audio.nix +++ b/framework/13-inch/common/classic-audio.nix @@ -315,12 +315,11 @@ in "device.api" = "dsp"; "node.virtual" = "false"; - # Lower seems to mean "more preferred", - # bluetooth devices seem to be ~1000, speakers seem to be ~2000 - # since this is between the two, bluetooth devices take over when they connect, - # and hand over to this instead of the speakers when they disconnect. - "priority.session" = 1500; - "priority.driver" = 1500; + # 1009 is the default priority of the "first" analog audio device. + # Higher priorities (e.g., 1010 for bluetooth and 1100 for usb audio) + # are preferred. + "priority.session" = 1009; + "priority.driver" = 1009; "state.default-volume" = 0.343; "device.icon-name" = "audio-card-analog-pci"; }; diff --git a/framework/16-inch/amd-ai-300-series/default.nix b/framework/16-inch/amd-ai-300-series/default.nix index 1e42fff1..c4d4e911 100644 --- a/framework/16-inch/amd-ai-300-series/default.nix +++ b/framework/16-inch/amd-ai-300-series/default.nix @@ -21,8 +21,9 @@ # The following mitigations fix various graphics issues # See https://gist.github.com/lbrame/f9034b1a9fe4fc2d2835c5542acb170a#user-content-quick-version-apply-the-mitigations-i-am-personally-using + hardware.amdgpu.dcDebugMask.disableReplay = lib.mkDefault true; + boot.kernelParams = [ - "amdgpu.dcdebugmask=0x410" "amdgpu.sg_display=0" "amdgpu.abmlevel=0" ]; diff --git a/framework/16-inch/common/amd.nix b/framework/16-inch/common/amd.nix index 4a89f8da..fc34d3dc 100644 --- a/framework/16-inch/common/amd.nix +++ b/framework/16-inch/common/amd.nix @@ -6,18 +6,18 @@ ../../../common/gpu/amd ]; - boot.kernelParams = [ - # There seems to be an issue with panel self-refresh (PSR) that - # causes hangs for users. - # - # https://community.frame.work/t/fedora-kde-becomes-suddenly-slow/58459 - # https://gitlab.freedesktop.org/drm/amd/-/issues/3647 - "amdgpu.dcdebugmask=0x10" - ] - # Workaround for SuspendThenHibernate: https://lore.kernel.org/linux-kernel/20231106162310.85711-1-mario.limonciello@amd.com/ - ++ lib.optionals (lib.versionOlder config.boot.kernelPackages.kernel.version "6.8") [ - "rtc_cmos.use_acpi_alarm=1" - ]; + # There seems to be an issue with panel self-refresh (PSR) that + # causes hangs for users. + # + # https://community.frame.work/t/fedora-kde-becomes-suddenly-slow/58459 + # https://gitlab.freedesktop.org/drm/amd/-/issues/3647 + hardware.amdgpu.dcDebugMask.disablePsr = lib.mkDefault true; + + boot.kernelParams = + # Workaround for SuspendThenHibernate: https://lore.kernel.org/linux-kernel/20231106162310.85711-1-mario.limonciello@amd.com/ + lib.optionals (lib.versionOlder config.boot.kernelPackages.kernel.version "6.8") [ + "rtc_cmos.use_acpi_alarm=1" + ]; # AMD has better battery life with PPD over TLP: # https://community.frame.work/t/responded-amd-7040-sleep-states/38101/13 diff --git a/gpd/duo/default.nix b/gpd/duo/default.nix new file mode 100644 index 00000000..a7d8cb75 --- /dev/null +++ b/gpd/duo/default.nix @@ -0,0 +1,60 @@ +{ + config, + lib, + pkgs, + ... +}: + +let + cfg = config.hardware.gpd.duo; +in +with lib; +{ + imports = [ + ./duo-specific + ../../common/pc/laptop + ../../common/pc/ssd + ../../common/hidpi.nix + ]; + + options = { + hardware.gpd.duo.preventWakeOnAC = mkOption { + type = types.bool; + default = false; + description = '' + Stop the system waking from suspend when the AC is plugged + in. The catch: it also disables waking from the keyboard. + + See: + https://community.frame.work/t/tracking-framework-amd-ryzen-7040-series-lid-wakeup-behavior-feedback/39128/45 + ''; + }; + }; + + config = { + # Workaround applied upstream in Linux >=6.7 (on BIOS 03.03) + # https://github.com/torvalds/linux/commit/a55bdad5dfd1efd4ed9ffe518897a21ca8e4e193 + services.udev.extraRules = + mkIf (versionOlder config.boot.kernelPackages.kernel.version "6.7" && cfg.preventWakeOnAC) + '' + # Prevent wake when plugging in AC during suspend. Trade-off: keyboard wake disabled. See: + # https://community.frame.work/t/tracking-framework-amd-ryzen-7040-series-lid-wakeup-behavior-feedback/39128/45 + ACTION=="add", SUBSYSTEM=="serio", DRIVERS=="atkbd", ATTR{power/wakeup}="disabled" + ''; + + # Replace 'left' with 'right' or 'inverted' as needed + # Fixes DUO stupid inverted display at boot + # Enable kernel module for your graphics (adjust if needed) + boot.kernelModules = [ "amdgpu" ]; + + # Set the eDP-1 panel video parameters for display rotation + boot.kernelParams = mkBefore [ + "video=eDP-1:2880x1800,panel_orientation=upside_down" + "video=DP-3:2880x1800,panel_orientation=normal" + "i2c_touchscreen_props=GXTP7380:touchscreen-inverted-x:touchscreen-inverted-y" + ]; + + hardware.gpd.duo.audioEnhancement.rawDeviceName = + mkDefault "alsa_output.pci-0000_c1_00.6.analog-stereo"; + }; +} diff --git a/gpd/duo/duo-specific/amd.nix b/gpd/duo/duo-specific/amd.nix new file mode 100644 index 00000000..c2f36a60 --- /dev/null +++ b/gpd/duo/duo-specific/amd.nix @@ -0,0 +1,27 @@ +{ lib, config, ... }: +with lib; +{ + imports = [ + ../../../common/cpu/amd + ../../../common/cpu/amd/pstate.nix + ../../../common/gpu/amd + ]; + + boot.kernelParams = [ + # There seems to be an issue with panel self-refresh (PSR) that + # causes hangs for users. + # + # https://community.frame.work/t/fedora-kde-becomes-suddenly-slow/58459 + # https://gitlab.freedesktop.org/drm/amd/-/issues/3647 + "amdgpu.dcdebugmask=0x210" + ] + # Workaround for SuspendThenHibernate: https://lore.kernel.org/linux-kernel/20231106162310.85711-1-mario.limonciello@amd.com/ + ++ optionals (versionOlder config.boot.kernelPackages.kernel.version "6.8") [ + "rtc_cmos.use_acpi_alarm=1" + ]; + + # AMD has better battery life with PPD over TLP: + # https://community.frame.work/t/responded-amd-7040-sleep-states/38101/13 + services.power-profiles-daemon.enable = mkDefault true; + services.tlp.enable = mkDefault false; +} diff --git a/gpd/duo/duo-specific/audio.nix b/gpd/duo/duo-specific/audio.nix new file mode 100644 index 00000000..d384c273 --- /dev/null +++ b/gpd/duo/duo-specific/audio.nix @@ -0,0 +1,391 @@ +{ + config, + lib, + pkgs, + ... +}: +let + cfg = config.hardware.gpd.duo.audioEnhancement; +in +with lib; +{ + options = { + hardware.gpd.duo.audioEnhancement = { + enable = mkOption { + type = types.bool; + default = false; + description = '' + Create a new audio device called "DUO Speakers", + which applies sound tuning before sending the audio out to the speakers. + This option requires PipeWire and WirePlumber. + + The filter chain includes the following: + - Pyschoacoustic bass enhancement + - Loudness compensation + - Equalizer + - Slight compression + + This option has been optimised for the Framework Laptop 13 AMD 7040 series, but should work on all models. + + Before applying, ensure the speakers are set to 100%, + because the volumes compound and the raw speaker device will be hidden by default. + + You might also need to re-select the default output device. + + In some cases, the added bass will vibrate the keyboard cable leading to a rattling sound, + a piece of foam can be used to mitigate this. + ''; + }; + + hideRawDevice = mkOption { + type = types.bool; + default = true; + description = '' + Hide the raw speaker device. + This option is enabled by default, because keeping the raw speaker device can lead to volume conflicts. + ''; + }; + + rawDeviceName = mkOption { + type = types.str; + example = "alsa_output.pci-0000_c1_00.6.analog-stereo"; + description = '' + The name of the raw speaker device. This will vary by device. + You can get this by running `pw-dump | grep -C 20 pci-0000`. + ''; + }; + }; + }; + + config = mkIf cfg.enable ( + let + outputName = cfg.rawDeviceName; + prettyName = "Duo Speakers"; + + # These are pre-made decibel to linear value conversions, since Nix doesn't have pow(). + # Use the formula `10 ** (db / 20)` to calculate. + db = { + "-18.1" = 0.1244514611771385; + "-5.48" = 0.5321082592667942; + "-4.76" = 0.5780960474057181; + "8.1" = 2.5409727055493048; + "-36" = 1.5848931924611134e-2; + }; + + json = pkgs.formats.json { }; + + # The filter chain, heavily inspired by the asahi-audio project: https://github.com/AsahiLinux/asahi-audio + filter-chain = json.generate "filter-chain.json" { + "node.description" = prettyName; + "media.name" = prettyName; + "filter.graph" = { + nodes = [ + # Psychoacoustic bass extension, + # it creates harmonics of the missing bass to fool our ears into hearing it. + { + type = "lv2"; + plugin = "https://chadmed.au/bankstown"; + name = "bassex"; + control = { + bypass = 0; + amt = 1.2; + sat_second = 1.3; + sat_third = 2.5; + blend = 1.0; + ceil = 200.0; + floor = 20.0; + }; + } + # Loudness compensation, + # it ensures that the sound profile stays consistent across different volumes. + { + type = "lv2"; + plugin = "http://lsp-plug.in/plugins/lv2/loud_comp_stereo"; + name = "el"; + control = { + enabled = 1; + input = 1.0; + fft = 4; + }; + } + # 8-band equalizer, + # it tries to lessen frequencies where the laptop might resonate, + # and tries to make the frequency curve more pleasing; + # this is the "Lappy McTopface" profile (https://github.com/ceiphr/ee-framework-presets) + # further tuned for the Framework Laptop 13 AMD 7040 series + # and might need some tuning on other models. + { + type = "lv2"; + plugin = "http://lsp-plug.in/plugins/lv2/para_equalizer_x8_lr"; + name = "fw13eq"; + control = { + mode = 0; + react = 0.2; + zoom = db."-36"; + + fl_0 = 101.0; + fml_0 = 0; + ftl_0 = 5; + gl_0 = db."-18.1"; + huel_0 = 0.0; + ql_0 = 4.36; + sl_0 = 0; + wl_0 = 4.0; + + fl_1 = 451.0; + fml_1 = 0; + ftl_1 = 1; + gl_1 = db."-5.48"; + huel_1 = 3.125e-2; + ql_1 = 2.46; + sl_1 = 0; + wl_1 = 4.0; + + fl_2 = 918.0; + fml_2 = 0; + ftl_2 = 1; + gl_2 = db."-4.76"; + huel_2 = 6.25e-2; + ql_2 = 2.44; + sl_2 = 0; + wl_2 = 4.0; + + fl_3 = 9700.0; + fml_3 = 0; + ftl_3 = 1; + gl_3 = db."8.1"; + huel_3 = 9.375e-2; + ql_3 = 2.0; + sl_3 = 0; + wl_3 = 4.0; + + fr_0 = 101.0; + fmr_0 = 0; + ftr_0 = 5; + gr_0 = db."-18.1"; + huer_0 = 0.0; + qr_0 = 4.36; + sr_0 = 0; + wr_0 = 4.0; + + fr_1 = 451.0; + fmr_1 = 0; + ftr_1 = 1; + gr_1 = db."-5.48"; + huer_1 = 3.125e-2; + qr_1 = 2.46; + sr_1 = 0; + wr_1 = 4.0; + + fr_2 = 918.0; + fmr_2 = 0; + ftr_2 = 1; + gr_2 = db."-4.76"; + huer_2 = 6.25e-2; + qr_2 = 2.44; + sr_2 = 0; + wr_2 = 4.0; + + fr_3 = 9700.0; + fmr_3 = 0; + ftr_3 = 1; + gr_3 = db."8.1"; + huer_3 = 9.375e-2; + qr_3 = 2.0; + sr_3 = 0; + wr_3 = 4.0; + }; + } + # Compressors. The settings were taken from the asahi-audio project. + { + type = "lv2"; + plugin = "http://lsp-plug.in/plugins/lv2/mb_compressor_stereo"; + name = "woofer_bp"; + control = { + mode = 0; + ce_0 = 1; + sla_0 = 5.0; + cr_0 = 1.75; + al_0 = 0.725; + at_0 = 1.0; + rt_0 = 100; + kn_0 = 0.125; + cbe_1 = 1; + sf_1 = 200.0; + ce_1 = 0; + cbe_2 = 0; + ce_2 = 0; + cbe_3 = 0; + ce_3 = 0; + cbe_4 = 0; + ce_4 = 0; + cbe_5 = 0; + ce_5 = 0; + cbe_6 = 0; + ce_6 = 0; + }; + } + { + type = "lv2"; + plugin = "http://lsp-plug.in/plugins/lv2/compressor_stereo"; + name = "woofer_lim"; + control = { + sla = 5.0; + al = 1.0; + at = 1.0; + rt = 100.0; + cr = 15.0; + kn = 0.5; + }; + } + ]; + + # Now, we're chaining together the modules instantiated above. + links = [ + { + output = "bassex:out_l"; + input = "el:in_l"; + } + { + output = "bassex:out_r"; + input = "el:in_r"; + } + + { + output = "el:out_l"; + input = "fw13eq:in_l"; + } + { + output = "el:out_r"; + input = "fw13eq:in_r"; + } + { + output = "fw13eq:out_l"; + input = "woofer_bp:in_l"; + } + { + output = "fw13eq:out_r"; + input = "woofer_bp:in_r"; + } + { + output = "woofer_bp:out_l"; + input = "woofer_lim:in_l"; + } + { + output = "woofer_bp:out_r"; + input = "woofer_lim:in_r"; + } + ]; + + inputs = [ + "bassex:in_l" + "bassex:in_r" + ]; + outputs = [ + "woofer_lim:out_l" + "woofer_lim:out_r" + ]; + + # This makes pipewire's volume control actually control the loudness comp module + "capture.volumes" = [ + { + control = "el:volume"; + min = -47.5; + max = 0.0; + scale = "cubic"; + } + ]; + }; + "capture.props" = { + "node.name" = "audio_effect.laptop-convolver"; + "media.class" = "Audio/Sink"; + "audio.channels" = "2"; + "audio.position" = [ + "FL" + "FR" + ]; + "audio.allowed-rates" = [ + 44100 + 48000 + 88200 + 96000 + 176400 + 192000 + ]; + "device.api" = "dsp"; + "node.virtual" = "false"; + + # Lower seems to mean "more preferred", + # bluetooth devices seem to be ~1000, speakers seem to be ~2000 + # since this is between the two, bluetooth devices take over when they connect, + # and hand over to this instead of the speakers when they disconnect. + "priority.session" = 1500; + "priority.driver" = 1500; + "state.default-volume" = 0.343; + "device.icon-name" = "audio-card-analog-pci"; + }; + "playback.props" = { + "node.name" = "audio_effect.laptop-convolver"; + "target.object" = outputName; + "node.passive" = "true"; + "audio.channels" = "2"; + "audio.allowed-rates" = [ + 44100 + 48000 + 88200 + 96000 + 176400 + 192000 + ]; + "audio.position" = [ + "FL" + "FR" + ]; + "device.icon-name" = "audio-card-analog-pci"; + }; + }; + + configPackage = + (pkgs.writeTextDir "share/wireplumber/wireplumber.conf.d/99-laptop.conf" '' + monitor.alsa.rules = [ + { + matches = [{ node.name = "${outputName}" }] + actions = { + update-props = { + audio.allowed-rates = [44100, 48000, 88200, 96000, 176400, 192000] + } + } + } + ] + + node.software-dsp.rules = [ + { + matches = [{ node.name = "${outputName}" }] + actions = { + create-filter = { + filter-path = "${filter-chain}" + hide-parent = ${boolToString cfg.hideRawDevice} + } + } + } + ] + + wireplumber.profiles = { + main = { node.software-dsp = "required" } + } + '') + // { + passthru.requiredLv2Packages = with pkgs; [ + lsp-plugins + bankstown-lv2 + ]; + }; + in + { + services.pipewire.wireplumber.configPackages = [ configPackage ]; + + # Pipewire is needed for this. + services.pipewire.enable = mkDefault true; + } + ); +} diff --git a/gpd/duo/duo-specific/bluetooth.nix b/gpd/duo/duo-specific/bluetooth.nix new file mode 100644 index 00000000..bdc530b9 --- /dev/null +++ b/gpd/duo/duo-specific/bluetooth.nix @@ -0,0 +1,56 @@ +# There is apparently a bug that affects Framework computers that causes black +# screen on resume from sleep or hibernate with kernel version 6.11. Framework +# have published a workaround; this applies that workaround. +# +# https://fosstodon.org/@frameworkcomputer/113406887743149089 +# https://github.com/FrameworkComputer/linux-docs/blob/main/hibernation/kernel-6-11-workarounds/suspend-hibernate-bluetooth-workaround.md#workaround-for-suspendhibernate-black-screen-on-resume-kernel-611 +{ + config, + lib, + pkgs, + ... + # TODO: drop this if linux 6.11 goes EOL +}: +with lib; +mkIf + ( + (config.boot.kernelPackages.kernelAtLeast "6.11") && (config.boot.kernelPackages.kernelOlder "6.12") + ) + { + systemd.services = { + bluetooth-rfkill-suspend = { + description = "Soft block Bluetooth on suspend/hibernate"; + before = [ "sleep.target" ]; + unitConfig.StopWhenUnneeded = true; + serviceConfig = { + Type = "oneshot"; + ExecStart = "${pkgs.util-linux}/bin/rfkill block bluetooth"; + ExecStartPost = "${pkgs.coreutils}/bin/sleep 3"; + RemainAfterExit = true; + }; + wantedBy = [ + "suspend.target" + "hibernate.target" + "suspend-then-hibernate.target" + ]; + }; + + bluetooth-rfkill-resume = { + description = "Unblock Bluetooth on resume"; + after = [ + "suspend.target" + "hibernate.target" + "suspend-then-hibernate.target" + ]; + serviceConfig = { + Type = "oneshot"; + ExecStart = "${pkgs.util-linux}/bin/rfkill unblock bluetooth"; + }; + wantedBy = [ + "suspend.target" + "hibernate.target" + "suspend-then-hibernate.target" + ]; + }; + }; + } diff --git a/gpd/duo/duo-specific/default.nix b/gpd/duo/duo-specific/default.nix new file mode 100644 index 00000000..2b5eaef3 --- /dev/null +++ b/gpd/duo/duo-specific/default.nix @@ -0,0 +1,20 @@ +{ lib, pkgs, ... }: +with lib; +{ + imports = [ + ../../../common/cpu/amd/raphael/igpu.nix + ./bluetooth.nix + ./amd.nix + ./audio.nix + ./power + ]; + + # Fix TRRS headphones missing a mic + # https://community.frame.work/t/headset-microphone-on-linux/12387/3 + boot.extraModprobeConfig = mkIf (versionOlder pkgs.linux.version "6.6.8") '' + options snd-hda-intel model=dell-headset-multi + ''; + + # Needed for desktop environments to detect/manage display brightness + hardware.sensor.iio.enable = mkDefault true; +} diff --git a/gpd/duo/duo-specific/power/default.nix b/gpd/duo/duo-specific/power/default.nix new file mode 100644 index 00000000..814ae900 --- /dev/null +++ b/gpd/duo/duo-specific/power/default.nix @@ -0,0 +1,6 @@ +{ + imports = [ + ../../../ppt.nix + ./power-saving.nix + ]; +} diff --git a/gpd/duo/duo-specific/power/power-saving.nix b/gpd/duo/duo-specific/power/power-saving.nix new file mode 100644 index 00000000..9c534040 --- /dev/null +++ b/gpd/duo/duo-specific/power/power-saving.nix @@ -0,0 +1,18 @@ +{ lib, config, ... }: +with lib; +let + cfg = config.hardware.gpd.duo.powerManagement; +in +{ + options.hardware.gpd.duo.powerManagement = { + enable = mkEnableOption "Enable power-profiles-daemon and disable TLP for the GPD Duo" // { + # Default increase PPT to the BIOS default when power adapter plugin to increase performance. + default = true; + }; + }; + + config = mkIf cfg.enable { + services.power-profiles-daemon.enable = mkDefault true; + services.tlp.enable = mkForce false; + }; +} diff --git a/gpd/pocket-4/default.nix b/gpd/pocket-4/default.nix index cb44fe65..fbd5abee 100644 --- a/gpd/pocket-4/default.nix +++ b/gpd/pocket-4/default.nix @@ -10,6 +10,7 @@ in ../../common/cpu/amd/pstate.nix ../../common/gpu/amd ../../common/hidpi.nix + ../ppt.nix ]; boot = { diff --git a/gpd/ppt.nix b/gpd/ppt.nix new file mode 100644 index 00000000..ffbf2a56 --- /dev/null +++ b/gpd/ppt.nix @@ -0,0 +1,66 @@ +{ + config, + lib, + pkgs, + ... +}: +with lib; +let + cfg = config.hardware.gpd.ppt; +in +{ + # Linux default PPT is 24-22-22, BIOS default PPT is 35-32-28. It can be controlled by ryzenadj. + + # NOTICE: Whenever you can limit PPT to 15W by pressing Fn + Shift to enter quiet mode. + + options.hardware.gpd.ppt = { + enable = mkEnableOption "Enable PPT control for device by ryzenadj." // { + # Default increase PPT to the BIOS default when power adapter plugin to increase performance. + default = true; + }; + + adapter = { + fast-limit = mkOption { + description = "Fast PTT Limit(milliwatt) when power adapter plugin."; + default = 35000; + type = types.ints.unsigned; + }; + slow-limit = mkOption { + description = "Slow PTT Limit(milliwatt) when power adapter plugin."; + default = 32000; + type = types.ints.unsigned; + }; + stapm-limit = mkOption { + description = "Stapm PTT Limit(milliwatt) when power adapter plugin."; + default = 28000; + type = types.ints.unsigned; + }; + }; + + battery = { + fast-limit = mkOption { + description = "Fast PTT Limit(milliwatt) when using battery."; + default = 24000; + type = types.ints.unsigned; + }; + slow-limit = mkOption { + description = "Slow PTT Limit(milliwatt) when using battery."; + default = 22000; + type = types.ints.unsigned; + }; + stapm-limit = mkOption { + description = "Stapm PTT Limit(milliwatt) when using battery."; + default = 22000; + type = types.ints.unsigned; + }; + }; + }; + + config = mkIf cfg.enable { + environment.systemPackages = [ pkgs.ryzenadj ]; + services.udev.extraRules = '' + SUBSYSTEM=="power_supply", KERNEL=="ADP1", ATTR{online}=="1", RUN+="${getExe pkgs.ryzenadj} --stapm-limit ${toString cfg.adapter.stapm-limit} --fast-limit ${toString cfg.adapter.fast-limit} --slow-limit ${toString cfg.adapter.slow-limit}" + SUBSYSTEM=="power_supply", KERNEL=="ADP1", ATTR{online}=="0", RUN+="${getExe pkgs.ryzenadj} --stapm-limit ${toString cfg.battery.stapm-limit} --fast-limit ${toString cfg.battery.fast-limit} --slow-limit ${toString cfg.battery.slow-limit}" + ''; + }; +} diff --git a/gpd/win-max-2/default.nix b/gpd/win-max-2/default.nix index c9762cd6..47e2dbe6 100644 --- a/gpd/win-max-2/default.nix +++ b/gpd/win-max-2/default.nix @@ -1,72 +1,8 @@ -{ - config, - lib, - pkgs, - ... -}: -with lib; -let - cfg = config.hardware.gpd.ppt; -in -{ +{ ... }: { imports = [ ../../common/pc/laptop ../../common/pc/ssd ../../common/hidpi.nix + ../ppt.nix ]; - - # Linux default PPT is 24-22-22, BIOS default PPT is 35-32-28. It can be controlled by ryzenadj. - - # NOTICE: Whenever you can limit PPT to 15W by pressing Fn + Shift to enter quiet mode. - - options.hardware.gpd.ppt = { - enable = mkEnableOption "Enable PPT control for device by ryzenadj." // { - # Default increase PPT to the BIOS default when power adapter plugin to increase performance. - default = true; - }; - - adapter = { - fast-limit = mkOption { - description = "Fast PTT Limit(milliwatt) when power adapter plugin."; - default = 35000; - type = types.ints.unsigned; - }; - slow-limit = mkOption { - description = "Slow PTT Limit(milliwatt) when power adapter plugin."; - default = 32000; - type = types.ints.unsigned; - }; - stapm-limit = mkOption { - description = "Stapm PTT Limit(milliwatt) when power adapter plugin."; - default = 28000; - type = types.ints.unsigned; - }; - }; - - battery = { - fast-limit = mkOption { - description = "Fast PTT Limit(milliwatt) when using battery."; - default = 24000; - type = types.ints.unsigned; - }; - slow-limit = mkOption { - description = "Slow PTT Limit(milliwatt) when using battery."; - default = 22000; - type = types.ints.unsigned; - }; - stapm-limit = mkOption { - description = "Stapm PTT Limit(milliwatt) when using battery."; - default = 22000; - type = types.ints.unsigned; - }; - }; - }; - - config = mkIf cfg.enable { - environment.systemPackages = [ pkgs.ryzenadj ]; - services.udev.extraRules = '' - SUBSYSTEM=="power_supply", KERNEL=="ADP1", ATTR{online}=="1", RUN+="${pkgs.ryzenadj}/bin/ryzenadj --stapm-limit ${toString cfg.adapter.stapm-limit} --fast-limit ${toString cfg.adapter.fast-limit} --slow-limit ${toString cfg.adapter.slow-limit}" - SUBSYSTEM=="power_supply", KERNEL=="ADP1", ATTR{online}=="0", RUN+="${pkgs.ryzenadj}/bin/ryzenadj --stapm-limit ${toString cfg.battery.stapm-limit} --fast-limit ${toString cfg.battery.fast-limit} --slow-limit ${toString cfg.battery.slow-limit}" - ''; - }; } diff --git a/gpd/win-mini/2024/default.nix b/gpd/win-mini/2024/default.nix index c8eb1bfd..6f93e46c 100644 --- a/gpd/win-mini/2024/default.nix +++ b/gpd/win-mini/2024/default.nix @@ -6,6 +6,7 @@ with lib; ../../../common/cpu/amd ../../../common/cpu/amd/pstate.nix ../../../common/gpu/amd + ../../ppt.nix ]; hardware.bluetooth.enable = lib.mkDefault true; diff --git a/intel/nuc/8i7beh/default.nix b/intel/nuc/8i7beh/default.nix index 5dfed4ef..22b15b6a 100644 --- a/intel/nuc/8i7beh/default.nix +++ b/intel/nuc/8i7beh/default.nix @@ -2,7 +2,9 @@ { imports = [ - ../../../common/cpu/intel + ../../../common/cpu/intel/coffee-lake + ../../../common/pc + ../../../common/pc/ssd ]; services.thermald.enable = lib.mkDefault true; diff --git a/lenovo/thinkpad/p1/default.nix b/lenovo/thinkpad/p1/default.nix index 197bfab2..75c0abee 100644 --- a/lenovo/thinkpad/p1/default.nix +++ b/lenovo/thinkpad/p1/default.nix @@ -1,9 +1,6 @@ { imports = [ ../../../common/cpu/intel - # might need nvidia module but we don't know the PCI ids: - # https://github.com/NixOS/nixos-hardware/pull/274#discussion_r650483740 - #../../../common/gpu/nvidia/prime.nix ../../../common/pc/ssd ]; diff --git a/lenovo/thinkpad/p1/gen5/README.md b/lenovo/thinkpad/p1/gen5/README.md new file mode 100644 index 00000000..41d2aaf4 --- /dev/null +++ b/lenovo/thinkpad/p1/gen5/README.md @@ -0,0 +1,68 @@ +# Lenovo ThinkPad P1 Gen 5 + +https://www.lenovo.com/us/en/p/laptops/thinkpad/thinkpadp/thinkpad-p1-gen-5-16-inch-intel/len101t0033 + +Tested on a P1 Gen 5 with Intel Iris Xe (Alder Lake) graphics and an +NVIDIA GeForce RTX 3080 Ti Mobile (Ampere) discrete GPU. + +- `lenovo-thinkpad-p1-gen5` — Alder Lake base; use on iGPU-only units. +- `lenovo-thinkpad-p1-gen5-nvidia` — adds NVIDIA PRIME **offload**. Run a + program on the discrete GPU with `nvidia-offload `. + +## Power management + +The `-nvidia` profile enables PRIME **offload** but does not turn on fine-grained +runtime power management, so the discrete GPU stays powered even when idle — +noticeable battery drain on a laptop. That setting is experimental and depends on +the GPU + firmware supporting PCIe Runtime D3 (RTD3), so it is left to the user. +If your unit supports it, let the dGPU suspend when unused by adding to your own +configuration: + +```nix +hardware.nvidia.powerManagement.finegrained = true; +``` + +## Tested Hardware + +```shell +lspci -nn +00:00.0 Host bridge [0600]: Intel Corporation 12th Gen Core Processor Host Bridge/DRAM Registers [8086:4641] (rev 02) +00:01.0 PCI bridge [0604]: Intel Corporation 12th Gen Core Processor PCI Express x16 Controller #1 [8086:460d] (rev 02) +00:02.0 VGA compatible controller [0300]: Intel Corporation Alder Lake-P GT2 [Iris Xe Graphics] [8086:46a6] (rev 0c) +00:04.0 Signal processing controller [1180]: Intel Corporation Alder Lake Innovation Platform Framework Processor Participant [8086:461d] (rev 02) +00:06.0 PCI bridge [0604]: Intel Corporation 12th Gen Core Processor PCI Express x4 Controller #0 [8086:464d] (rev 02) +00:08.0 System peripheral [0880]: Intel Corporation 12th Gen Core Processor Gaussian & Neural Accelerator [8086:464f] (rev 02) +00:0a.0 Signal processing controller [1180]: Intel Corporation Platform Monitoring Technology [8086:467d] (rev 01) +00:14.0 USB controller [0c03]: Intel Corporation Alder Lake PCH USB 3.2 xHCI Host Controller [8086:51ed] (rev 01) +00:14.2 RAM memory [0500]: Intel Corporation Alder Lake PCH Shared SRAM [8086:51ef] (rev 01) +00:14.3 Network controller [0280]: Intel Corporation Alder Lake-P PCH CNVi WiFi [8086:51f0] (rev 01) +00:15.0 Serial bus controller [0c80]: Intel Corporation Alder Lake PCH Serial IO I2C Controller #0 [8086:51e8] (rev 01) +00:16.0 Communication controller [0780]: Intel Corporation Alder Lake PCH HECI Controller [8086:51e0] (rev 01) +00:16.3 Serial controller [0700]: Intel Corporation Alder Lake AMT SOL Redirection [8086:51e3] (rev 01) +00:1c.0 PCI bridge [0604]: Intel Corporation Device [8086:51b8] (rev 01) +00:1c.7 PCI bridge [0604]: Intel Corporation Alder Lake PCH-P PCI Express Root Port #9 [8086:51bf] (rev 01) +00:1d.0 PCI bridge [0604]: Intel Corporation Alder Lake PCI Express Root Port #9 [8086:51b0] (rev 01) +00:1f.0 ISA bridge [0601]: Intel Corporation Alder Lake PCH eSPI Controller [8086:5182] (rev 01) +00:1f.3 Multimedia audio controller [0401]: Intel Corporation Alder Lake PCH-P High Definition Audio Controller [8086:51c8] (rev 01) +00:1f.4 SMBus [0c05]: Intel Corporation Alder Lake PCH-P SMBus Host Controller [8086:51a3] (rev 01) +00:1f.5 Serial bus controller [0c80]: Intel Corporation Alder Lake-P PCH SPI Controller [8086:51a4] (rev 01) +01:00.0 VGA compatible controller [0300]: NVIDIA Corporation GA103M [GeForce RTX 3080 Ti Mobile] [10de:2420] (rev a1) +01:00.1 Audio device [0403]: NVIDIA Corporation Device [10de:2288] (rev a1) +04:00.0 Non-Volatile memory controller [0108]: SK hynix Gold P31/BC711/PC711 NVMe Solid State Drive [1c5c:174a] +0a:00.0 Unassigned class [ff00]: Realtek Semiconductor Co., Ltd. RTS5261 PCIe SD Express Card Reader controller [10ec:5261] (rev 01) +20:00.0 PCI bridge [0604]: Intel Corporation Thunderbolt 4 Bridge [Maple Ridge 4C 2020] [8086:1136] (rev 02) +21:00.0 PCI bridge [0604]: Intel Corporation Thunderbolt 4 Bridge [Maple Ridge 4C 2020] [8086:1136] (rev 02) +21:01.0 PCI bridge [0604]: Intel Corporation Thunderbolt 4 Bridge [Maple Ridge 4C 2020] [8086:1136] (rev 02) +21:02.0 PCI bridge [0604]: Intel Corporation Thunderbolt 4 Bridge [Maple Ridge 4C 2020] [8086:1136] (rev 02) +21:03.0 PCI bridge [0604]: Intel Corporation Thunderbolt 4 Bridge [Maple Ridge 4C 2020] [8086:1136] (rev 02) +22:00.0 USB controller [0c03]: Intel Corporation Thunderbolt 4 NHI [Maple Ridge 4C 2020] [8086:1137] +56:00.0 USB controller [0c03]: Intel Corporation Thunderbolt 4 USB Controller [Maple Ridge 4C 2020] [8086:1138] + +nix-info -m + - system: `"x86_64-linux"` + - host os: `Linux 7.0.11, NixOS, 26.05 (Yarara), 26.05.20260603.6b31628` + - multi-user?: `yes` + - sandbox: `yes` + - version: `nix-env (Nix) 2.34.7` + - nixpkgs: `/nix/store/snzg7swkp0vsd2qch9izsbmxnyb13ca0-source` +``` diff --git a/lenovo/thinkpad/p1/gen5/default.nix b/lenovo/thinkpad/p1/gen5/default.nix new file mode 100644 index 00000000..1c9661fc --- /dev/null +++ b/lenovo/thinkpad/p1/gen5/default.nix @@ -0,0 +1,7 @@ +{ ... }: +{ + imports = [ + ../. + ../../../../common/cpu/intel/alder-lake # P1 Gen 5 is 12th-gen Alder Lake + ]; +} diff --git a/lenovo/thinkpad/p1/gen5/nvidia/default.nix b/lenovo/thinkpad/p1/gen5/nvidia/default.nix new file mode 100644 index 00000000..4b588292 --- /dev/null +++ b/lenovo/thinkpad/p1/gen5/nvidia/default.nix @@ -0,0 +1,26 @@ +{ lib, ... }: +{ + imports = [ + ../. + ../../../../../common/gpu/nvidia/ampere + ../../../../../common/gpu/nvidia/prime.nix + ]; + + hardware = { + graphics = { + enable = lib.mkDefault true; + enable32Bit = lib.mkDefault true; + }; + nvidia = { + # "Wayland requires kernel mode setting (KMS) to be enabled (Highly + # Recommended)" per https://wiki.nixos.org/wiki/NVIDIA#Requirements. + modesetting.enable = lib.mkDefault true; + prime = { + # Bus ID of the Intel GPU. + intelBusId = lib.mkDefault "PCI:0:2:0"; + # Bus ID of the NVIDIA GPU. + nvidiaBusId = lib.mkDefault "PCI:1:0:0"; + }; + }; + }; +} diff --git a/lenovo/thinkpad/x1-extreme/gen2/default.nix b/lenovo/thinkpad/x1-extreme/gen2/default.nix index 17147b53..25023300 100644 --- a/lenovo/thinkpad/x1-extreme/gen2/default.nix +++ b/lenovo/thinkpad/x1-extreme/gen2/default.nix @@ -5,6 +5,7 @@ with lib; { imports = [ ../. + ../../../../common/cpu/intel/coffee-lake ]; # Fixes an issue with incorrect battery reporting. See @@ -15,6 +16,9 @@ with lib; # See also https://certification.ubuntu.com/catalog/component/input/5313/input%3ATPPS/2ElanTrackPoint/ hardware.trackpoint.device = "TPPS/2 Elan TrackPoint"; + # Fix clickpad (clicking by depressing the touchpad). + boot.kernelParams = [ "psmouse.synaptics_intertouch=0" ]; + # Since the HDMI port is connected to the NVIDIA card. hardware.bumblebee.connectDisplay = true; diff --git a/mnt/reform/updateKernelPatches.nix b/mnt/reform/updateKernelPatches.nix index e30bd6f9..2bffbec6 100644 --- a/mnt/reform/updateKernelPatches.nix +++ b/mnt/reform/updateKernelPatches.nix @@ -1,4 +1,5 @@ { + runCommand, lib, fetchFromGitLab, }: @@ -7,6 +8,8 @@ let sources = lib.importJSON ./sources.json; reformDebianPackages = fetchFromGitLab sources.reformDebianPackages; in -map (lib.removePrefix "${reformDebianPackages}/") ( - lib.filesystem.listFilesRecursive "${reformDebianPackages}/linux/patches${lib.versions.majorMinor sources.modDirVersion}" -) +runCommand "mnt-reform-kernel-patches" { } '' + shopt -s globstar + cd ${reformDebianPackages} + echo -e "[\n$(printf ' "%s"\n' linux/patches${lib.versions.majorMinor sources.modDirVersion}/**/*.patch)\n]"> $out +'' diff --git a/mnt/reform/updateKernelPatches.sh b/mnt/reform/updateKernelPatches.sh index 79581c7d..8475acc0 100755 --- a/mnt/reform/updateKernelPatches.sh +++ b/mnt/reform/updateKernelPatches.sh @@ -1,4 +1,4 @@ #!/usr/bin/env sh -nix eval .#mnt-reform-kernel-patches > kernelPatches.nix -nix fmt kernelPatches.nix +nix build .#mnt-reform-kernel-patches +cp result kernelPatches.nix diff --git a/raspberry-pi/common/firmware.nix b/raspberry-pi/common/firmware.nix index f3631ff2..2f7baf8d 100644 --- a/raspberry-pi/common/firmware.nix +++ b/raspberry-pi/common/firmware.nix @@ -70,14 +70,32 @@ let kept[$dst]=1 done - if [ -d "$dtbSrc/overlays" ]; then - for ovr in "$dtbSrc"/overlays/*; do + # hardware.raspberry-pi.configtxt.deviceTreeOverlays entries are + # matched by filename against the vendor .dtbo set the Raspberry Pi + # firmware ships, regardless of whether the *base* dtb above came + # from the generation or from firmwareBoot. Stage those + # unconditionally so config.txt's "dtoverlay=" lines have a target + # to apply, even when useGenerationDeviceTree = true. + if [ -d "$firmwareBoot/overlays" ]; then + for ovr in "$firmwareBoot"/overlays/*; do dst="$target/overlays/$(basename "$ovr")" copyForced "$ovr" "$dst" kept[$dst]=1 done fi + # When useGenerationDeviceTree also produced its own overlays + # (built via hardware.deviceTree.overlays), stage those too, + # letting them take precedence over same-named vendor overlays. + if [ "$dtbSrc" != "$firmwareBoot" ] && [ -d "$dtbSrc/overlays" ]; then + for ovr in "$dtbSrc"/overlays/*; do + dst="$target/overlays/$(basename "$ovr")" + copyForced "$ovr" "$dst" + kept[$dst]=1 + done + fi + + # Prune stale device trees / overlays. for fn in "$target"/*.dtb "$target"/overlays/*; do if [ "''${kept[$fn]:-}" != 1 ]; then diff --git a/raspberry-pi/common/kernel.nix b/raspberry-pi/common/kernel.nix index ed4ad9b5..92b73547 100644 --- a/raspberry-pi/common/kernel.nix +++ b/raspberry-pi/common/kernel.nix @@ -10,9 +10,9 @@ let # NOTE: raspberryPiWirelessFirmware should be updated with this - modDirVersion = "6.18.39"; - tag = "stable_20260724"; - hash = "sha256-IT/SkF458oLmnFIPbN76Qp6s8KVxKQOC02XmN7NRdBc="; + modDirVersion = "6.18.50"; + tag = "stable_20260911"; + hash = "sha256-rIYYt4AzTZnZO1v8Gv6byJFXm4gQDlColgRSu09/9F4="; inherit (lib.kernel) freeform yes no; in (buildLinux ( diff --git a/raspberry-pi/common/raspberry-pi-wireless-firmware.nix b/raspberry-pi/common/raspberry-pi-wireless-firmware.nix index 17ef3fda..e5b20784 100644 --- a/raspberry-pi/common/raspberry-pi-wireless-firmware.nix +++ b/raspberry-pi/common/raspberry-pi-wireless-firmware.nix @@ -6,7 +6,7 @@ stdenvNoCC.mkDerivation { pname = "raspberrypi-wireless-firmware"; - version = "0-unstable-2026-03-21"; + version = "0-unstable-2026-07-10"; srcs = [ (fetchFromGitHub { @@ -20,8 +20,8 @@ stdenvNoCC.mkDerivation { name = "firmware-nonfree"; owner = "RPi-Distro"; repo = "firmware-nonfree"; - rev = "9794282eb9f4a2de1f23b41a738926740e975d83"; - hash = "sha256-OtA8yHvfusGP/ucf8Exzi+nSUmNoYp10u+luC2gbNZc="; + rev = "3bab0f823f5b53150b76aab77093adef6655b920"; + hash = "sha256-2DXj2esIix8YQwBf3IuzHwnUJ+yCANbRdpyS/DeB4XE="; }) ]; @@ -36,7 +36,8 @@ stdenvNoCC.mkDerivation { mkdir -p "$out/lib/firmware/brcm" # Wifi firmware - cp -r "firmware-nonfree/debian/config/brcm80211/." "$out/lib/firmware/" + cp -r "firmware-nonfree/debian/added-firmware/brcm" "$out/lib/firmware/" + cp -r "firmware-nonfree/debian/added-firmware/cypress" "$out/lib/firmware/" # Bluetooth firmware cp -r "bluez-firmware/debian/firmware/broadcom/." "$out/lib/firmware/brcm" diff --git a/tests/flake.lock b/tests/flake.lock index 09bc7112..b2249ce8 100644 --- a/tests/flake.lock +++ b/tests/flake.lock @@ -2,11 +2,11 @@ "nodes": { "nixos-stable": { "locked": { - "lastModified": 1784011430, - "narHash": "sha256-LX2eBS9gFbXL5xUNBwp5mZ0tjnNvgiXoDnhz3ee1LzY=", - "rev": "8eeec934ae0dbeca3d7868c059568a65c08b2fc3", + "lastModified": 1789542786, + "narHash": "sha256-BGtBoaZNpOPDEBLTiWNFdYppnDjGhwrUq5/P15QwrrM=", + "rev": "4c7870105e7f1fdf9c48688c8d7efc21abf0688a", "type": "tarball", - "url": "https://releases.nixos.org/nixos/26.05/nixos-26.05.4937.8eeec934ae0d/nixexprs.tar.xz" + "url": "https://releases.nixos.org/nixos/26.05/nixos-26.05.9904.4c7870105e7f/nixexprs.tar.xz" }, "original": { "type": "tarball", @@ -15,11 +15,11 @@ }, "nixos-unstable-small": { "locked": { - "lastModified": 1784157011, - "narHash": "sha256-k3oN75PtDT9xJfc4zqgah7ulSaw1Bv/XDuMrXaHupEE=", - "rev": "d4a57f162b50db6d7e49580a772ccbdb3a1605a4", + "lastModified": 1789590615, + "narHash": "sha256-Kdzc9cA73knnnxYsWcfV1fL1Ru4sCYSjRvIpZBFKrL8=", + "rev": "bc071daf4c377dd821398672fafe269d5c654ce8", "type": "tarball", - "url": "https://releases.nixos.org/nixos/unstable-small/nixos-26.11pre1035646.d4a57f162b50/nixexprs.tar.xz" + "url": "https://releases.nixos.org/nixos/unstable-small/nixos-26.11pre1075076.bc071daf4c37/nixexprs.tar.xz" }, "original": { "type": "tarball",