2023-01-29 07:19:17 +00:00
|
|
|
{ lib, stdenv, fetchFromGitHub, python3Packages, pciutils }:
|
2019-05-26 22:24:45 +00:00
|
|
|
|
|
|
|
stdenv.mkDerivation rec {
|
|
|
|
pname = "throttled";
|
2022-12-15 14:39:18 +00:00
|
|
|
version = "0.10.0";
|
2019-05-26 22:24:45 +00:00
|
|
|
|
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "erpalma";
|
|
|
|
repo = pname;
|
|
|
|
rev = "v${version}";
|
2022-12-15 14:39:18 +00:00
|
|
|
sha256 = "sha256-0MsPp6y4r/uZB2SplKV+SAiJoxIs2jgOQmQoQQ2ZKwI=";
|
2019-05-26 22:24:45 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
nativeBuildInputs = [ python3Packages.wrapPython ];
|
|
|
|
|
2020-02-21 05:39:41 +00:00
|
|
|
pythonPath = with python3Packages; [
|
2019-05-26 22:24:45 +00:00
|
|
|
configparser
|
|
|
|
dbus-python
|
|
|
|
pygobject3
|
|
|
|
];
|
|
|
|
|
2020-02-21 05:39:41 +00:00
|
|
|
# The upstream unit both assumes the install location, and tries to run in a virtualenv
|
2023-01-29 07:19:17 +00:00
|
|
|
postPatch = ''
|
|
|
|
sed -e 's|ExecStart=.*|ExecStart=${placeholder "out"}/bin/throttled.py|' -i systemd/throttled.service
|
|
|
|
|
|
|
|
substituteInPlace throttled.py --replace "'setpci'" "'${pciutils}/bin/setpci'"
|
|
|
|
'';
|
2019-05-26 22:24:45 +00:00
|
|
|
|
|
|
|
installPhase = ''
|
|
|
|
runHook preInstall
|
2022-12-15 14:39:18 +00:00
|
|
|
install -D -m755 -t $out/bin throttled.py
|
|
|
|
install -D -t $out/bin throttled.py mmio.py
|
2019-05-26 22:24:45 +00:00
|
|
|
install -D -m644 -t $out/etc etc/*
|
|
|
|
install -D -m644 -t $out/lib/systemd/system systemd/*
|
|
|
|
runHook postInstall
|
|
|
|
'';
|
|
|
|
|
2021-01-24 09:19:10 +00:00
|
|
|
postFixup = "wrapPythonPrograms";
|
2019-05-26 22:24:45 +00:00
|
|
|
|
2021-01-11 07:54:33 +00:00
|
|
|
meta = with lib; {
|
2019-05-26 22:24:45 +00:00
|
|
|
description = "Fix for Intel CPU throttling issues";
|
2020-04-01 01:11:51 +00:00
|
|
|
homepage = "https://github.com/erpalma/throttled";
|
2019-05-26 22:24:45 +00:00
|
|
|
license = licenses.mit;
|
|
|
|
platforms = [ "x86_64-linux" ];
|
|
|
|
maintainers = with maintainers; [ michaelpj ];
|
|
|
|
};
|
|
|
|
}
|