From ca2a5fbbda7999b978686fbac8277bf9f0f219bb Mon Sep 17 00:00:00 2001 From: teutat3s Date: Sat, 13 May 2023 18:48:43 +0200 Subject: [PATCH] dumpyourvms: fix AMD gpu power saving systemd unit Clean up unused services mozilla-vpn and unbound Clean up comments --- hosts/dumpyourvms/dumpyourvms.nix | 31 ++++++++++++++----------------- 1 file changed, 14 insertions(+), 17 deletions(-) diff --git a/hosts/dumpyourvms/dumpyourvms.nix b/hosts/dumpyourvms/dumpyourvms.nix index aed265fa..93c0770b 100644 --- a/hosts/dumpyourvms/dumpyourvms.nix +++ b/hosts/dumpyourvms/dumpyourvms.nix @@ -66,32 +66,28 @@ in { MulticastDNS=no ''; }; - services.mozillavpn.enable = true; networking = import ./networking.nix; services.tailscale.enable = true; security.pki.certificateFiles = [./consul-agent-ca.pem]; - services.unbound = import ./unbound.nix; - - # Set default brightness to 50% - # https://ubuntuforums.org/showthread.php?t=2409856 + # Disable bluetooth on startup to save battery services.cron.systemCronJobs = [ "@reboot root ${pkgs.util-linux}/bin/rfkill block bluetooth" ]; - # Disable dedicated GPU, use integrated Intel GPU to save battery + # Power off dedicated GPU, use only integrated Intel GPU to save battery # https://github.com/NixOS/nixpkgs/pull/33915 + # https://ubuntuforums.org/showthread.php?t=2409856 systemd.services."amd-hybrid-graphics-power-save" = { - path = [pkgs.bash pkgs.coreutils]; + path = [pkgs.bash]; description = "Power Off dedicated AMD Card to reduce power usage"; - after = ["sys-kernel-debug.mount"]; - before = ["systemd-vconsole-setup.service" "display-manager.service"]; + after = ["graphical-session.target"]; requires = ["sys-kernel-debug.mount"]; serviceConfig = { Type = "oneshot"; RemainAfterExit = true; - ExecStart = "${pkgs.bash}/bin/sh -c 'sleep 8 && echo -e \"IGD\\nOFF\" > /sys/kernel/debug/vgaswitcheroo/switch'"; + 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'"; }; wantedBy = ["multi-user.target"]; @@ -116,11 +112,13 @@ in { # brcmfmac being loaded during hibernation would inhibit a successful resume # https://bugzilla.kernel.org/show_bug.cgi?id=101681#c116. # Also brcmfmac could randomly crash on resume from sleep. - # For hibernate successfully using the amdgpu driver, the dedicated GPU needs + # To hibernate successfully using the amdgpu driver, the dedicated GPU needs # to be powered on. - powerUpCommands = lib.mkBefore ("${pkgs.kmod}/bin/modprobe brcmfmac" + powerUpCommands = lib.mkBefore ( + "${pkgs.kmod}/bin/modprobe brcmfmac" + lib.optionalString - (lib.versionAtLeast config.boot.kernelPackages.kernel.version "6.2") " brcmfmac_wcc"); + (lib.versionAtLeast config.boot.kernelPackages.kernel.version "6.2") " brcmfmac_wcc" + ); powerDownCommands = lib.mkBefore ( lib.optionalString (lib.versionAtLeast config.boot.kernelPackages.kernel.version "6.2") @@ -130,6 +128,9 @@ in { ${pkgs.systemd}/bin/systemctl stop amd-hybrid-graphics-power-save.service '' ); + resumeCommands = '' + ${pkgs.systemd}/bin/systemctl start amd-hybrid-graphics-power-save.service + ''; }; # Change lid switch behaviour @@ -166,10 +167,6 @@ in { }; }; - users.users.teutat3s = { - extraGroups = ["unbound"]; - }; - # WLAN frequency compliance (e.g. check for radar with DFS) hardware.firmware = with pkgs; [wireless-regdb]; boot.extraModprobeConfig = ''