dumpyourvms: fix AMD gpu power saving systemd unit
All checks were successful
continuous-integration/drone/push Build is passing

Clean up unused services mozilla-vpn and unbound

Clean up comments
This commit is contained in:
teutat3s 2023-05-13 18:48:43 +02:00
parent 90e1fe7e6f
commit ca2a5fbbda
Signed by: teutat3s
GPG key ID: 4FA1D3FA524F22C1

View file

@ -66,32 +66,28 @@ in {
MulticastDNS=no MulticastDNS=no
''; '';
}; };
services.mozillavpn.enable = true;
networking = import ./networking.nix; networking = import ./networking.nix;
services.tailscale.enable = true; services.tailscale.enable = true;
security.pki.certificateFiles = [./consul-agent-ca.pem]; security.pki.certificateFiles = [./consul-agent-ca.pem];
services.unbound = import ./unbound.nix; # Disable bluetooth on startup to save battery
# Set default brightness to 50%
# 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"
]; ];
# 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://github.com/NixOS/nixpkgs/pull/33915
# https://ubuntuforums.org/showthread.php?t=2409856
systemd.services."amd-hybrid-graphics-power-save" = { 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"; description = "Power Off dedicated AMD Card to reduce power usage";
after = ["sys-kernel-debug.mount"]; after = ["graphical-session.target"];
before = ["systemd-vconsole-setup.service" "display-manager.service"];
requires = ["sys-kernel-debug.mount"]; requires = ["sys-kernel-debug.mount"];
serviceConfig = { serviceConfig = {
Type = "oneshot"; Type = "oneshot";
RemainAfterExit = true; 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'"; ExecStop = "${pkgs.bash}/bin/sh -c 'echo ON >/sys/kernel/debug/vgaswitcheroo/switch'";
}; };
wantedBy = ["multi-user.target"]; wantedBy = ["multi-user.target"];
@ -116,11 +112,13 @@ in {
# brcmfmac being loaded during hibernation would inhibit a successful resume # brcmfmac being loaded during hibernation would inhibit a successful resume
# https://bugzilla.kernel.org/show_bug.cgi?id=101681#c116. # https://bugzilla.kernel.org/show_bug.cgi?id=101681#c116.
# Also brcmfmac could randomly crash on resume from sleep. # 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. # to be powered on.
powerUpCommands = lib.mkBefore ("${pkgs.kmod}/bin/modprobe brcmfmac" powerUpCommands = lib.mkBefore (
"${pkgs.kmod}/bin/modprobe brcmfmac"
+ lib.optionalString + 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 ( powerDownCommands = lib.mkBefore (
lib.optionalString lib.optionalString
(lib.versionAtLeast config.boot.kernelPackages.kernel.version "6.2") (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 ${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 # Change lid switch behaviour
@ -166,10 +167,6 @@ in {
}; };
}; };
users.users.teutat3s = {
extraGroups = ["unbound"];
};
# WLAN frequency compliance (e.g. check for radar with DFS) # WLAN frequency compliance (e.g. check for radar with DFS)
hardware.firmware = with pkgs; [wireless-regdb]; hardware.firmware = with pkgs; [wireless-regdb];
boot.extraModprobeConfig = '' boot.extraModprobeConfig = ''