dumpyourvms: use systemd for disabling 2nd gpu,

hibernate when closing the lid, cleanup comments
This commit is contained in:
teutat3s 2023-03-16 11:50:35 +01:00
parent e9895dd7f7
commit fe2a196641
Signed by: teutat3s
GPG key ID: 4FA1D3FA524F22C1

View file

@ -30,13 +30,18 @@ in {
virtualisation.enable = true; virtualisation.enable = true;
}; };
# fix backlight for keyboard and brightness, adjust function key binding, # Fix backlight for keyboard and brightness, adjust function key binding,
# intel_pstate for cpu schedutil, resume offset for swapfile, disable amdgpu driver # intel_pstate for cpu schedutil
# For now, the radeon driver seems to work better than amdgpu with Radeon R9 M370X
# Explicitly set amdgpu support in place of radeon
# Source: https://github.com/NixOS/nixos-hardware/blob/master/common/gpu/amd/southern-islands/default.nix
# Try again after https://lists.freedesktop.org/archives/amd-gfx/2023-March/090096.html lands
# Maybe linux kernel 6.3?
#boot.kernelParams = ["acpi_backlight=video" "hid_apple.fnmode=2" "intel_pstate=passive" "radeon.si_support=0" "amdgpu.si_support=1"];
boot.kernelParams = ["acpi_backlight=video" "hid_apple.fnmode=2" "intel_pstate=passive"]; boot.kernelParams = ["acpi_backlight=video" "hid_apple.fnmode=2" "intel_pstate=passive"];
boot.loader.efi.canTouchEfiVariables = true; boot.loader.efi.canTouchEfiVariables = true;
#boot.resumeDevice = "/dev/mapper/cryptroot";
# fix for Error switching console mode to 1: unsupported on startup # Fix for Error switching console mode to 1: unsupported on startup
boot.loader.systemd-boot.consoleMode = mkForce "0"; boot.loader.systemd-boot.consoleMode = mkForce "0";
boot.binfmt.emulatedSystems = ["aarch64-linux"]; boot.binfmt.emulatedSystems = ["aarch64-linux"];
@ -70,15 +75,36 @@ in {
services.unbound = import ./unbound.nix; services.unbound = import ./unbound.nix;
# Disable dedicated GPU, use integrated Intel GPU to save battery
# Set default brightness to 50% # Set default brightness to 50%
# https://ubuntuforums.org/showthread.php?t=2409856 # https://ubuntuforums.org/showthread.php?t=2409856
services.cron.systemCronJobs = [ services.cron.systemCronJobs = [
"@reboot root ${pkgs.util-linux}/bin/rfkill block bluetooth" "@reboot root ${pkgs.util-linux}/bin/rfkill block bluetooth"
"@reboot root ${pkgs.coreutils}/bin/sleep 10; ${pkgs.coreutils}/bin/echo OFF > /sys/kernel/debug/vgaswitcheroo/switch"
"@reboot root ${pkgs.coreutils}/bin/sleep 11; ${pkgs.coreutils}/bin/echo 510 > /sys/class/backlight/gmux_backlight/brightness" "@reboot root ${pkgs.coreutils}/bin/sleep 11; ${pkgs.coreutils}/bin/echo 510 > /sys/class/backlight/gmux_backlight/brightness"
]; ];
# Disable dedicated GPU, use integrated Intel GPU to save battery
# https://github.com/NixOS/nixpkgs/pull/33915
systemd.services."amd-hybrid-graphics" = {
path = [pkgs.bash];
description = "Disable AMD Card";
after = ["sys-kernel-debug.mount"];
before = ["systemd-vconsole-setup.service" "display-manager.service"];
requires = ["sys-kernel-debug.mount" "vgaswitcheroo.path"];
serviceConfig = {
Type = "oneshot";
RemainAfterExit = true;
ExecStart = "${pkgs.bash}/bin/sh -c 'echo -e \"IGD\\nOFF\" > /sys/kernel/debug/vgaswitcheroo/switch'";
ExecStop = "${pkgs.bash}/bin/sh -c 'echo ON >/sys/kernel/debug/vgaswitcheroo/switch'";
};
};
systemd.paths."vgaswitcheroo" = {
pathConfig = {
PathExists = "/sys/kernel/debug/vgaswitcheroo/switch";
Unit = "amd-hybrid-graphics.service";
};
wantedBy = ["multi-user.target"];
};
# Increase console font size for HiDPI display # Increase console font size for HiDPI display
console = { console = {
earlySetup = true; earlySetup = true;
@ -102,8 +128,8 @@ in {
powerDownCommands = lib.mkBefore "${pkgs.kmod}/bin/rmmod brcmfmac"; powerDownCommands = lib.mkBefore "${pkgs.kmod}/bin/rmmod brcmfmac";
}; };
# change lid switch behaviour # Change lid switch behaviour
#services.logind.lidSwitch = "hibernate"; services.logind.lidSwitch = "hibernate";
# TLP for power management # TLP for power management
services.tlp = { services.tlp = {
@ -142,8 +168,6 @@ in {
}; };
# WLAN frequency compliance (e.g. check for radar with DFS) # WLAN frequency compliance (e.g. check for radar with DFS)
#
# Radeon driver seems to work better than amdgpu with Radeon R9 M370X
hardware.firmware = with pkgs; [wireless-regdb]; hardware.firmware = with pkgs; [wireless-regdb];
boot.extraModprobeConfig = '' boot.extraModprobeConfig = ''
options cfg80211 ieee80211_regdom="DE" options cfg80211 ieee80211_regdom="DE"