From 9596b22b9090286cf580dfff6a9a27349c6e08ef Mon Sep 17 00:00:00 2001 From: shadeyg56 Date: Mon, 2 Oct 2023 18:08:47 -0500 Subject: [PATCH 01/10] auto-cpufreq: 1.9.9 -> 2.0.0 --- pkgs/tools/system/auto-cpufreq/default.nix | 36 ++++++++--- .../system/auto-cpufreq/prevent-update.patch | 59 ++++++++++++------- 2 files changed, 66 insertions(+), 29 deletions(-) diff --git a/pkgs/tools/system/auto-cpufreq/default.nix b/pkgs/tools/system/auto-cpufreq/default.nix index 4c15908eab191..f8199e90eb123 100644 --- a/pkgs/tools/system/auto-cpufreq/default.nix +++ b/pkgs/tools/system/auto-cpufreq/default.nix @@ -1,17 +1,21 @@ -{ lib, python3Packages, fetchFromGitHub, substituteAll }: +{ lib, pkgs, python310Packages, fetchFromGitHub, substituteAll }: -python3Packages.buildPythonPackage rec { +python310Packages.buildPythonPackage rec { pname = "auto-cpufreq"; - version = "1.9.9"; + version = "2.0.0"; src = fetchFromGitHub { owner = "AdnanHodzic"; repo = pname; rev = "v${version}"; - sha256 = "sha256-D/5pwE2V+yXj92ECOUcl/dajMDbvVdz9YNJrl2Pzvts="; + hash = "sha256-164Gi1Oo9Tfd58aDq/3UjsWeS4rAZ39xCEhBgqv+GtI="; }; - propagatedBuildInputs = with python3Packages; [ setuptools-git-versioning click distro psutil ]; + nativeBuildInputs = with pkgs; [ wrapGAppsHook gobject-introspection ]; + + buildInputs = with pkgs; [ gtk3 ]; + + propagatedBuildInputs = with python310Packages; [ setuptools-git-versioning click distro psutil pygobject3 ]; doCheck = false; pythonImportsCheck = [ "auto_cpufreq" ]; @@ -23,11 +27,17 @@ python3Packages.buildPythonPackage rec { inherit version; }) + # patch to prevent update + ./prevent-update.patch + # patch to prevent script copying and to disable install ./prevent-install-and-copy.patch - # patch to prevent update - ./prevent-update.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 @@ -36,6 +46,16 @@ python3Packages.buildPythonPackage rec { # systemd service mkdir -p $out/lib/systemd/system cp ${src}/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 = with lib; { diff --git a/pkgs/tools/system/auto-cpufreq/prevent-update.patch b/pkgs/tools/system/auto-cpufreq/prevent-update.patch index 10da9fec97855..77169cc3fbe7d 100644 --- a/pkgs/tools/system/auto-cpufreq/prevent-update.patch +++ b/pkgs/tools/system/auto-cpufreq/prevent-update.patch @@ -1,12 +1,15 @@ diff --git a/requirements.txt b/requirements.txt -index f492cac..e61d1a4 100755 +index f492cac..1cbad0d 100755 --- a/requirements.txt +++ b/requirements.txt -@@ -2,4 +2,3 @@ +@@ -2,5 +2,4 @@ setuptools psutil click distro -requests +-PyGObject +\ No newline at end of file ++PyGObject diff --git a/auto_cpufreq/core.py b/auto_cpufreq/core.py index 99397a9..697fb68 100755 @@ -22,39 +25,53 @@ index 99397a9..697fb68 100755 # execution timestamp used in countdown func diff --git a/bin/auto-cpufreq b/bin/auto-cpufreq -index b89d925..b73974c 100755 +index 4e94e55..ee164b2 100755 --- a/bin/auto-cpufreq +++ b/bin/auto-cpufreq -@@ -193,31 +193,7 @@ - elif remove: - print("remove is disabled in the nix package") +@@ -225,45 +225,7 @@ def main(config, daemon, debug, update, install, remove, live, log, monitor, sta + remove_daemon() + remove_complete_msg() elif update: - root_check() +- custom_dir = "/opt/auto-cpufreq/source" +- for arg in sys.argv: +- if arg.startswith("--update="): +- custom_dir = arg.split("=")[1] +- sys.argv.remove(arg) +- +- if "--update" in sys.argv: +- update = True +- sys.argv.remove("--update") +- if len(sys.argv) == 2: +- custom_dir = sys.argv[1] +- - if os.getenv("PKG_MARKER") == "SNAP": - print("Detected auto-cpufreq was installed using snap") - # refresh snap directly using this command +- # path wont work in this case - - print("Please update using snap package manager, i.e: `sudo snap refresh auto-cpufreq`.") - #check for AUR -- elif subprocess.run(["bash", "-c", "command -v yay >/dev/null 2>&1"]).returncode == 0 or subprocess.run(["bash", "-c", "command -v pacman >/dev/null 2>&1"]).returncode == 0: +- elif subprocess.run(["bash", "-c", "command -v pacman >/dev/null 2>&1"]).returncode == 0 and subprocess.run(["bash", "-c", "pacman -Q auto-cpufreq >/dev/null 2>&1"]).returncode == 0: - print("Arch-based distribution with AUR support detected. Please refresh auto-cpufreq using your AUR helper.") - else: - verify_update() -- ans = input ("Do you want to update auto-cpufreq to the latest release? [y/n]: ") -- valid_options = ['y', 'Y', 'yes', 'YES', 'Yes'] -- if ans.lower() in valid_options: +- ans = input("Do you want to update auto-cpufreq to the latest release? [Y/n]: ").strip().lower() +- if not os.path.exists(custom_dir): +- os.makedirs(custom_dir) +- if os.path.exists(os.path.join(custom_dir, "auto-cpufreq")): +- shutil.rmtree(os.path.join(custom_dir, "auto-cpufreq")) +- if ans in ['', 'y', 'yes']: - remove_daemon() - remove_complete_msg() -- new_update() +- new_update(custom_dir) +- print("enabling daemon") +- run(["auto-cpufreq", "--install"]) +- print("auto-cpufreq is installed with the latest version") +- run(["auto-cpufreq", "--version"]) - else: -- print("incorrect input\n") - print("Aborted") -- print("enabling daemon") -- run(["auto-cpufreq", "--install"]) -- print("auto-cpufreq is installed with the latest version") -- app_version() -- -+ print("update is disabled in the nix package") - - - if __name__ == "__main__": \ No newline at end of file ++ print("Update is disabled in the Nix package") + + if __name__ == "__main__": + main() From 35b0fdc759637a38a9d588152b1b08a5ff1f0cd1 Mon Sep 17 00:00:00 2001 From: shadeyg56 Date: Wed, 18 Oct 2023 15:35:24 -0500 Subject: [PATCH 02/10] auto-cpufreq: copy css file and add new substitutes --- pkgs/tools/system/auto-cpufreq/default.nix | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/pkgs/tools/system/auto-cpufreq/default.nix b/pkgs/tools/system/auto-cpufreq/default.nix index f8199e90eb123..3c882217aac83 100644 --- a/pkgs/tools/system/auto-cpufreq/default.nix +++ b/pkgs/tools/system/auto-cpufreq/default.nix @@ -37,12 +37,21 @@ python310Packages.buildPythonPackage rec { 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 + + 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 + substituteInPlace auto_cpufreq/gui/app.py --replace "/usr/local/share/auto-cpufreq/scripts/style.css" $out/share/auto-cpufreq/scripts/style.css + ''; postInstall = '' # copy script manually cp ${src}/scripts/cpufreqctl.sh $out/bin/cpufreqctl.auto-cpufreq + # copy css file + mkdir -p $out/share/auto-cpufreq/scripts + cp scripts/style.css $out/share/auto-cpufreq/scripts/style.css + + # systemd service mkdir -p $out/lib/systemd/system cp ${src}/scripts/auto-cpufreq.service $out/lib/systemd/system From a6e009599ee25fe17ec23f0aff1fcefca2741079 Mon Sep 17 00:00:00 2001 From: shadeyg56 Date: Thu, 19 Oct 2023 13:51:25 -0500 Subject: [PATCH 03/10] auto-cpufreq: revert Python to default version --- pkgs/tools/system/auto-cpufreq/default.nix | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pkgs/tools/system/auto-cpufreq/default.nix b/pkgs/tools/system/auto-cpufreq/default.nix index 3c882217aac83..2a6cd6fa68b28 100644 --- a/pkgs/tools/system/auto-cpufreq/default.nix +++ b/pkgs/tools/system/auto-cpufreq/default.nix @@ -1,6 +1,6 @@ -{ lib, pkgs, python310Packages, fetchFromGitHub, substituteAll }: +{ lib, pkgs, python3Packages, fetchFromGitHub, substituteAll }: -python310Packages.buildPythonPackage rec { +python3Packages.buildPythonPackage rec { pname = "auto-cpufreq"; version = "2.0.0"; @@ -15,7 +15,7 @@ python310Packages.buildPythonPackage rec { buildInputs = with pkgs; [ gtk3 ]; - propagatedBuildInputs = with python310Packages; [ setuptools-git-versioning click distro psutil pygobject3 ]; + propagatedBuildInputs = with python3Packages; [ setuptools-git-versioning click distro psutil pygobject3 ]; doCheck = false; pythonImportsCheck = [ "auto_cpufreq" ]; From 35ea9e83018b265599602bc0eed5ee58eaf60ee8 Mon Sep 17 00:00:00 2001 From: shadeyg56 Date: Sun, 17 Dec 2023 17:07:56 -0600 Subject: [PATCH 04/10] auto-cpufreq: pass needed packages instead of 'pkgs' --- pkgs/tools/system/auto-cpufreq/default.nix | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkgs/tools/system/auto-cpufreq/default.nix b/pkgs/tools/system/auto-cpufreq/default.nix index 2a6cd6fa68b28..c0c6994f2da80 100644 --- a/pkgs/tools/system/auto-cpufreq/default.nix +++ b/pkgs/tools/system/auto-cpufreq/default.nix @@ -1,4 +1,4 @@ -{ lib, pkgs, python3Packages, fetchFromGitHub, substituteAll }: +{ lib, python3Packages, fetchFromGitHub, substituteAll, wrapGAppsHook, gobject-introspection, gtk3 }: python3Packages.buildPythonPackage rec { pname = "auto-cpufreq"; @@ -11,7 +11,7 @@ python3Packages.buildPythonPackage rec { hash = "sha256-164Gi1Oo9Tfd58aDq/3UjsWeS4rAZ39xCEhBgqv+GtI="; }; - nativeBuildInputs = with pkgs; [ wrapGAppsHook gobject-introspection ]; + nativeBuildInputs = [ wrapGAppsHook gobject-introspection ]; buildInputs = with pkgs; [ gtk3 ]; From b2077fb81222e069b9fe0535fef9339d667f02ed Mon Sep 17 00:00:00 2001 From: shadeyg56 Date: Sun, 17 Dec 2023 17:09:20 -0600 Subject: [PATCH 05/10] auto-cpufreq: 2.0.0 -> 2.1.0 --- pkgs/tools/system/auto-cpufreq/default.nix | 11 ++++-- .../auto-cpufreq/fix-version-output.patch | 20 +++++----- .../prevent-install-and-copy.patch | 13 ++++--- .../system/auto-cpufreq/prevent-update.patch | 38 +++++++------------ 4 files changed, 38 insertions(+), 44 deletions(-) diff --git a/pkgs/tools/system/auto-cpufreq/default.nix b/pkgs/tools/system/auto-cpufreq/default.nix index c0c6994f2da80..6bd4753808572 100644 --- a/pkgs/tools/system/auto-cpufreq/default.nix +++ b/pkgs/tools/system/auto-cpufreq/default.nix @@ -1,21 +1,24 @@ { lib, python3Packages, fetchFromGitHub, substituteAll, wrapGAppsHook, gobject-introspection, gtk3 }: python3Packages.buildPythonPackage rec { + # use pyproject.toml instead of setup.py + format = "pyproject"; + pname = "auto-cpufreq"; - version = "2.0.0"; + version = "2.1.0"; src = fetchFromGitHub { owner = "AdnanHodzic"; repo = pname; rev = "v${version}"; - hash = "sha256-164Gi1Oo9Tfd58aDq/3UjsWeS4rAZ39xCEhBgqv+GtI="; + hash = "sha256-cALWWcmT1fVOof4Kgsbs+TMKB2dBpUF5VpFU3JM20Uc="; }; nativeBuildInputs = [ wrapGAppsHook gobject-introspection ]; - buildInputs = with pkgs; [ gtk3 ]; + buildInputs = [ gtk3 python3Packages.poetry-core ]; - propagatedBuildInputs = with python3Packages; [ setuptools-git-versioning click distro psutil pygobject3 ]; + propagatedBuildInputs = with python3Packages; [ setuptools click distro psutil pygobject3 poetry-dynamic-versioning]; doCheck = false; pythonImportsCheck = [ "auto_cpufreq" ]; diff --git a/pkgs/tools/system/auto-cpufreq/fix-version-output.patch b/pkgs/tools/system/auto-cpufreq/fix-version-output.patch index fad9f091da40e..7e604a37ed958 100644 --- a/pkgs/tools/system/auto-cpufreq/fix-version-output.patch +++ b/pkgs/tools/system/auto-cpufreq/fix-version-output.patch @@ -1,19 +1,17 @@ diff --git a/auto_cpufreq/core.py b/auto_cpufreq/core.py -index 99397a9..f3ef28f 100755 +index 0ef4315..66fd9e2 100755 --- a/auto_cpufreq/core.py +++ b/auto_cpufreq/core.py -@@ -144,26 +144,10 @@ except PermissionError: +@@ -145,26 +145,8 @@ except PermissionError: # display running version of auto-cpufreq def app_version(): -+ print("auto-cpufreq version: @version@") -+ print("Git commit: v@version@") - +- - print("auto-cpufreq version: ", end="") - +- - # snap package - if os.getenv("PKG_MARKER") == "SNAP": -- print(getoutput("echo \(Snap\) $SNAP_VERSION")) +- print(getoutput(r"echo \(Snap\) $SNAP_VERSION")) - # aur package - elif dist_name in ["arch", "manjaro", "garuda"]: - aur_pkg_check = call("pacman -Qs auto-cpufreq > /dev/null", shell=True) @@ -28,6 +26,8 @@ index 99397a9..f3ef28f 100755 - except Exception as e: - print(repr(e)) - pass - def verify_update(): - # Specify the repository and package name - # IT IS IMPORTANT TO THAT IF THE REPOSITORY STRUCTURE IS CHANGED, THE FOLLOWING FUNCTION NEEDS TO BE UPDATED ACCORDINGLY \ No newline at end of file ++ print("auto-cpufreq version: @version@") ++ print("Git commit: v@version@") + + def check_for_update(): + # returns True if a new release is available from the GitHub repo diff --git a/pkgs/tools/system/auto-cpufreq/prevent-install-and-copy.patch b/pkgs/tools/system/auto-cpufreq/prevent-install-and-copy.patch index 9b5bffb5591ee..eb3e8e21b295e 100644 --- a/pkgs/tools/system/auto-cpufreq/prevent-install-and-copy.patch +++ b/pkgs/tools/system/auto-cpufreq/prevent-install-and-copy.patch @@ -113,11 +113,11 @@ index 99397a9..48a377a 100755 def gov_check(): -diff --git a/bin/auto-cpufreq b/bin/auto-cpufreq -index b89d925..b73974c 100755 ---- a/bin/auto-cpufreq -+++ b/bin/auto-cpufreq -@@ -189,41 +189,9 @@ +diff --git a/auto_cpufreq/bin/auto_cpufreq.py b/auto_cpufreq/bin/auto_cpufreq.py +index db2b84d..9c3caf3 100755 +--- a/auto_cpufreq/bin/auto_cpufreq.py ++++ b/auto_cpufreq/bin/auto_cpufreq.py +@@ -189,41 +189,9 @@ def main(config, daemon, debug, update, install, remove, live, log, monitor, sta print("https://github.com/AdnanHodzic/auto-cpufreq/#donate") footer() elif install: @@ -160,4 +160,5 @@ index b89d925..b73974c 100755 + print("remove is disabled in the nix package") elif update: root_check() - if os.getenv("PKG_MARKER") == "SNAP": \ No newline at end of file + custom_dir = "/opt/auto-cpufreq/source" + diff --git a/pkgs/tools/system/auto-cpufreq/prevent-update.patch b/pkgs/tools/system/auto-cpufreq/prevent-update.patch index 77169cc3fbe7d..58aa742c5c201 100644 --- a/pkgs/tools/system/auto-cpufreq/prevent-update.patch +++ b/pkgs/tools/system/auto-cpufreq/prevent-update.patch @@ -1,21 +1,8 @@ -diff --git a/requirements.txt b/requirements.txt -index f492cac..1cbad0d 100755 ---- a/requirements.txt -+++ b/requirements.txt -@@ -2,5 +2,4 @@ setuptools - psutil - click - distro --requests --PyGObject -\ No newline at end of file -+PyGObject - diff --git a/auto_cpufreq/core.py b/auto_cpufreq/core.py -index 99397a9..697fb68 100755 +index 0ef4315..fe9dc25 100755 --- a/auto_cpufreq/core.py +++ b/auto_cpufreq/core.py -@@ -18,7 +18,6 @@ from math import isclose +@@ -19,7 +19,6 @@ from math import isclose from pathlib import Path from shutil import which from subprocess import getoutput, call, run, check_output, DEVNULL @@ -24,11 +11,12 @@ index 99397a9..697fb68 100755 # execution timestamp used in countdown func -diff --git a/bin/auto-cpufreq b/bin/auto-cpufreq -index 4e94e55..ee164b2 100755 ---- a/bin/auto-cpufreq -+++ b/bin/auto-cpufreq -@@ -225,45 +225,7 @@ def main(config, daemon, debug, update, install, remove, live, log, monitor, sta + +diff --git a/auto_cpufreq/bin/auto_cpufreq.py b/auto_cpufreq/bin/auto_cpufreq.py +index db2b84d..0425338 100755 +--- a/auto_cpufreq/bin/auto_cpufreq.py ++++ b/auto_cpufreq/bin/auto_cpufreq.py +@@ -225,47 +225,7 @@ def main(config, daemon, debug, update, install, remove, live, log, monitor, sta remove_daemon() remove_complete_msg() elif update: @@ -55,7 +43,9 @@ index 4e94e55..ee164b2 100755 - elif subprocess.run(["bash", "-c", "command -v pacman >/dev/null 2>&1"]).returncode == 0 and subprocess.run(["bash", "-c", "pacman -Q auto-cpufreq >/dev/null 2>&1"]).returncode == 0: - print("Arch-based distribution with AUR support detected. Please refresh auto-cpufreq using your AUR helper.") - else: -- verify_update() +- is_new_update = check_for_update() +- if not is_new_update: +- return - ans = input("Do you want to update auto-cpufreq to the latest release? [Y/n]: ").strip().lower() - if not os.path.exists(custom_dir): - os.makedirs(custom_dir) @@ -71,7 +61,7 @@ index 4e94e55..ee164b2 100755 - run(["auto-cpufreq", "--version"]) - else: - print("Aborted") -+ print("Update is disabled in the Nix package") ++ print("Update is disabled in the Nix package") - if __name__ == "__main__": - main() + elif completions: + if completions == "bash": From d7e6e08eefc2e176493d272a8a0fd52ac33a462b Mon Sep 17 00:00:00 2001 From: shadeyg56 <31134255+shadeyg56@users.noreply.github.com> Date: Fri, 23 Feb 2024 17:23:33 -0600 Subject: [PATCH 06/10] Apply formatting from code review Co-authored-by: Pol Dellaiera --- pkgs/tools/system/auto-cpufreq/default.nix | 38 +++++++++++++++++----- 1 file changed, 30 insertions(+), 8 deletions(-) diff --git a/pkgs/tools/system/auto-cpufreq/default.nix b/pkgs/tools/system/auto-cpufreq/default.nix index 6bd4753808572..9a74a58be2053 100644 --- a/pkgs/tools/system/auto-cpufreq/default.nix +++ b/pkgs/tools/system/auto-cpufreq/default.nix @@ -1,4 +1,11 @@ -{ lib, python3Packages, fetchFromGitHub, substituteAll, wrapGAppsHook, gobject-introspection, gtk3 }: +{ lib +, python3Packages +, fetchFromGitHub +, substituteAll +, wrapGAppsHook +, gobject-introspection +, gtk3 +}: python3Packages.buildPythonPackage rec { # use pyproject.toml instead of setup.py @@ -14,11 +21,24 @@ python3Packages.buildPythonPackage rec { hash = "sha256-cALWWcmT1fVOof4Kgsbs+TMKB2dBpUF5VpFU3JM20Uc="; }; - nativeBuildInputs = [ wrapGAppsHook gobject-introspection ]; - - buildInputs = [ gtk3 python3Packages.poetry-core ]; - - propagatedBuildInputs = with python3Packages; [ setuptools click distro psutil pygobject3 poetry-dynamic-versioning]; + nativeBuildInputs = [ + gobject-introspection + wrapGAppsHook + ]; + + buildInputs = [ + gtk3 + python3Packages.poetry-core + ]; + + propagatedBuildInputs = with python3Packages; [ + click + distro + psutil + pygobject3 + poetry-dynamic-versioning + setuptools + ]; doCheck = false; pythonImportsCheck = [ "auto_cpufreq" ]; @@ -41,8 +61,10 @@ python3Packages.buildPythonPackage rec { 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 - 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 - substituteInPlace auto_cpufreq/gui/app.py --replace "/usr/local/share/auto-cpufreq/scripts/style.css" $out/share/auto-cpufreq/scripts/style.css + 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 ''; From 95a3b0df98bf10b5591c3e316220dc1cf6513bbf Mon Sep 17 00:00:00 2001 From: shadeyg56 Date: Fri, 23 Feb 2024 17:31:32 -0600 Subject: [PATCH 07/10] auto-cpufreq: revert unnecessary move of code --- pkgs/tools/system/auto-cpufreq/default.nix | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/pkgs/tools/system/auto-cpufreq/default.nix b/pkgs/tools/system/auto-cpufreq/default.nix index 9a74a58be2053..e24777dda894f 100644 --- a/pkgs/tools/system/auto-cpufreq/default.nix +++ b/pkgs/tools/system/auto-cpufreq/default.nix @@ -50,11 +50,10 @@ python3Packages.buildPythonPackage rec { inherit version; }) - # patch to prevent update - ./prevent-update.patch - # patch to prevent script copying and to disable install ./prevent-install-and-copy.patch + # patch to prevent update + ./prevent-update.patch ]; postPatch = '' From 0177e728f2854637986e13059a58493a096f533e Mon Sep 17 00:00:00 2001 From: shadeyg56 Date: Fri, 23 Feb 2024 17:50:22 -0600 Subject: [PATCH 08/10] auto-cpufreq: 2.1.0->2.2.0 --- pkgs/tools/system/auto-cpufreq/default.nix | 10 ++-- .../system/auto-cpufreq/prevent-update.patch | 46 +++++++++++++++++++ 2 files changed, 51 insertions(+), 5 deletions(-) diff --git a/pkgs/tools/system/auto-cpufreq/default.nix b/pkgs/tools/system/auto-cpufreq/default.nix index e24777dda894f..71294dfe61357 100644 --- a/pkgs/tools/system/auto-cpufreq/default.nix +++ b/pkgs/tools/system/auto-cpufreq/default.nix @@ -12,13 +12,13 @@ python3Packages.buildPythonPackage rec { format = "pyproject"; pname = "auto-cpufreq"; - version = "2.1.0"; + version = "2.2.0"; src = fetchFromGitHub { owner = "AdnanHodzic"; repo = pname; rev = "v${version}"; - hash = "sha256-cALWWcmT1fVOof4Kgsbs+TMKB2dBpUF5VpFU3JM20Uc="; + hash = "sha256-lwimP4+qRFNQN+uHSFJHdkXYREWGwtoEc7U+bN5TDcc="; }; nativeBuildInputs = [ @@ -52,7 +52,7 @@ python3Packages.buildPythonPackage rec { # patch to prevent script copying and to disable install ./prevent-install-and-copy.patch - # patch to prevent update + # patch to prevent update ./prevent-update.patch ]; @@ -61,9 +61,9 @@ python3Packages.buildPythonPackage rec { substituteInPlace scripts/org.auto-cpufreq.pkexec.policy --replace "/opt/auto-cpufreq/venv/bin/auto-cpufreq" $out/bin/auto-cpufreq 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 + --replace "/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 + --replace "/usr/local/share/auto-cpufreq/scripts/style.css" $out/share/auto-cpufreq/scripts/style.css ''; diff --git a/pkgs/tools/system/auto-cpufreq/prevent-update.patch b/pkgs/tools/system/auto-cpufreq/prevent-update.patch index 58aa742c5c201..4dbd2163e0163 100644 --- a/pkgs/tools/system/auto-cpufreq/prevent-update.patch +++ b/pkgs/tools/system/auto-cpufreq/prevent-update.patch @@ -65,3 +65,49 @@ index db2b84d..0425338 100755 elif completions: if completions == "bash": +diff --git a/auto_cpufreq/core.py b/auto_cpufreq/core.py +index e355ff3..a0e9c48 100755 +--- a/auto_cpufreq/core.py ++++ b/auto_cpufreq/core.py +@@ -167,40 +167,8 @@ def app_version(): + pass + + def check_for_update(): +- # returns True if a new release is available from the GitHub repo ++ pass + +- # Specify the repository and package name +- # IT IS IMPORTANT TO THAT IF THE REPOSITORY STRUCTURE IS CHANGED, THE FOLLOWING FUNCTION NEEDS TO BE UPDATED ACCORDINGLY +- # Fetch the latest release information from GitHub API +- latest_release_url = f"https://api.github.com/repos/AdnanHodzic/auto-cpufreq/releases/latest" +- try: +- latest_release = requests.get(latest_release_url).json() +- except (requests.exceptions.ConnectionError, requests.exceptions.Timeout, +- requests.exceptions.RequestException, requests.exceptions.HTTPError) as err: +- print ("Error Connecting to server!") +- return False +- +- latest_version = latest_release["tag_name"] +- +- # Get the current version of auto-cpufreq +- # Extract version number from the output string +- output = check_output(['auto-cpufreq', '--version']).decode('utf-8') +- try: +- version_line = next((re.search(r'\d+\.\d+\.\d+', line).group() for line in output.split('\n') if line.startswith('auto-cpufreq version')), None) +- except AttributeError: +- print("Error Retrieving Current Version!") +- exit(1) +- installed_version = "v" + version_line +- #Check whether the same is installed or not +- # Compare the latest version with the installed version and perform update if necessary +- if latest_version == installed_version: +- print("auto-cpufreq is up to date") +- return False +- else: +- print(f"Updates are available,\nCurrent version: {installed_version}\nLatest version: {latest_version}") +- print("Note that your previous custom settings might be erased with the following update") +- return True +- + def new_update(custom_dir): + os.chdir(custom_dir) + print(f"Cloning the latest release to {custom_dir}") From 4d09b46ed9adc085eea832305e856846bbc44e0f Mon Sep 17 00:00:00 2001 From: shadeyg56 Date: Fri, 23 Feb 2024 17:51:55 -0600 Subject: [PATCH 09/10] auto-cpufreq: replace repo=pname --- pkgs/tools/system/auto-cpufreq/default.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkgs/tools/system/auto-cpufreq/default.nix b/pkgs/tools/system/auto-cpufreq/default.nix index 71294dfe61357..1f6a268c45f80 100644 --- a/pkgs/tools/system/auto-cpufreq/default.nix +++ b/pkgs/tools/system/auto-cpufreq/default.nix @@ -16,7 +16,7 @@ python3Packages.buildPythonPackage rec { src = fetchFromGitHub { owner = "AdnanHodzic"; - repo = pname; + repo = "auto-cpufreq"; rev = "v${version}"; hash = "sha256-lwimP4+qRFNQN+uHSFJHdkXYREWGwtoEc7U+bN5TDcc="; }; From c5751ac9bfe37f4d30c74bf247f35b8e3904252d Mon Sep 17 00:00:00 2001 From: shadeyg56 Date: Fri, 23 Feb 2024 17:53:52 -0600 Subject: [PATCH 10/10] auto-cpufreq: remove trailing whitespace --- pkgs/tools/system/auto-cpufreq/default.nix | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/pkgs/tools/system/auto-cpufreq/default.nix b/pkgs/tools/system/auto-cpufreq/default.nix index 1f6a268c45f80..72ca49b1ca83a 100644 --- a/pkgs/tools/system/auto-cpufreq/default.nix +++ b/pkgs/tools/system/auto-cpufreq/default.nix @@ -21,23 +21,23 @@ python3Packages.buildPythonPackage rec { hash = "sha256-lwimP4+qRFNQN+uHSFJHdkXYREWGwtoEc7U+bN5TDcc="; }; - nativeBuildInputs = [ + nativeBuildInputs = [ gobject-introspection wrapGAppsHook ]; - buildInputs = [ - gtk3 + buildInputs = [ + gtk3 python3Packages.poetry-core ]; - propagatedBuildInputs = with python3Packages; [ - click - distro - psutil - pygobject3 + propagatedBuildInputs = with python3Packages; [ + click + distro + psutil + pygobject3 poetry-dynamic-versioning - setuptools + setuptools ]; doCheck = false;