From f8b9bfe69b6baab93bd6453b67cb3311e34bde97 Mon Sep 17 00:00:00 2001 From: caleb Date: Sat, 16 Nov 2024 18:19:51 -0500 Subject: [PATCH 01/12] modified nvidia services to allow for combination sleep/suspend --- common/gpu/nvidia/ada-lovelace/default.nix | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/common/gpu/nvidia/ada-lovelace/default.nix b/common/gpu/nvidia/ada-lovelace/default.nix index 461ae914f..5b21702f1 100644 --- a/common/gpu/nvidia/ada-lovelace/default.nix +++ b/common/gpu/nvidia/ada-lovelace/default.nix @@ -7,4 +7,22 @@ in # enable the open source drivers if the package supports it hardware.nvidia.open = lib.mkOverride 990 (nvidiaPackage ? open && nvidiaPackage ? firmware); + + # nvidia's hibernate, suspend, and resume services are not normally triggered on suspend-then-hibernate and hybrid-hibernate + systemd.services = { + nvidia-hibernate = { + before = [ "systemd-suspend-then-hibernate.service" ]; + wantedBy = [ "suspend-then-hibernate.target" ]; + }; + + nvidia-suspend = { + before = [ "systemd-hybrid-sleep.service" ]; + wantedBy = [ "hybrid-sleep.target" ]; + }; + + nvidia-resume = { + after = [ "systemd-suspend-then-hibernate.service" "systemd-hybrid-sleep.service" ]; + wantedBy = [ "post-resume.target" ]; + }; + }; } From 51de9fe52b7674a720fdafd385eb803ae7d9cada Mon Sep 17 00:00:00 2001 From: caleb Date: Sat, 16 Nov 2024 18:20:31 -0500 Subject: [PATCH 02/12] added zephyrus g14 (2024) - ga403 --- asus/zephyrus/ga403/default.nix | 89 +++++++++++++++++++++++++++++++++ 1 file changed, 89 insertions(+) create mode 100644 asus/zephyrus/ga403/default.nix diff --git a/asus/zephyrus/ga403/default.nix b/asus/zephyrus/ga403/default.nix new file mode 100644 index 000000000..3c4f96243 --- /dev/null +++ b/asus/zephyrus/ga403/default.nix @@ -0,0 +1,89 @@ +{ config, + pkgs, + lib, + ... +}: + +let + inherit (lib) mkDefault; +in { + + imports = [ + ../../../common/cpu/amd + ../../../common/cpu/amd/pstate.nix + ../../../common/gpu/amd + ../../../common/pc/laptop + ../../../common/pc/laptop/acpi_call.nix + ../../../common/pc/ssd + ../../../../common/gpu/nvidia/prime.nix + ../../../../common/gpu/nvidia/ada-lovelace + ]; + + # Configure basic system settings: + boot = { + kernelPackages = mkDefault pkgs.linuxPackages_latest; + kernelModules = [ "kvm-amd" ]; + kernelParams = [ + "mem_sleep_default=deep" + "pcie_aspm.policy=powersupersave" + ]; + }; + + services = { + asusd = { + enable = mkDefault true; + enableUserService = mkDefault true; + }; + + supergfxd.enable = mkDefault true; + }; + + (mkIf (versionOlder version "23.11") { + # See https://asus-linux.org/wiki/nixos/ for info about some problems + # detecting the dGPU: + systemd.services.supergfxd.path = [ pkgs.pciutils ]; + }) + + (mkIf (config.networking.wireless.iwd.enable && config.networking.wireless.scanOnLowSignal) { + # Meditek doesn't seem to be quite sensitive enough on the default roaming settings: + # https://wiki.archlinux.org/title/Wpa_supplicant#Roaming + # https://wiki.archlinux.org/title/Iwd#iwd_keeps_roaming + # + # But NixOS doesn't have the tweaks for IWD, yet. + networking.wireless.iwd.settings = { + General = { + RoamThreshold = -75; + RoamThreshold5G = -80; + RoamRetryInterval = 20; + }; + }; + }) + + # Enable the Nvidia card, as well as Prime and Offload: NVIDIA GeForce RTX 4060 Mobile + boot.blacklistedKernelModules = [ "nouveau" ]; + + services.xserver.videoDrivers = mkDefault [ "nvidia" ]; + + hardware = { + amdgpu.initrd.enable = mkDefault true; + + nvidia = { + modesetting.enable = true; + nvidiaSettings = mkDefault true; + + prime = { + offload = { + enable = mkDefault true; + enableOffloadCmd = mkDefault true; + }; + amdgpuBusId = "PCI:101:0:0"; + nvidiaBusId = "PCI:1:0:0"; + }; + + powerManagement = { + enable = true; + finegrained = true + }; + }; + }; +} \ No newline at end of file From ce8601a85a1d87540abf5e76406d8fa561d148f2 Mon Sep 17 00:00:00 2001 From: caleb Date: Sat, 16 Nov 2024 18:43:28 -0500 Subject: [PATCH 03/12] fixed layout --- asus/zephyrus/ga403/default.nix | 116 +++++++++++++++++--------------- 1 file changed, 60 insertions(+), 56 deletions(-) diff --git a/asus/zephyrus/ga403/default.nix b/asus/zephyrus/ga403/default.nix index 3c4f96243..47ca265db 100644 --- a/asus/zephyrus/ga403/default.nix +++ b/asus/zephyrus/ga403/default.nix @@ -5,7 +5,7 @@ }: let - inherit (lib) mkDefault; + inherit (lib) mkDefault mkEnableOption mkIf mkMerge version versionAtLeast versionOlder; in { imports = [ @@ -19,71 +19,75 @@ in { ../../../../common/gpu/nvidia/ada-lovelace ]; - # Configure basic system settings: - boot = { - kernelPackages = mkDefault pkgs.linuxPackages_latest; - kernelModules = [ "kvm-amd" ]; - kernelParams = [ - "mem_sleep_default=deep" - "pcie_aspm.policy=powersupersave" - ]; - }; - - services = { - asusd = { - enable = mkDefault true; - enableUserService = mkDefault true; - }; - - supergfxd.enable = mkDefault true; - }; + config = mkMerge [ + { + # Configure basic system settings: + boot = { + kernelPackages = mkDefault pkgs.linuxPackages_latest; + kernelModules = [ "kvm-amd" ]; + kernelParams = [ + "mem_sleep_default=deep" + "pcie_aspm.policy=powersupersave" + ]; + }; - (mkIf (versionOlder version "23.11") { - # See https://asus-linux.org/wiki/nixos/ for info about some problems - # detecting the dGPU: - systemd.services.supergfxd.path = [ pkgs.pciutils ]; - }) + services = { + asusd = { + enable = mkDefault true; + enableUserService = mkDefault true; + }; - (mkIf (config.networking.wireless.iwd.enable && config.networking.wireless.scanOnLowSignal) { - # Meditek doesn't seem to be quite sensitive enough on the default roaming settings: - # https://wiki.archlinux.org/title/Wpa_supplicant#Roaming - # https://wiki.archlinux.org/title/Iwd#iwd_keeps_roaming - # - # But NixOS doesn't have the tweaks for IWD, yet. - networking.wireless.iwd.settings = { - General = { - RoamThreshold = -75; - RoamThreshold5G = -80; - RoamRetryInterval = 20; + supergfxd.enable = mkDefault true; }; - }; - }) - # Enable the Nvidia card, as well as Prime and Offload: NVIDIA GeForce RTX 4060 Mobile - boot.blacklistedKernelModules = [ "nouveau" ]; + # Enable the Nvidia card, as well as Prime and Offload: NVIDIA GeForce RTX 4060 Mobile + boot.blacklistedKernelModules = [ "nouveau" ]; - services.xserver.videoDrivers = mkDefault [ "nvidia" ]; + services.xserver.videoDrivers = mkDefault [ "nvidia" ]; - hardware = { - amdgpu.initrd.enable = mkDefault true; + hardware = { + amdgpu.initrd.enable = mkDefault true; - nvidia = { - modesetting.enable = true; - nvidiaSettings = mkDefault true; + nvidia = { + modesetting.enable = true; + nvidiaSettings = mkDefault true; - prime = { - offload = { - enable = mkDefault true; - enableOffloadCmd = mkDefault true; + prime = { + offload = { + enable = mkDefault true; + enableOffloadCmd = mkDefault true; + }; + amdgpuBusId = "PCI:101:0:0"; + nvidiaBusId = "PCI:1:0:0"; + }; + + powerManagement = { + enable = true; + finegrained = true + }; }; - amdgpuBusId = "PCI:101:0:0"; - nvidiaBusId = "PCI:1:0:0"; }; + } + + (mkIf (versionOlder version "23.11") { + # See https://asus-linux.org/wiki/nixos/ for info about some problems + # detecting the dGPU: + systemd.services.supergfxd.path = [ pkgs.pciutils ]; + }) - powerManagement = { - enable = true; - finegrained = true + (mkIf (config.networking.wireless.iwd.enable && config.networking.wireless.scanOnLowSignal) { + # Meditek doesn't seem to be quite sensitive enough on the default roaming settings: + # https://wiki.archlinux.org/title/Wpa_supplicant#Roaming + # https://wiki.archlinux.org/title/Iwd#iwd_keeps_roaming + # + # But NixOS doesn't have the tweaks for IWD, yet. + networking.wireless.iwd.settings = { + General = { + RoamThreshold = -75; + RoamThreshold5G = -80; + RoamRetryInterval = 20; + }; }; - }; - }; + }) + ]; } \ No newline at end of file From 8ac932b3993f4f2d8d1023a74274b50486b0dd82 Mon Sep 17 00:00:00 2001 From: caleb Date: Mon, 18 Nov 2024 12:23:09 -0500 Subject: [PATCH 04/12] fixed paths and forced video drivers --- asus/zephyrus/ga403/default.nix | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/asus/zephyrus/ga403/default.nix b/asus/zephyrus/ga403/default.nix index 47ca265db..032e67089 100644 --- a/asus/zephyrus/ga403/default.nix +++ b/asus/zephyrus/ga403/default.nix @@ -5,7 +5,7 @@ }: let - inherit (lib) mkDefault mkEnableOption mkIf mkMerge version versionAtLeast versionOlder; + inherit (lib) mkDefault mkEnableOption mkIf mkMerge mkForce version versionAtLeast versionOlder; in { imports = [ @@ -15,15 +15,15 @@ in { ../../../common/pc/laptop ../../../common/pc/laptop/acpi_call.nix ../../../common/pc/ssd - ../../../../common/gpu/nvidia/prime.nix - ../../../../common/gpu/nvidia/ada-lovelace + ../../../common/gpu/nvidia/prime.nix + ../../../common/gpu/nvidia/ada-lovelace ]; config = mkMerge [ { # Configure basic system settings: boot = { - kernelPackages = mkDefault pkgs.linuxPackages_latest; + kernelPackages = mkDefault pkgs.linuxPackages_latest; kernelModules = [ "kvm-amd" ]; kernelParams = [ "mem_sleep_default=deep" @@ -43,7 +43,7 @@ in { # Enable the Nvidia card, as well as Prime and Offload: NVIDIA GeForce RTX 4060 Mobile boot.blacklistedKernelModules = [ "nouveau" ]; - services.xserver.videoDrivers = mkDefault [ "nvidia" ]; + services.xserver.videoDrivers = mkForce [ "amdgpu" "nvidia" ]; hardware = { amdgpu.initrd.enable = mkDefault true; @@ -63,7 +63,7 @@ in { powerManagement = { enable = true; - finegrained = true + finegrained = true; }; }; }; @@ -90,4 +90,4 @@ in { }; }) ]; -} \ No newline at end of file +} From f35e440247eb467ab4a1fb1d375fa27592aef6af Mon Sep 17 00:00:00 2001 From: caleb Date: Mon, 25 Nov 2024 14:11:44 -0500 Subject: [PATCH 05/12] added ga403 import to flake.nix --- flake.nix | 1 + 1 file changed, 1 insertion(+) diff --git a/flake.nix b/flake.nix index bec4b4dfd..3775c1246 100644 --- a/flake.nix +++ b/flake.nix @@ -45,6 +45,7 @@ asus-zephyrus-ga402x = import ./asus/zephyrus/ga402x; asus-zephyrus-ga402x-amdgpu = import ./asus/zephyrus/ga402x/amdgpu; asus-zephyrus-ga402x-nvidia = import ./asus/zephyrus/ga402x/nvidia; + asus-zephyrus-ga403 = import ./asus/zephyrus/ga403; asus-zephyrus-ga502 = import ./asus/zephyrus/ga502; asus-zephyrus-ga503 = import ./asus/zephyrus/ga503; asus-zephyrus-gu603h = import ./asus/zephyrus/gu603h; From 8b2e64c0caf3876a3783e3b4757353cc2298abda Mon Sep 17 00:00:00 2001 From: caleb Date: Mon, 2 Dec 2024 17:56:43 -0500 Subject: [PATCH 06/12] added GA403 to readme --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 7f77e2666..37046b73f 100644 --- a/README.md +++ b/README.md @@ -101,6 +101,7 @@ See code for all available configurations. | [Asus ROG Zephyrus G14 GA402](asus/zephyrus/ga402) | `` | | [Asus ROG Zephyrus G14 GA402X\* (2023)](asus/zephyrus/ga402x/amdgpu) | `` | | [Asus ROG Zephyrus G14 GA402X\* (2023)](asus/zephyrus/ga402x/nvidia) | `` | +| [Asus ROG Zephyrus G14 GA403 (2024)](asus/zephyrus/ga403) | `` | | [Asus ROG Zephyrus G15 GA502](asus/zephyrus/ga502) | `` | | [Asus ROG Zephyrus G15 GA503](asus/zephyrus/ga503) | `` | | [Asus ROG Zephyrus G16 GU605MY](asus/zephyrus/gu605my) | `` | From 53e832b9cde6c7731f9983f2e865d3f3ce386bc5 Mon Sep 17 00:00:00 2001 From: caleb Date: Sat, 16 Nov 2024 18:19:51 -0500 Subject: [PATCH 07/12] modified nvidia services to allow for combination sleep/suspend --- common/gpu/nvidia/ada-lovelace/default.nix | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/common/gpu/nvidia/ada-lovelace/default.nix b/common/gpu/nvidia/ada-lovelace/default.nix index 461ae914f..5b21702f1 100644 --- a/common/gpu/nvidia/ada-lovelace/default.nix +++ b/common/gpu/nvidia/ada-lovelace/default.nix @@ -7,4 +7,22 @@ in # enable the open source drivers if the package supports it hardware.nvidia.open = lib.mkOverride 990 (nvidiaPackage ? open && nvidiaPackage ? firmware); + + # nvidia's hibernate, suspend, and resume services are not normally triggered on suspend-then-hibernate and hybrid-hibernate + systemd.services = { + nvidia-hibernate = { + before = [ "systemd-suspend-then-hibernate.service" ]; + wantedBy = [ "suspend-then-hibernate.target" ]; + }; + + nvidia-suspend = { + before = [ "systemd-hybrid-sleep.service" ]; + wantedBy = [ "hybrid-sleep.target" ]; + }; + + nvidia-resume = { + after = [ "systemd-suspend-then-hibernate.service" "systemd-hybrid-sleep.service" ]; + wantedBy = [ "post-resume.target" ]; + }; + }; } From babed36046f2260ff0fe17286827a3ab35b71cb3 Mon Sep 17 00:00:00 2001 From: caleb Date: Sat, 16 Nov 2024 18:20:31 -0500 Subject: [PATCH 08/12] added zephyrus g14 (2024) - ga403 --- README.md | 1 + asus/zephyrus/ga403/default.nix | 92 +++++++++++++++++++++++++++++++++ flake.nix | 1 + 3 files changed, 94 insertions(+) create mode 100644 asus/zephyrus/ga403/default.nix diff --git a/README.md b/README.md index a0b046553..143fe6a73 100644 --- a/README.md +++ b/README.md @@ -101,6 +101,7 @@ See code for all available configurations. | [Asus ROG Zephyrus G14 GA402](asus/zephyrus/ga402) | `` | | [Asus ROG Zephyrus G14 GA402X\* (2023)](asus/zephyrus/ga402x/amdgpu) | `` | | [Asus ROG Zephyrus G14 GA402X\* (2023)](asus/zephyrus/ga402x/nvidia) | `` | +| [Asus ROG Zephyrus G14 GA403 (2024)](asus/zephyrus/ga403) | `` | | [Asus ROG Zephyrus G15 GA502](asus/zephyrus/ga502) | `` | | [Asus ROG Zephyrus G15 GA503](asus/zephyrus/ga503) | `` | | [Asus ROG Zephyrus G16 GU605MY](asus/zephyrus/gu605my) | `` | diff --git a/asus/zephyrus/ga403/default.nix b/asus/zephyrus/ga403/default.nix new file mode 100644 index 000000000..d3c36ff57 --- /dev/null +++ b/asus/zephyrus/ga403/default.nix @@ -0,0 +1,92 @@ +{ + config, + pkgs, + lib, + ... +}: + +let + inherit (lib) + mkDefault + mkForce + ; +in +{ + + imports = [ + ../../../common/cpu/amd + ../../../common/cpu/amd/pstate.nix + ../../../common/gpu/amd + ../../../common/pc/laptop + ../../../common/pc/laptop/acpi_call.nix + ../../../common/pc/ssd + ../../../common/gpu/nvidia/prime.nix + ../../../common/gpu/nvidia/ada-lovelace + ]; + + config = { + # Configure basic system settings: + boot = { + kernelPackages = mkDefault pkgs.linuxPackages_latest; + kernelModules = [ "kvm-amd" ]; + kernelParams = [ + "mem_sleep_default=deep" + "pcie_aspm.policy=powersupersave" + ]; + }; + + services = { + asusd = { + enable = mkDefault true; + enableUserService = mkDefault true; + }; + + supergfxd.enable = mkDefault true; + }; + + # Enable the Nvidia card, as well as Prime and Offload: NVIDIA GeForce RTX 4060 Mobile + boot.blacklistedKernelModules = [ "nouveau" ]; + + services.xserver.videoDrivers = mkForce [ + "amdgpu" + "nvidia" + ]; + + hardware = { + amdgpu.initrd.enable = mkDefault true; + + nvidia = { + modesetting.enable = true; + nvidiaSettings = mkDefault true; + + prime = { + offload = { + enable = mkDefault true; + enableOffloadCmd = mkDefault true; + }; + amdgpuBusId = "PCI:101:0:0"; + nvidiaBusId = "PCI:1:0:0"; + }; + + powerManagement = { + enable = true; + finegrained = true; + }; + }; + }; + # Meditek doesn't seem to be quite sensitive enough on the default roaming settings: + # https://wiki.archlinux.org/title/Wpa_supplicant#Roaming + # https://wiki.archlinux.org/title/Iwd#iwd_keeps_roaming + # + # But NixOS doesn't have the tweaks for IWD, yet. + networking.wireless.iwd.settings = + lib.mkIf (config.networking.wireless.iwd.enable && config.networking.wireless.scanOnLowSignal) + { + General = { + RoamThreshold = -75; + RoamThreshold5G = -80; + RoamRetryInterval = 20; + }; + }; + }; +} diff --git a/flake.nix b/flake.nix index 44bedb0a0..446f5df0d 100644 --- a/flake.nix +++ b/flake.nix @@ -45,6 +45,7 @@ asus-zephyrus-ga402x = import ./asus/zephyrus/ga402x; asus-zephyrus-ga402x-amdgpu = import ./asus/zephyrus/ga402x/amdgpu; asus-zephyrus-ga402x-nvidia = import ./asus/zephyrus/ga402x/nvidia; + asus-zephyrus-ga403 = import ./asus/zephyrus/ga403; asus-zephyrus-ga502 = import ./asus/zephyrus/ga502; asus-zephyrus-ga503 = import ./asus/zephyrus/ga503; asus-zephyrus-gu603h = import ./asus/zephyrus/gu603h; From 5198cf6ff8c235c78f7e655ee67dc675f9edb443 Mon Sep 17 00:00:00 2001 From: caleb Date: Tue, 3 Dec 2024 17:48:44 -0500 Subject: [PATCH 09/12] Fixed formatting error --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 143fe6a73..84261f8ee 100644 --- a/README.md +++ b/README.md @@ -101,7 +101,7 @@ See code for all available configurations. | [Asus ROG Zephyrus G14 GA402](asus/zephyrus/ga402) | `` | | [Asus ROG Zephyrus G14 GA402X\* (2023)](asus/zephyrus/ga402x/amdgpu) | `` | | [Asus ROG Zephyrus G14 GA402X\* (2023)](asus/zephyrus/ga402x/nvidia) | `` | -| [Asus ROG Zephyrus G14 GA403 (2024)](asus/zephyrus/ga403) | `` | +| [Asus ROG Zephyrus G14 GA403 (2024)](asus/zephyrus/ga403) | `` | | [Asus ROG Zephyrus G15 GA502](asus/zephyrus/ga502) | `` | | [Asus ROG Zephyrus G15 GA503](asus/zephyrus/ga503) | `` | | [Asus ROG Zephyrus G16 GU605MY](asus/zephyrus/gu605my) | `` | From 162f8ac135f6ddd28849dd1ca58571d94c6a6907 Mon Sep 17 00:00:00 2001 From: caleb Date: Tue, 3 Dec 2024 17:49:02 -0500 Subject: [PATCH 10/12] Removed per Mic92's suggestion --- asus/zephyrus/ga403/default.nix | 6 ------ 1 file changed, 6 deletions(-) diff --git a/asus/zephyrus/ga403/default.nix b/asus/zephyrus/ga403/default.nix index 032e67089..7ad96f9bc 100644 --- a/asus/zephyrus/ga403/default.nix +++ b/asus/zephyrus/ga403/default.nix @@ -69,12 +69,6 @@ in { }; } - (mkIf (versionOlder version "23.11") { - # See https://asus-linux.org/wiki/nixos/ for info about some problems - # detecting the dGPU: - systemd.services.supergfxd.path = [ pkgs.pciutils ]; - }) - (mkIf (config.networking.wireless.iwd.enable && config.networking.wireless.scanOnLowSignal) { # Meditek doesn't seem to be quite sensitive enough on the default roaming settings: # https://wiki.archlinux.org/title/Wpa_supplicant#Roaming From 328f218b589a8d152b937d4dfc49a310a3bdd3d0 Mon Sep 17 00:00:00 2001 From: caleb Date: Mon, 16 Dec 2024 09:26:43 -0500 Subject: [PATCH 11/12] removed acpi_call.nix --- asus/zephyrus/ga403/default.nix | 1 - 1 file changed, 1 deletion(-) diff --git a/asus/zephyrus/ga403/default.nix b/asus/zephyrus/ga403/default.nix index d3c36ff57..215b224ab 100644 --- a/asus/zephyrus/ga403/default.nix +++ b/asus/zephyrus/ga403/default.nix @@ -18,7 +18,6 @@ in ../../../common/cpu/amd/pstate.nix ../../../common/gpu/amd ../../../common/pc/laptop - ../../../common/pc/laptop/acpi_call.nix ../../../common/pc/ssd ../../../common/gpu/nvidia/prime.nix ../../../common/gpu/nvidia/ada-lovelace From 64bb927d282e67f9b37be2b5c1bd8ce3b73178d2 Mon Sep 17 00:00:00 2001 From: caleb Date: Wed, 18 Dec 2024 00:15:43 -0500 Subject: [PATCH 12/12] added note about kernel version --- asus/zephyrus/ga403/default.nix | 2 ++ 1 file changed, 2 insertions(+) diff --git a/asus/zephyrus/ga403/default.nix b/asus/zephyrus/ga403/default.nix index 215b224ab..f6d101b01 100644 --- a/asus/zephyrus/ga403/default.nix +++ b/asus/zephyrus/ga403/default.nix @@ -26,6 +26,8 @@ in config = { # Configure basic system settings: boot = { + # Note: it seems being on the latest kernel is important for CPPC to work, which is required for the amd_pstate + # https://bugzilla.kernel.org/show_bug.cgi?id=218686 kernelPackages = mkDefault pkgs.linuxPackages_latest; kernelModules = [ "kvm-amd" ]; kernelParams = [