auto-cpufreq/nix/default.nix

80 lines
2.6 KiB
Nix
Raw Normal View History

2023-10-13 16:31:59 +02:00
{
lib,
python310Packages,
pkgs,
fetchFromGitHub,
2023-10-13 16:31:59 +02:00
}:
let
psutilGit = python310Packages.psutil.overrideAttrs (oldAttrs: {
src = fetchFromGitHub {
owner = "giampaolo";
repo = "psutil";
rev = "4cf56e08c1bc883ec89758834b50954380759858";
sha256 = "61JwXP/cZrXqdBnb2J0kdDJoKpltO62KcpM0sYX6g1A=";
};
});
in
2023-10-13 16:31:59 +02:00
python310Packages.buildPythonPackage {
# use pyproject.toml instead of setup.py
format = "pyproject";
2023-09-16 11:36:01 +02:00
pname = "auto-cpufreq";
2024-02-14 17:47:37 +01:00
version = "2.2.0";
2023-09-16 11:36:01 +02:00
src = ../.;
2023-10-13 16:31:59 +02:00
nativeBuildInputs = with pkgs; [wrapGAppsHook gobject-introspection];
2023-10-13 16:31:59 +02:00
buildInputs = with pkgs; [gtk3 python310Packages.poetry-core];
2023-09-16 11:36:01 +02:00
propagatedBuildInputs = with python310Packages; [requests pygobject3 click distro psutilGit setuptools poetry-dynamic-versioning];
2023-09-16 11:36:01 +02:00
doCheck = false;
2023-10-13 16:31:59 +02:00
pythonImportsCheck = ["auto_cpufreq"];
2023-09-16 11:36:01 +02:00
patches = [
2023-10-13 16:31:59 +02:00
# patch to prevent script copying and to disable install
2023-09-16 11:36:01 +02:00
./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
2023-10-13 16:31:59 +02:00
2023-10-13 23:47:16 +02:00
substituteInPlace auto_cpufreq/gui/app.py auto_cpufreq/gui/objects.py --replace "/usr/local/share/auto-cpufreq/images/icon.png" $out/share/pixmaps/auto-cpufreq.png
2023-10-13 16:31:59 +02:00
substituteInPlace auto_cpufreq/gui/app.py --replace "/usr/local/share/auto-cpufreq/scripts/style.css" $out/share/auto-cpufreq/scripts/style.css
2023-09-16 11:36:01 +02:00
'';
postInstall = ''
# copy script manually
cp scripts/cpufreqctl.sh $out/bin/cpufreqctl.auto-cpufreq
2023-10-13 16:31:59 +02:00
# move the css to the rihgt place
mkdir -p $out/share/auto-cpufreq/scripts
cp scripts/style.css $out/share/auto-cpufreq/scripts/style.css
2023-09-16 11:36:01 +02:00
# 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;
2023-10-13 16:31:59 +02:00
maintainers = [maintainers.Technical27];
2023-09-16 11:36:01 +02:00
mainProgram = "auto-cpufreq";
};
}