nix/host/x86_64-linux/max/Power.nix

90 lines
1.7 KiB
Nix
Raw Normal View History

2024-12-11 07:30:56 +03:00
{
2024-12-16 14:47:47 +03:00
__findFile,
2024-12-11 07:30:56 +03:00
pkgs,
...
2024-12-16 14:47:47 +03:00
}: let
wm2fc = pkgs.callPackage <package/wm2fc> {};
in {
2024-12-11 10:39:21 +03:00
# hardware.cpu.amd.ryzen-smu.enable = true;
2024-12-11 09:41:25 +03:00
2024-12-11 07:30:56 +03:00
environment.systemPackages = with pkgs; [
# SRC: https://github.com/FlyGoat/RyzenAdj
# ./ryzenadj --stapm-limit=45000 --fast-limit=45000 --slow-limit=45000 --tctl-temp=90
# ryzenAdj --info
2024-12-16 14:47:47 +03:00
# radg [TEMP]
2024-12-11 09:35:06 +03:00
ryzenadj
2024-12-11 07:30:56 +03:00
# SRC: https://github.com/nbfc-linux/nbfc-linux
nbfc-linux
2024-12-16 14:47:47 +03:00
wm2fc
2024-12-11 07:30:56 +03:00
];
2024-12-11 10:39:21 +03:00
systemd.services.radj = {
enable = true;
description = "Ryzen Adj temperature limiter.";
serviceConfig.Type = "simple";
wantedBy = [ "multi-user.target" ];
path = with pkgs; [
coreutils
ryzenadj
];
script = ''
2024-12-17 13:08:58 +03:00
ryzenadj --tctl-temp=50
2024-12-11 10:39:21 +03:00
while true; do
sleep 60
2024-12-17 13:08:58 +03:00
ryzenadj --tctl-temp=50 &> /dev/null
2024-12-11 10:39:21 +03:00
done
'';
};
2024-12-16 14:47:47 +03:00
systemd.services.fan = {
enable = true;
description = "The fan control";
wantedBy = [ "multi-user.target" ];
serviceConfig = {
ExecStop = "${wm2fc}/bin/wm2fc a";
Type = "simple";
};
path = with pkgs; [
coreutils
wm2fc
];
2024-12-17 13:08:58 +03:00
script = ''
old=0
2024-12-16 14:47:47 +03:00
while true; do
temp=$(cat /sys/devices/pci0000\:00/0000\:00\:18.3/hwmon/*/temp1_input)
value=0
2024-12-17 13:08:58 +03:00
if [ $temp -gt 80000 ]
2024-12-16 14:47:47 +03:00
then value=184
2024-12-17 13:08:58 +03:00
elif [ $temp -gt 70000 ]
then value=128
elif [ $temp -gt 60000 ]
2024-12-16 14:47:47 +03:00
then value=92
2024-12-17 16:07:04 +03:00
elif [ $temp -gt 50000 ]
2024-12-16 14:47:47 +03:00
then value=46
2024-12-17 13:08:58 +03:00
elif [ $temp -gt 45000 ]
2024-12-16 14:47:47 +03:00
then value=23
fi
if [[ $old != $value ]]; then
old=$value
printf "%s: %d\n" "New fan speed" $value
fi
wm2fc $value &> /dev/null
2024-12-16 14:47:47 +03:00
sleep 2
done
'';
};
# security.wrappers.wm2fc = {
# source = "${wm2fc}/bin/wm2fc";
# owner = "root";
# group = "root";
# setuid = true;
# permissions = "u+rx,g+x,o+x";
# };
2024-12-11 07:30:56 +03:00
}