dumpyourvms: fix AMD gpu power saving systemd unit

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
'';
};
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 = ''