From ca8613a693e22921ce513b2ff6d61466f4e44b15 Mon Sep 17 00:00:00 2001 From: eum3l <77971322+eum3l@users.noreply.github.com> Date: Wed, 30 Oct 2024 22:00:08 +0100 Subject: [PATCH] minisforum/v3: init --- README.md | 7 ++--- flake.nix | 1 + minisforum/v3/accelerometer.nix | 39 +++++++++++++++++++++++++++ minisforum/v3/audio.nix | 47 +++++++++++++++++++++++++++++++++ minisforum/v3/default.nix | 12 +++++++++ minisforum/v3/dsdt.patch | 31 ++++++++++++++++++++++ minisforum/v3/power.nix | 19 +++++++++++++ minisforum/v3/src.nix | 8 ++++++ 8 files changed, 161 insertions(+), 3 deletions(-) create mode 100644 minisforum/v3/accelerometer.nix create mode 100644 minisforum/v3/audio.nix create mode 100644 minisforum/v3/default.nix create mode 100644 minisforum/v3/dsdt.patch create mode 100644 minisforum/v3/power.nix create mode 100644 minisforum/v3/src.nix diff --git a/README.md b/README.md index 3c92298e6..f3650bcc0 100644 --- a/README.md +++ b/README.md @@ -300,6 +300,7 @@ See code for all available configurations. | [Microsoft Surface Pro 3](microsoft/surface-pro/3) | `` | | [Microsoft Surface Pro 9](microsoft/surface-pro/9) | `` | | [Morefine M600](morefine/m600) | `` | +| [Minisforum V3](minisforum/v3) | `` | | [NXP iMX8 MPlus Evaluation Kit](nxp/imx8mp-evk) | `` | | [NXP iMX8 MQuad Evaluation Kit](nxp/imx8mq-evk) | `` | | [Hardkernel Odroid HC4](hardkernel/odroid-hc4/default.nix) | `` | @@ -327,15 +328,15 @@ See code for all available configurations. | [Samsung Series 9 NP900X3C](samsung/np900x3c) | `` | | [StarFive VisionFive v1](starfive/visionfive/v1) | `` | | [StarFive VisionFive 2](starfive/visionfive/v2) | `` | -| [StarLabs StarLite 5 (I5)](starlabs/starlite/i5) | `` | +| [StarLabs StarLite 5 (I5)](starlabs/starlite/i5) | `` | | [Supermicro A1SRi-2758F](supermicro/a1sri-2758f) | `` | | [Supermicro M11SDV-8C-LN4F](supermicro/m11sdv-8c-ln4f) | `` | | [Supermicro X10SLL-F](supermicro/x10sll-f) | `` | | [Supermicro X12SCZ-TLN4F](supermicro/x12scz-tln4f) | `` | | [System76 (generic)](system76) | `` | | [System76 Darter Pro 6](system76/darp6) | `` | -| [System76 Gazelle 18](system76/gaze18) | `` | -| [System76 Galago Pro 5](system76/galp5-1650) | `` | +| [System76 Gazelle 18](system76/gaze18) | `` | +| [System76 Galago Pro 5](system76/galp5-1650) | `` | | [Toshiba Chromebook 2 `swanky`](toshiba/swanky) | `` | | [Tuxedo InfinityBook v4](tuxedo/infinitybook/v4) | `` | | [TUXEDO Aura 15 - Gen1](tuxedo/aura/15/gen1) | `` | diff --git a/flake.nix b/flake.nix index c404a9fc2..0ac9acba2 100644 --- a/flake.nix +++ b/flake.nix @@ -244,6 +244,7 @@ microsoft-surface-pro-3 = import ./microsoft/surface-pro/3; microsoft-surface-pro-9 = import ./microsoft/surface-pro/9; milkv-pioneer = import ./milkv/pioneer; + minisforum-v3 = import ./minisforum/v3; morefine-m600 = import ./morefine/m600; msi-b350-tomahawk = import ./msi/b350-tomahawk; msi-b550-a-pro = import ./msi/b550-a-pro; diff --git a/minisforum/v3/accelerometer.nix b/minisforum/v3/accelerometer.nix new file mode 100644 index 000000000..d984f8bda --- /dev/null +++ b/minisforum/v3/accelerometer.nix @@ -0,0 +1,39 @@ +{ pkgs, ... }: +{ + + # Override the DSDT ACPI table to fix the accelerometer. + # A driver already exists for a similar sensor. + # This overrides the IDs to make the existing driver work. + # From [Accelerometer on Linux](https://github.com/mudkipme/awesome-minisforum-v3/issues/2#issuecomment-2279282784) + boot.initrd.prepend = + let + minisforum-acpi-override = pkgs.stdenv.mkDerivation { + name = "minisforum-acpi-override"; + CPIO_PATH = "kernel/firmware/acpi"; + + src = pkgs.callPackage ./src.nix {}; + patches = [ ./dsdt.patch ]; + + nativeBuildInputs = with pkgs; [ + acpica-tools + cpio + ]; + + installPhase = '' + mkdir -p $CPIO_PATH + iasl -tc ./dsdt.dsl + cp ./dsdt.aml $CPIO_PATH + find kernel | cpio -H newc --create > acpi_override + cp acpi_override $out + ''; + }; + in + [ (toString minisforum-acpi-override) ]; + + # Fix inverted accelerometer rotation. + services.udev.extraHwdb = '' + sensor:modalias:acpi:SMO8B30*:dmi:*svnMicroComputer*:pnV3:* + ACCEL_MOUNT_MATRIX=-1, 0, 0; 0, -1, 0; 0, 0, -1 + ''; + +} diff --git a/minisforum/v3/audio.nix b/minisforum/v3/audio.nix new file mode 100644 index 000000000..823f0da1b --- /dev/null +++ b/minisforum/v3/audio.nix @@ -0,0 +1,47 @@ +{ ... }: +{ + # Fix microphone. + # From [Volume control workaround doesn't work on Arch](https://github.com/mudkipme/awesome-minisforum-v3/issues/10#issuecomment-2317474057) + boot.extraModprobeConfig = '' + options snd-hda-intel model=alc256-asus-aio + ''; + + # From [volume control fixes for arch](https://github.com/mudkipme/awesome-minisforum-v3/issues/9#issue-2407782714) + services.pipewire.wireplumber.extraConfig."alsa-soft-mixer"."monitor.alsa.rules" = [ + { + # Enable soft-mixer. + # Fix global volume control. + actions.update-props."api.alsa.soft-mixer" = true; + matches = [ + { + "device.name" = "~alsa_card.*"; + } + ]; + } + { + # Disable soft-mixer for input devices. + actions.update-props."api.alsa.soft-mixer" = false; + matches = [ + { + "device.name" = "~alsa_card.*"; + "node.name" = "~alsa_input.*"; + } + ]; + } + { + # Disable audio session suspension. + # Fix bug with plugged in headphones. + # From [Disable audio session suspension](https://github.com/mudkipme/awesome-minisforum-v3?tab=readme-ov-file#disable-audio-session-suspension) + actions.update-props."session.suspend-timeout-seconds" = "0"; + matches = [ + { + "node.name" = "~alsa_input.*"; + } + { + "node.name" = "~alsa_output.*"; + } + ]; + } + ]; + +} diff --git a/minisforum/v3/default.nix b/minisforum/v3/default.nix new file mode 100644 index 000000000..947746b0a --- /dev/null +++ b/minisforum/v3/default.nix @@ -0,0 +1,12 @@ +{ ... }: +{ + imports = [ + ./accelerometer.nix + ./audio.nix + ./power.nix + + ../../common/gpu/amd/default.nix + ../../common/cpu/amd/default.nix + ../../common/pc/laptop/default.nix + ]; +} diff --git a/minisforum/v3/dsdt.patch b/minisforum/v3/dsdt.patch new file mode 100644 index 000000000..ce799986e --- /dev/null +++ b/minisforum/v3/dsdt.patch @@ -0,0 +1,31 @@ +--- dsdt.dsl 2024-08-10 06:24:09.143777067 +0200 ++++ patched/dsdt.dsl 2024-08-10 04:58:50.191036154 +0200 +@@ -18,7 +18,7 @@ + * Compiler ID "INTL" + * Compiler Version 0x20220331 (539099953) + */ +-DefinitionBlock ("", "DSDT", 2, "ALASKA", "A M I ", 0x01072009) ++DefinitionBlock ("", "DSDT", 2, "ALASKA", "A M I ", 0x01072019) + { + External (_SB_.APTS, MethodObj) // 1 Arguments + External (_SB_.AWAK, MethodObj) // 1 Arguments +@@ -7341,7 +7341,7 @@ + + Device (CIND) + { +- Name (_HID, "ID9001") // _HID: Hardware ID ++ Name (_HID, "INT33D3") // _HID: Hardware ID + Name (_CID, "PNP0C60" /* Display Sensor Device */) // _CID: Compatible ID + Method (_STA, 0, Serialized) // _STA: Status + { +@@ -7364,8 +7364,8 @@ + { + Device (STS) + { +- Name (_HID, EisaId ("SMOCF05")) // _HID: Hardware ID +- Name (_CID, EisaId ("SMOCF05")) // _CID: Compatible ID ++ Name (_HID, EisaId ("SMO8B30")) // _HID: Hardware ID ++ Name (_CID, EisaId ("SMO8B30")) // _CID: Compatible ID + Name (_UID, Zero) // _UID: Unique ID + Method (_STA, 0, NotSerialized) // _STA: Status + { \ No newline at end of file diff --git a/minisforum/v3/power.nix b/minisforum/v3/power.nix new file mode 100644 index 000000000..0aca22872 --- /dev/null +++ b/minisforum/v3/power.nix @@ -0,0 +1,19 @@ +{ pkgs, ... }: +{ + + # From [Optimizing power draw (under Linux)](https://github.com/mudkipme/awesome-minisforum-v3/issues/5#issue-2391536450) + boot.kernelParams = [ "pcie_aspm.policy=powersupersave" ]; + systemd.services.enable-aspm = { + wantedBy = [ "default.target" ]; + serviceConfig = { + ExecStart = "${pkgs.bash}/bin/bash ${pkgs.callPackage ./src.nix { }}/aspm_v3.sh"; + Restart = "no"; + }; + + path = with pkgs; [ + bc + pciutils + ]; + }; + +} diff --git a/minisforum/v3/src.nix b/minisforum/v3/src.nix new file mode 100644 index 000000000..d2686bc0c --- /dev/null +++ b/minisforum/v3/src.nix @@ -0,0 +1,8 @@ +# Outsource for aspm_v3.sh and dsdt.dsl +{ fetchFromGitHub, ... }: +fetchFromGitHub { + owner = "eum3l"; + repo = "minisforum-v3-nixos-hardware"; + rev = "4b1d99b3379d046142c1094018072acc22b40c70"; + hash = "sha256-UBPTLbSjDdL6NPUrAdsWcL28QSyiY/5oA+iqxl9dEGY="; +}