feat(goliath): refactor, make fans sane

This commit is contained in:
Kat Inskip 2024-01-26 15:32:38 -08:00
parent 67f6cccf47
commit 69d4363c8c
Signed by: kat
GPG key ID: 465E64DECEA8CF0F
18 changed files with 178 additions and 335 deletions

215
flake.lock generated
View file

@ -17,61 +17,6 @@
"type": "github"
}
},
"artemiscli": {
"inputs": {
"artemiscore": [
"artemiscore"
],
"flake-utils": [
"utils"
],
"nixpkgs": [
"nixpkgs"
],
"poetry2nix": "poetry2nix",
"std": [
"std"
]
},
"locked": {
"lastModified": 1693677435,
"narHash": "sha256-Vs3NQ3JnCEkg7QFXKcJZ/p8YImV3FNyYXw0K6kYJn2M=",
"ref": "refs/heads/main",
"rev": "301c1544b5d7eca590df277eefc3ffb14ad1427d",
"revCount": 175,
"type": "git",
"url": "ssh://git@github.com/Glamorous-ai/metaflow-cli-plugin.git"
},
"original": {
"type": "git",
"url": "ssh://git@github.com/Glamorous-ai/metaflow-cli-plugin.git"
}
},
"artemiscore": {
"inputs": {
"flake-utils": [
"utils"
],
"nixpkgs": [
"nixpkgs"
],
"poetry2nix": "poetry2nix_2"
},
"locked": {
"lastModified": 1695031434,
"narHash": "sha256-mAcZz0n0cORv+WHnCbLfAhB2RrLNgSThuw70GBuyFHk=",
"ref": "develop",
"rev": "717b0a497bc8027d540a46e5ad0ac260c1b3660c",
"revCount": 113,
"type": "git",
"url": "ssh://git@github.com/Glamorous-ai/metaflow-core-plugin.git"
},
"original": {
"ref": "develop",
"type": "git",
"url": "ssh://git@github.com/Glamorous-ai/metaflow-core-plugin.git"
}
},
"base16": {
"inputs": {
"flakelib": "flakelib",
@ -230,42 +175,6 @@
"type": "github"
}
},
"flake-utils": {
"inputs": {
"systems": "systems"
},
"locked": {
"lastModified": 1689068808,
"narHash": "sha256-6ixXo3wt24N/melDWjq70UuHQLxGV8jZvooRanIHXw0=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "919d646de7be200f3bf08cb76ae1f09402b6f9b4",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "flake-utils",
"type": "github"
}
},
"flake-utils_2": {
"inputs": {
"systems": "systems_2"
},
"locked": {
"lastModified": 1689068808,
"narHash": "sha256-6ixXo3wt24N/melDWjq70UuHQLxGV8jZvooRanIHXw0=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "919d646de7be200f3bf08cb76ae1f09402b6f9b4",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "flake-utils",
"type": "github"
}
},
"flakelib": {
"inputs": {
"fl-config": "fl-config",
@ -400,50 +309,6 @@
"type": "github"
}
},
"nix-github-actions": {
"inputs": {
"nixpkgs": [
"artemiscli",
"poetry2nix",
"nixpkgs"
]
},
"locked": {
"lastModified": 1688870561,
"narHash": "sha256-4UYkifnPEw1nAzqqPOTL2MvWtm3sNGw1UTYTalkTcGY=",
"owner": "nix-community",
"repo": "nix-github-actions",
"rev": "165b1650b753316aa7f1787f3005a8d2da0f5301",
"type": "github"
},
"original": {
"owner": "nix-community",
"repo": "nix-github-actions",
"type": "github"
}
},
"nix-github-actions_2": {
"inputs": {
"nixpkgs": [
"artemiscore",
"poetry2nix",
"nixpkgs"
]
},
"locked": {
"lastModified": 1688870561,
"narHash": "sha256-4UYkifnPEw1nAzqqPOTL2MvWtm3sNGw1UTYTalkTcGY=",
"owner": "nix-community",
"repo": "nix-github-actions",
"rev": "165b1650b753316aa7f1787f3005a8d2da0f5301",
"type": "github"
},
"original": {
"owner": "nix-community",
"repo": "nix-github-actions",
"type": "github"
}
},
"nix-index-database": {
"inputs": {
"nixpkgs": [
@ -564,52 +429,6 @@
"type": "github"
}
},
"poetry2nix": {
"inputs": {
"flake-utils": "flake-utils",
"nix-github-actions": "nix-github-actions",
"nixpkgs": [
"artemiscli",
"nixpkgs"
]
},
"locked": {
"lastModified": 1689512738,
"narHash": "sha256-p2hKM6WYl4dJ6C6qmf8kct2PYJRNii3eAoRUhWjkGdU=",
"owner": "nix-community",
"repo": "poetry2nix",
"rev": "e7a88dfc2c5aa0c660a3ec4661a695c1c2380a8a",
"type": "github"
},
"original": {
"owner": "nix-community",
"repo": "poetry2nix",
"type": "github"
}
},
"poetry2nix_2": {
"inputs": {
"flake-utils": "flake-utils_2",
"nix-github-actions": "nix-github-actions_2",
"nixpkgs": [
"artemiscore",
"nixpkgs"
]
},
"locked": {
"lastModified": 1689512738,
"narHash": "sha256-p2hKM6WYl4dJ6C6qmf8kct2PYJRNii3eAoRUhWjkGdU=",
"owner": "nix-community",
"repo": "poetry2nix",
"rev": "e7a88dfc2c5aa0c660a3ec4661a695c1c2380a8a",
"type": "github"
},
"original": {
"owner": "nix-community",
"repo": "poetry2nix",
"type": "github"
}
},
"pypi-deps-db": {
"flake": false,
"locked": {
@ -629,8 +448,6 @@
"root": {
"inputs": {
"arcexprs": "arcexprs",
"artemiscli": "artemiscli",
"artemiscore": "artemiscore",
"base16": "base16",
"base16-data": "base16-data",
"darwin": "darwin",
@ -789,36 +606,6 @@
"type": "github"
}
},
"systems_2": {
"locked": {
"lastModified": 1681028828,
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
"owner": "nix-systems",
"repo": "default",
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
"type": "github"
},
"original": {
"owner": "nix-systems",
"repo": "default",
"type": "github"
}
},
"systems_3": {
"locked": {
"lastModified": 1681028828,
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
"owner": "nix-systems",
"repo": "default",
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
"type": "github"
},
"original": {
"owner": "nix-systems",
"repo": "default",
"type": "github"
}
},
"tree": {
"inputs": {
"nixpkgs": [
@ -844,7 +631,7 @@
},
"utils": {
"inputs": {
"systems": "systems_3"
"systems": "systems"
},
"locked": {
"lastModified": 1701680307,

View file

@ -139,23 +139,6 @@
home-manager.follows = "home-manager";
};
};
# work
artemiscore = {
url = "git+ssh://git@github.com/Glamorous-ai/metaflow-core-plugin.git?ref=develop";
inputs = {
flake-utils.follows = "utils";
nixpkgs.follows = "nixpkgs";
};
};
artemiscli = {
url = "git+ssh://git@github.com/Glamorous-ai/metaflow-cli-plugin.git";
inputs = {
artemiscore.follows = "artemiscore";
flake-utils.follows = "utils";
nixpkgs.follows = "nixpkgs";
std.follows = "std";
};
};
};
outputs = inputs: import ./outputs.nix {inherit inputs;};
}

View file

@ -4,7 +4,6 @@
inputs,
...
}: let
inherit (lib.modules) mkMerge;
inherit (inputs.base16-data.lib.base16-data) schemeSources;
in {
base16 = {

View file

@ -9,6 +9,7 @@
kubectl # kubectl
k9s # cute k8s client, canines~
kubernetes-helm # k8s package manager
kustomize # config management and patching, ...
# AWS

View file

@ -1,15 +0,0 @@
{lib, ...}: let
inherit (lib.options) mkOption;
inherit (lib.types) enum;
in {
options.machine = {
cpuVendor = mkOption {
type = enum [
"intel"
"amd"
"apple"
];
description = "CPU vendor";
};
};
}

View file

@ -0,0 +1,10 @@
{
config,
lib,
...
}: let
inherit (lib.modules) mkDefault;
in {
boot.kernelModules = ["kvm-amd"];
hardware.cpu.amd.updateMicrocode = mkDefault config.hardware.enableRedistributableFirmware;
}

View file

@ -0,0 +1,5 @@
_: {
boot.kernelParams = [
"amdgpu.gpu_recovery=1"
];
}

View file

@ -0,0 +1,91 @@
{pkgs, ...}: {
systemd.services.fanSetup = let
# https://github.com/arcnmx/home/blob/9eb1cd4dd43883e1a0c6a2a55c00d7c3bede1776/hw/x370gpc/default.nix#L80 <3
nct = "/sys/devices/platform/nct6775.656/hwmon/hwmon*/";
# https://www.kernel.org/doc/html/next/hwmon/nct6775.html
#nct = ".//.//.sys.devices.platform.nct6775/656.hwmon.hwmon0";
# take in celcius, turn it into millicelcius
tempIn = x: toString (x * 1000);
# take in a percentage, turn it into a number between 0 and 255
pwmIn = x: toString (x * 255 / 100);
pwmEnable = {
maximum = 0;
manual = 1;
thermalCruise = 2;
speedCruise = 3;
# smart_fan_3 = 4;
smart_fan = 5;
};
cpu_sensor = 2;
mobo_sensor = 3;
cpu_temp = "temp${toString cpu_sensor}";
mobo_temp = "temp${toString mobo_sensor}";
exhaust = "pwm1";
intake = "pwm3";
temps = {
cpu = {
max = 80;
max_hyst = 75;
};
mobo = {
max = 50;
max_hyst = 45;
};
};
fanScript = pkgs.writeShellScriptBin "fan" ''
cd ${nct}
echo "${toString temps.cpu.max}" > ${cpu_temp}_max
echo "${toString temps.cpu.max_hyst}" > ${cpu_temp}_max_hyst
echo "${toString temps.mobo.max}" > ${mobo_temp}_max
echo "${toString temps.mobo.max_hyst}" > ${mobo_temp}_max_hyst
# Rear and Top Exhaust
echo "${toString pwmEnable.smart_fan}" > ${exhaust}_enable
echo "${toString mobo_sensor}" > ${exhaust}_temp_sel
echo "${tempIn 35}" > ${exhaust}_auto_point1_temp
echo "${pwmIn 10}" > ${exhaust}_auto_point1_pwm
echo "${tempIn 40}" > ${exhaust}_auto_point2_temp
echo "${pwmIn 20}" > ${exhaust}_auto_point2_pwm
echo "${tempIn 45}" > ${exhaust}_auto_point3_temp
echo "${pwmIn 50}" > ${exhaust}_auto_point3_pwm
echo "${tempIn 50}" > ${exhaust}_auto_point4_temp
echo "${pwmIn 75}" > ${exhaust}_auto_point4_pwm
echo "${tempIn 55}" > ${exhaust}_auto_point5_temp
echo "${pwmIn 100}" > ${exhaust}_auto_point5_pwm
# Bottom Intake
echo "${toString pwmEnable.smart_fan}" > ${intake}_enable
echo "${toString mobo_sensor}" > ${intake}_temp_sel
echo "${tempIn 35}" > ${intake}_auto_point1_temp
echo "${pwmIn 10}" > ${intake}_auto_point1_pwm
echo "${tempIn 40}" > ${intake}_auto_point2_temp
echo "${pwmIn 20}" > ${intake}_auto_point2_pwm
echo "${tempIn 45}" > ${intake}_auto_point3_temp
echo "${pwmIn 50}" > ${intake}_auto_point3_pwm
echo "${tempIn 50}" > ${intake}_auto_point4_temp
echo "${pwmIn 75}" > ${intake}_auto_point4_pwm
echo "${tempIn 55}" > ${intake}_auto_point5_temp
echo "${pwmIn 100}" > ${intake}_auto_point5_pwm
# CLC
${pkgs.liquidctl}/bin/liquidctl --match clc set fan speed 20 0 30 0 40 10 50 50 60 75 70 100
'';
in {
wantedBy = ["multi-user.target"];
description = "Set up the fan speeds for the system";
after = ["systemd-modules-load.service"];
serviceConfig = {
Type = "oneshot";
ExecStart = "${fanScript}/bin/fan";
};
};
}

View file

@ -1,11 +0,0 @@
{
config,
lib,
...
}: let
inherit (lib.modules) mkIf;
in {
config = mkIf (config.machine.cpuVendor == "intel") {
boot.kernelModules = ["kvm-intel"];
};
}

View file

@ -0,0 +1,5 @@
_: let
in {
boot.kernelModules = ["kvm-intel"];
services.thermald.enable = true;
}

13
nixos/hardware/uefi.nix Normal file
View file

@ -0,0 +1,13 @@
_: {
boot.loader = {
grub = {
devices = ["nodev"];
efiSupport = true;
gfxmodeEfi = "1920x1080";
};
efi = {
canTouchEfiVariables = true;
efiSysMountPoint = "/boot";
};
};
}

View file

@ -1,8 +1,9 @@
_: {
boot.loader = {
timeout = -1;
timeout = null;
grub = {
# theme = pkgs.nixos-grub2-theme; # so like, this turbo-breaks the fuck out of GRUB, i have no clue why?
enable = true;
useOSProber = true;
splashImage = ./splash.jpg;
extraConfig = ''
set color_normal=black/black

View file

@ -8,6 +8,7 @@
dnsutils
firefox
usbutils
plexamp
inputs.konawall-py.packages.${pkgs.system}.konawall-py
];
services.udev.packages = [

View file

@ -1,11 +0,0 @@
{
config,
lib,
...
}: let
inherit (lib.modules) mkIf;
in {
config = mkIf (config.machine.cpuVendor == "intel") {
services.thermald.enable = true;
};
}

View file

@ -6,10 +6,40 @@ _: let
pkgs,
...
}: let
inherit (lib.modules) mkDefault;
inherit (lib.lists) singleton;
drives = {
root = {
raw = "/dev/disk/by-uuid/af144e7f-e35b-49e7-be90-ef7001cc2abd";
luks = "luks-af144e7f-e35b-49e7-be90-ef7001cc2abd";
result = {
device = "/dev/disk/by-uuid/cf7fc410-4e27-4797-8464-a409766928c1";
fsType = "ext4";
};
};
boot = rec {
raw = "/dev/disk/by-uuid/D0D8-F8BF";
result = {
device = raw;
fsType = "vfat";
};
};
swap = {
raw = "/dev/disk/by-uuid/111c4857-5d73-4e75-89c7-43be9b044ade";
luks = "luks-111c4857-5d73-4e75-89c7-43be9b044ade";
result = {
device = "/dev/disk/by-uuid/bebdb14c-4707-4e05-848f-5867764b7c27";
};
};
};
in {
imports =
(with tree.nixos.profiles; [
(with tree.nixos.hardware; [
amd_cpu
amd_gpu
b550m-itx-ac
uefi
])
++ (with tree.nixos.profiles; [
graphical
wireless
gaming
@ -27,72 +57,37 @@ _: let
kde
]);
machine = {
cpuVendor = "amd";
};
# to-do: add this and kvm-amd to automation
hardware.cpu.amd.updateMicrocode = mkDefault config.hardware.enableRedistributableFirmware;
environment.systemPackages = with pkgs; [
fd # fd, better fine!
ripgrep # rg, better grep!
deadnix # dead-code scanner
alejandra # code formatter
statix # anti-pattern finder
deploy-rs.deploy-rs # deployment system
rnix-lsp # vscode nix extensions
terraform # terraform
kubectl
k9s
];
boot = {
loader = {
grub = {
enable = true;
efiSupport = true;
devices = ["nodev"];
enableCryptodisk = true;
useOSProber = true;
gfxmodeBios = "1920x1080";
gfxmodeEfi = "1920x1080";
};
efi = {
canTouchEfiVariables = true;
efiSysMountPoint = "/boot";
};
};
# Enable swap on luks
initrd = {
luks.devices = {
"luks-111c4857-5d73-4e75-89c7-43be9b044ade".device = "/dev/disk/by-uuid/111c4857-5d73-4e75-89c7-43be9b044ade";
"luks-111c4857-5d73-4e75-89c7-43be9b044ade".keyFile = "/crypto_keyfile.bin";
"luks-af144e7f-e35b-49e7-be90-ef7001cc2abd".device = "/dev/disk/by-uuid/af144e7f-e35b-49e7-be90-ef7001cc2abd";
${drives.swap.luks} = {
device = drives.swap.raw;
keyFile = "/crypto_keyfile.bin";
};
availableKernelModules = ["nvme" "xhci_pci" "ahci" "usb_storage" "usbhid" "sd_mod"];
${drives.root.luks}.device = drives.root.raw;
};
#
secrets = {
"/crypto_keyfile.bin" = null;
};
availableKernelModules = ["nvme" "xhci_pci" "ahci" "usb_storage" "usbhid" "sd_mod"];
};
kernelParams = [
"amdgpu.gpu_recovery=1"
];
kernelModules = ["kvm-amd"];
kernelModules = ["nct6775"];
supportedFilesystems = ["ntfs"];
};
fileSystems = {
"/" = {
device = "/dev/disk/by-uuid/cf7fc410-4e27-4797-8464-a409766928c1";
fsType = "ext4";
};
"/boot" = {
device = "/dev/disk/by-uuid/D0D8-F8BF";
fsType = "vfat";
};
"/" = drives.root.result;
"/boot" = drives.boot.result;
};
swapDevices = singleton drives.swap.result;
services.openssh = {
hostKeys = [
{
@ -111,15 +106,6 @@ _: let
'';
};
swapDevices = [
{device = "/dev/disk/by-uuid/bebdb14c-4707-4e05-848f-5867764b7c27";}
];
networking = {
hostId = "dddbb888";
useDHCP = false;
};
system.stateVersion = "21.11";
};
in {

View file

@ -25,7 +25,6 @@ _: let
boot.kernelPackages = pkgs.linuxPackages_6_3;
environment.systemPackages = with pkgs; [
inputs.artemiscli.packages.aarch64-linux.artemiscli
awscli2
kubectl
];

View file

@ -1,9 +1,5 @@
_: let
hostConfig = {
tree,
pkgs,
...
}: {
hostConfig = {tree, ...}: {
imports = with tree.darwin; [
orbstack
packages

View file

@ -64,6 +64,9 @@
"nixos/hardware" = {
external = inputs.nixos-hardware.outputs.nixosModules;
};
"nixos/hardware/conditional" = {
functor.enable = true;
};
"modules/nixos" = {
functor = {
enable = true;