auto-cpufreq/nix/default.nix

62 lines
1.9 KiB
Nix
Raw Normal View History

{ lib, python310Packages, fetchFromGitHub, callPackage, pkgs}:
2023-09-16 11:36:01 +02:00
python310Packages.buildPythonPackage rec {
# use pyproject.toml instead of setup.py
format = "pyproject";
2023-09-16 11:36:01 +02:00
pname = "auto-cpufreq";
version = "2.0.0dev";
2023-09-16 11:36:01 +02:00
src = ../.;
2023-09-16 11:36:01 +02:00
nativeBuildInputs = with pkgs; [ wrapGAppsHook gobject-introspection ];
buildInputs = with pkgs; [ gtk3 python310Packages.poetry-core ];
2023-09-16 11:36:01 +02:00
propagatedBuildInputs = with python310Packages; [ requests pygobject3 click distro psutil setuptools poetry-dynamic-versioning ];
2023-09-16 11:36:01 +02:00
doCheck = false;
pythonImportsCheck = [ "auto_cpufreq" ];
patches = [
# patch to prevent script copying and to disable install
./patches/prevent-install-and-copy.patch
];
postPatch = ''
substituteInPlace auto_cpufreq/core.py --replace '/opt/auto-cpufreq/override.pickle' /var/run/override.pickle
substituteInPlace scripts/org.auto-cpufreq.pkexec.policy --replace "/opt/auto-cpufreq/venv/bin/auto-cpufreq" $out/bin/auto-cpufreq
'';
postInstall = ''
# copy script manually
cp scripts/cpufreqctl.sh $out/bin/cpufreqctl.auto-cpufreq
# systemd service
mkdir -p $out/lib/systemd/system
cp scripts/auto-cpufreq.service $out/lib/systemd/system
substituteInPlace $out/lib/systemd/system/auto-cpufreq.service --replace "/usr/local" $out
# desktop icon
mkdir -p $out/share/applications
mkdir $out/share/pixmaps
cp scripts/auto-cpufreq-gtk.desktop $out/share/applications
cp images/icon.png $out/share/pixmaps/auto-cpufreq.png
# polkit policy
mkdir -p $out/share/polkit-1/actions
cp scripts/org.auto-cpufreq.pkexec.policy $out/share/polkit-1/actions
'';
meta = with lib; {
homepage = "https://github.com/AdnanHodzic/auto-cpufreq";
description = "Automatic CPU speed & power optimizer for Linux";
license = licenses.lgpl3Plus;
platforms = platforms.linux;
maintainers = [ maintainers.Technical27 ];
mainProgram = "auto-cpufreq";
};
}