Merge pull request 'cpu-fix' (#21) from cpu-fix into main
All checks were successful
build / test (push) Successful in 11s

Reviewed-on: #21
This commit is contained in:
Mic92 2023-07-20 07:20:03 +00:00
commit 303f991c67
3 changed files with 14 additions and 20 deletions

View File

@ -2,6 +2,7 @@
flake.nixosModules = {
server.imports = [
inputs.srvos.nixosModules.server
inputs.srvos.nixosModules.mixins-telegraf
inputs.sops-nix.nixosModules.default
];

View File

@ -9,24 +9,5 @@
# We are not limited by zfs, so we can use the latest kernel
boot.kernelPackages = pkgs.linuxPackages_latest;
# looks like the Intel i9-13900 draws too much power and crashes the system
systemd.services.limit-cpu-freq = {
description = "Limit CPU frequency to 4.2GHz";
wantedBy = [ "multi-user.target" ];
after = [ "systemd-modules-load.service" ];
# Some cores do have a scaling max freq less than 5GHz, so we need to
# check for that or else all cores will run at 800MHz
script = ''
#!/bin/sh
for f in /sys/devices/system/cpu/cpu*/cpufreq/scaling_max_freq; do
old_val="$(<"$f")"
if [[ "$old_val" -gt 4200000 ]]; then
echo 4200000 > "$f"
fi
done
'';
serviceConfig = {
Type = "oneshot";
};
};
powerManagement.cpuFreqGovernor = "powersave";
}

12
targets/web01/reboot.sh Executable file
View File

@ -0,0 +1,12 @@
#!/usr/bin/env bash
HOST=clan.lol
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
ssh "root@$HOST" reboot
# wait till shutdown
while ping -4 -W 1 -c 1 "$HOST"; do
sleep 1
done
"$SCRIPT_DIR/decrypt.sh"