2023-11-14 19:00:13 +01:00
|
|
|
{ config, pkgs, ... }:
|
|
|
|
let
|
|
|
|
my-python-packages = ps: with ps; [
|
|
|
|
# de-p1st-monitor is not (yet) packaged, thus we build it from PyPI
|
|
|
|
(
|
|
|
|
buildPythonPackage rec {
|
|
|
|
pname = "de.p1st.monitor";
|
2023-11-14 19:17:48 +01:00
|
|
|
version = "0.11.3";
|
2023-11-14 19:00:13 +01:00
|
|
|
# https://nixos.wiki/wiki/Packaging/Python#Fix_Missing_setup.py
|
|
|
|
format = "pyproject";
|
|
|
|
src = fetchPypi {
|
|
|
|
inherit pname version;
|
2023-11-14 19:17:48 +01:00
|
|
|
sha256 = "sha256-uzMmZoh/eCqbsTKDnm0oQ0sD8HvCprAncIuAawzpWu8=";
|
2023-11-14 19:00:13 +01:00
|
|
|
};
|
|
|
|
propagatedBuildInputs = [
|
|
|
|
# Dependencies
|
|
|
|
pkgs.python3Packages.psutil
|
|
|
|
# Build dependencies
|
|
|
|
build
|
|
|
|
twine
|
|
|
|
];
|
|
|
|
}
|
|
|
|
)
|
|
|
|
];
|
|
|
|
in
|
|
|
|
{
|
|
|
|
# Install de.p1st.monitor packages.
|
|
|
|
environment.systemPackages = [
|
|
|
|
(pkgs.python3.withPackages my-python-packages)
|
|
|
|
# Dependency of de.p1st.monitor.
|
|
|
|
pkgs.smartmontools
|
|
|
|
];
|
|
|
|
# Dependency of de.p1st.monitor
|
|
|
|
boot.kernelModules = [ "drivetemp" ];
|
|
|
|
|
|
|
|
# Create de.p1st.monitor timer.
|
|
|
|
systemd.timers."de.p1st.monitor" = {
|
|
|
|
wantedBy = [ "timers.target" ];
|
|
|
|
partOf = [ "de.p1st.monitor.service" ];
|
|
|
|
timerConfig = {
|
|
|
|
OnBootSec = "0m";
|
|
|
|
OnUnitInactiveSec = "3m";
|
|
|
|
|
|
|
|
AccuracySec = "15s";
|
|
|
|
RandomizedDelaySec = "15s";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
systemd.services."de.p1st.monitor" = {
|
|
|
|
serviceConfig = {
|
|
|
|
Type = "oneshot";
|
|
|
|
PrivateTmp = true;
|
|
|
|
# `smartctl` requires root to access /dev/* devices and read their temperatures.
|
|
|
|
User = "root";
|
|
|
|
Nice = 19;
|
|
|
|
IOSchedulingClass = "idle";
|
|
|
|
ExecStart = "${pkgs.python3.withPackages my-python-packages}/bin/de-p1st-monitor";
|
|
|
|
};
|
|
|
|
path = with pkgs; [
|
|
|
|
# Provides `findmnt` binary.
|
|
|
|
libuuid
|
|
|
|
smartmontools
|
|
|
|
];
|
|
|
|
};
|
|
|
|
}
|