2024-12-18 09:40:11 +03:00
|
|
|
{ __findFile, pkgs, ... }:
|
|
|
|
let
|
|
|
|
wm2fc = pkgs.callPackage <package/wm2fc> { };
|
|
|
|
in
|
2024-12-11 07:30:56 +03:00
|
|
|
{
|
2024-12-18 09:40:11 +03:00
|
|
|
# hardware.cpu.amd.ryzen-smu.enable = true;
|
2024-12-11 09:41:25 +03:00
|
|
|
|
2024-12-18 09:40:11 +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
|
|
|
|
# radg [TEMP]
|
|
|
|
ryzenadj
|
2024-12-11 07:30:56 +03:00
|
|
|
|
2024-12-18 09:40:11 +03:00
|
|
|
# SRC: https://github.com/nbfc-linux/nbfc-linux
|
|
|
|
nbfc-linux
|
2024-12-16 14:47:47 +03:00
|
|
|
|
2024-12-18 09:40:11 +03:00
|
|
|
wm2fc
|
|
|
|
];
|
2024-12-11 10:39:21 +03:00
|
|
|
|
2024-12-18 09:40:11 +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 = ''
|
|
|
|
ryzenadj --tctl-temp=55
|
|
|
|
while true; do
|
|
|
|
sleep 60
|
|
|
|
ryzenadj --tctl-temp=55 &> /dev/null
|
|
|
|
done
|
|
|
|
'';
|
|
|
|
};
|
2024-12-16 14:47:47 +03:00
|
|
|
|
2024-12-18 09:40:11 +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
|
|
|
|
];
|
|
|
|
script = ''
|
2024-12-20 08:03:46 +03:00
|
|
|
old=-1
|
|
|
|
oldtemp=-1
|
2024-12-18 09:40:11 +03:00
|
|
|
smooth=0
|
|
|
|
while true; do
|
|
|
|
temp=$(cat /sys/devices/pci0000\:00/0000\:00\:18.3/hwmon/*/temp1_input)
|
|
|
|
value=0
|
2024-12-16 14:47:47 +03:00
|
|
|
|
2024-12-18 09:40:11 +03:00
|
|
|
if [ $temp -gt 80000 ]
|
|
|
|
then value=184
|
|
|
|
elif [ $temp -gt 70000 ]
|
|
|
|
then value=128
|
|
|
|
elif [ $temp -gt 60000 ]
|
|
|
|
then value=92
|
2024-12-19 06:36:39 +03:00
|
|
|
elif [ $temp -gt 55000 ]
|
2024-12-20 08:18:59 +03:00
|
|
|
then value=52
|
2024-12-18 09:40:11 +03:00
|
|
|
elif [ $temp -gt 45000 ]
|
|
|
|
then value=46
|
|
|
|
elif [ $temp -gt 40000 ]
|
|
|
|
then value=23
|
|
|
|
else value=0
|
|
|
|
fi
|
2024-12-16 14:47:47 +03:00
|
|
|
|
2024-12-18 09:40:11 +03:00
|
|
|
if [[ $old != $value ]]; then
|
2024-12-19 06:36:39 +03:00
|
|
|
# 30 = 60s smooth. -5 degrees smooth.
|
2024-12-18 09:40:11 +03:00
|
|
|
if [[ $value -lt $old ]] && [[ $smooth -lt 30 ]]; then
|
2024-12-19 06:36:39 +03:00
|
|
|
if [[ $temp -lt $((oldtemp - 5000)) ]]; then
|
|
|
|
smooth=$((smooth+1))
|
|
|
|
fi
|
2024-12-18 09:40:11 +03:00
|
|
|
else
|
|
|
|
old=$value
|
2024-12-19 06:36:39 +03:00
|
|
|
oldtemp=$temp
|
2024-12-18 09:40:11 +03:00
|
|
|
smooth=0
|
|
|
|
wm2fc $value
|
|
|
|
fi
|
|
|
|
else
|
|
|
|
smooth=0
|
|
|
|
fi
|
2024-12-17 12:21:16 +03:00
|
|
|
|
2024-12-18 09:40:11 +03:00
|
|
|
sleep 2
|
|
|
|
done
|
|
|
|
'';
|
|
|
|
};
|
2024-12-16 14:47:47 +03:00
|
|
|
|
2024-12-18 09:40:11 +03:00
|
|
|
# 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
|
|
|
}
|