auto-cpufreq/nix/default.nix

83 lines
2.6 KiB
Nix
Raw Normal View History

2023-10-13 16:31:59 +02:00
{
lib,
Rework config and reload config on file change/creation/deletion (#663) * add config.py and config_event_handler.py also introduces the utils folder * update config imports and variables * add 'pyinotify' dependency * config: check for changes using threading * config: handle errors and new eventsx * config: set_path even if file doesn't exist and make new ConfigParser on every update * fix get_config call * config: check for changes on moved file * call notifier.start() manually to prevent hanging * config: update comments * battery: fix config imports * config: fix config deletion detection * Add load from user config in XDG_CONFIG_HOME if available (#672) * Add load from user config from in XDG_CONFIG_HOME if available This update introduces the flexibility to load the configuration file from multiple locations, prioritizing user preferences and system standards. Previously, the configuration was strictly read from a hardcoded system path (`/etc/auto-cpufreq.conf`). Now, the application first checks if the user has specified a configuration file path via command line arguments. If not, it looks for a configuration file in the user's config directory (`$XDG_CONFIG_HOME/auto-cpufreq/auto-cpufreq.conf`). If neither is found, it defaults to the original system-wide configuration file. This allows users to add their auto-cpufreq configuration to their dotfiles. * If --config is set but invalid, exit with error * Remove redundant empty string check on config file path * Remove duplicate isfile check for config path See also: https://github.com/AdnanHodzic/auto-cpufreq/pull/672#discussion_r1548003119 * Update configuration options in README See also: #672 * config: move find_config_file function and fix finding home directory * auto_cpufreq: fix hanging on --daemon, --live, and --monitor * swap pyinotify for patched version --------- Co-authored-by: Steven Braun <steven.braun.mz@gmail.com>
2024-04-30 08:35:53 +02:00
python3Packages,
2023-10-13 16:31:59 +02:00
pkgs,
fetchFromGitHub,
2024-05-22 01:43:05 +02:00
fetchPypi,
2023-10-13 16:31:59 +02:00
}:
let
Rework config and reload config on file change/creation/deletion (#663) * add config.py and config_event_handler.py also introduces the utils folder * update config imports and variables * add 'pyinotify' dependency * config: check for changes using threading * config: handle errors and new eventsx * config: set_path even if file doesn't exist and make new ConfigParser on every update * fix get_config call * config: check for changes on moved file * call notifier.start() manually to prevent hanging * config: update comments * battery: fix config imports * config: fix config deletion detection * Add load from user config in XDG_CONFIG_HOME if available (#672) * Add load from user config from in XDG_CONFIG_HOME if available This update introduces the flexibility to load the configuration file from multiple locations, prioritizing user preferences and system standards. Previously, the configuration was strictly read from a hardcoded system path (`/etc/auto-cpufreq.conf`). Now, the application first checks if the user has specified a configuration file path via command line arguments. If not, it looks for a configuration file in the user's config directory (`$XDG_CONFIG_HOME/auto-cpufreq/auto-cpufreq.conf`). If neither is found, it defaults to the original system-wide configuration file. This allows users to add their auto-cpufreq configuration to their dotfiles. * If --config is set but invalid, exit with error * Remove redundant empty string check on config file path * Remove duplicate isfile check for config path See also: https://github.com/AdnanHodzic/auto-cpufreq/pull/672#discussion_r1548003119 * Update configuration options in README See also: #672 * config: move find_config_file function and fix finding home directory * auto_cpufreq: fix hanging on --daemon, --live, and --monitor * swap pyinotify for patched version --------- Co-authored-by: Steven Braun <steven.braun.mz@gmail.com>
2024-04-30 08:35:53 +02:00
pyinotify = python3Packages.pyinotify.overrideAttrs (oldAttrs: {
src = fetchFromGitHub {
owner = "shadeyg56";
repo = "pyinotify-3.12";
rev = "923cebec3a2a84c7e38c9e68171eb93f5d07ce5d";
hash = "sha256-714CximEK4YhIqDmvqJYOUGs39gvDkWGrkNrXwxT8iM=";
};
patches = [];
Rework config and reload config on file change/creation/deletion (#663) * add config.py and config_event_handler.py also introduces the utils folder * update config imports and variables * add 'pyinotify' dependency * config: check for changes using threading * config: handle errors and new eventsx * config: set_path even if file doesn't exist and make new ConfigParser on every update * fix get_config call * config: check for changes on moved file * call notifier.start() manually to prevent hanging * config: update comments * battery: fix config imports * config: fix config deletion detection * Add load from user config in XDG_CONFIG_HOME if available (#672) * Add load from user config from in XDG_CONFIG_HOME if available This update introduces the flexibility to load the configuration file from multiple locations, prioritizing user preferences and system standards. Previously, the configuration was strictly read from a hardcoded system path (`/etc/auto-cpufreq.conf`). Now, the application first checks if the user has specified a configuration file path via command line arguments. If not, it looks for a configuration file in the user's config directory (`$XDG_CONFIG_HOME/auto-cpufreq/auto-cpufreq.conf`). If neither is found, it defaults to the original system-wide configuration file. This allows users to add their auto-cpufreq configuration to their dotfiles. * If --config is set but invalid, exit with error * Remove redundant empty string check on config file path * Remove duplicate isfile check for config path See also: https://github.com/AdnanHodzic/auto-cpufreq/pull/672#discussion_r1548003119 * Update configuration options in README See also: #672 * config: move find_config_file function and fix finding home directory * auto_cpufreq: fix hanging on --daemon, --live, and --monitor * swap pyinotify for patched version --------- Co-authored-by: Steven Braun <steven.braun.mz@gmail.com>
2024-04-30 08:35:53 +02:00
});
in
Rework config and reload config on file change/creation/deletion (#663) * add config.py and config_event_handler.py also introduces the utils folder * update config imports and variables * add 'pyinotify' dependency * config: check for changes using threading * config: handle errors and new eventsx * config: set_path even if file doesn't exist and make new ConfigParser on every update * fix get_config call * config: check for changes on moved file * call notifier.start() manually to prevent hanging * config: update comments * battery: fix config imports * config: fix config deletion detection * Add load from user config in XDG_CONFIG_HOME if available (#672) * Add load from user config from in XDG_CONFIG_HOME if available This update introduces the flexibility to load the configuration file from multiple locations, prioritizing user preferences and system standards. Previously, the configuration was strictly read from a hardcoded system path (`/etc/auto-cpufreq.conf`). Now, the application first checks if the user has specified a configuration file path via command line arguments. If not, it looks for a configuration file in the user's config directory (`$XDG_CONFIG_HOME/auto-cpufreq/auto-cpufreq.conf`). If neither is found, it defaults to the original system-wide configuration file. This allows users to add their auto-cpufreq configuration to their dotfiles. * If --config is set but invalid, exit with error * Remove redundant empty string check on config file path * Remove duplicate isfile check for config path See also: https://github.com/AdnanHodzic/auto-cpufreq/pull/672#discussion_r1548003119 * Update configuration options in README See also: #672 * config: move find_config_file function and fix finding home directory * auto_cpufreq: fix hanging on --daemon, --live, and --monitor * swap pyinotify for patched version --------- Co-authored-by: Steven Braun <steven.braun.mz@gmail.com>
2024-04-30 08:35:53 +02:00
python3Packages.buildPythonPackage {
# use pyproject.toml instead of setup.py
format = "pyproject";
2023-09-16 11:36:01 +02:00
pname = "auto-cpufreq";
2024-05-09 10:07:52 +02:00
version = "2.3.0";
2023-09-16 11:36:01 +02:00
src = ../.;
2023-10-13 16:31:59 +02:00
nativeBuildInputs = with pkgs; [wrapGAppsHook gobject-introspection];
Rework config and reload config on file change/creation/deletion (#663) * add config.py and config_event_handler.py also introduces the utils folder * update config imports and variables * add 'pyinotify' dependency * config: check for changes using threading * config: handle errors and new eventsx * config: set_path even if file doesn't exist and make new ConfigParser on every update * fix get_config call * config: check for changes on moved file * call notifier.start() manually to prevent hanging * config: update comments * battery: fix config imports * config: fix config deletion detection * Add load from user config in XDG_CONFIG_HOME if available (#672) * Add load from user config from in XDG_CONFIG_HOME if available This update introduces the flexibility to load the configuration file from multiple locations, prioritizing user preferences and system standards. Previously, the configuration was strictly read from a hardcoded system path (`/etc/auto-cpufreq.conf`). Now, the application first checks if the user has specified a configuration file path via command line arguments. If not, it looks for a configuration file in the user's config directory (`$XDG_CONFIG_HOME/auto-cpufreq/auto-cpufreq.conf`). If neither is found, it defaults to the original system-wide configuration file. This allows users to add their auto-cpufreq configuration to their dotfiles. * If --config is set but invalid, exit with error * Remove redundant empty string check on config file path * Remove duplicate isfile check for config path See also: https://github.com/AdnanHodzic/auto-cpufreq/pull/672#discussion_r1548003119 * Update configuration options in README See also: #672 * config: move find_config_file function and fix finding home directory * auto_cpufreq: fix hanging on --daemon, --live, and --monitor * swap pyinotify for patched version --------- Co-authored-by: Steven Braun <steven.braun.mz@gmail.com>
2024-04-30 08:35:53 +02:00
buildInputs = with pkgs; [gtk3 python3Packages.poetry-core];
2023-09-16 11:36:01 +02:00
2024-05-22 05:49:41 +02:00
propagatedBuildInputs = with python3Packages; [requests pygobject3 click distro psutil setuptools poetry-dynamic-versioning pyinotify pkgs.getent];
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-fail '/opt/auto-cpufreq/override.pickle' /var/run/override.pickle
substituteInPlace scripts/org.auto-cpufreq.pkexec.policy --replace-fail "/opt/auto-cpufreq/venv/bin/auto-cpufreq" $out/bin/auto-cpufreq
2023-10-13 16:31:59 +02:00
substituteInPlace auto_cpufreq/gui/app.py auto_cpufreq/gui/objects.py --replace-fail "/usr/local/share/auto-cpufreq/images/icon.png" $out/share/pixmaps/auto-cpufreq.png
substituteInPlace auto_cpufreq/gui/app.py --replace-fail "/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
# 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 = {
2023-09-16 11:36:01 +02:00
homepage = "https://github.com/AdnanHodzic/auto-cpufreq";
description = "Automatic CPU speed & power optimizer for Linux";
license = lib.licenses.lgpl3Plus;
platforms = lib.platforms.linux;
maintainers = with lib.maintainers; [Technical27];
2023-09-16 11:36:01 +02:00
mainProgram = "auto-cpufreq";
};
}