maxwell/hardware.nix
2024-08-02 19:26:13 +02:00

81 lines
2.0 KiB
Nix

{ config, lib, pkgs, ... }:
{
imports = [
<nixpkgs/nixos/modules/installer/scan/not-detected.nix>
];
boot.kernelModules = [ "kvm-intel" ];
boot.initrd.availableKernelModules = [
"uhci_hcd" "ehci_pci" "ata_piix"
"usbhid" "usb_storage" "sd_mod"
];
boot.loader.grub = {
enable = true;
device = "/dev/sda";
};
fileSystems."/" =
{ device = "/dev/main/nixos";
fsType = "ext4";
};
fileSystems."/home" =
{ device = "/dev/main/home";
fsType = "ext4";
};
fileSystems."/var/lib" =
{ device = "/dev/data/data";
fsType = "ext4";
};
powerManagement.cpuFreqGovernor = "ondemand";
services.apcupsd = {
enable = true;
configText = ''
UPSTYPE usb
UPSCABLE usb
NETSERVER on
MINUTES 5
'';
hooks =
let
# Send notifications when something bad happens
notify = msg: ''${pkgs.maxwell-notify}/bin/notify "UPS: ${msg}"'';
in
{
changeme = notify "replace batteries";
battdetach = notify "batteries disconnected";
battattach = notify "batteries reconnected";
commfailure = notify "connection lost";
commok = notify "connection enstablished";
loadlimit = notify "critical battery level (5%)";
runlimit = notify "critical battery life (5min)";
doshutdown = notify "shutting down!";
powerout = notify "main power is out";
mainsback = notify "main power is back";
onbattery = notify "batteries connected";
offbattery = notify "batteries disconnected";
emergency = notify "battery malfunction, possible shutdown!";
};
};
services.smartd =
let
# Send a notification when a disk is starting to fail
failHook = with pkgs; writeScript "disk-fail-hook" ''
#!/bin/sh
${pkgs.maxwell-notify}/bin/notify \
"SMART: rilevato problema al disco $SMARTD_DEVICESTRING:"
${pkgs.maxwell-notify}/bin/notify "> $SMARTD_MESSAGE"
'';
in
{
enable = true;
defaults.monitored = "-a -M exec ${failHook}";
};
}