From fa188528484ed0b055db8d9be48453e2fa9d8b1b Mon Sep 17 00:00:00 2001 From: Felix Uhl Date: Sat, 2 Mar 2024 18:38:44 +0100 Subject: [PATCH 1/7] persepolis: 3.2.0 -> 4.0.0 Closes #288825 Auto-update didn't work because one patch didn't apply. Additionally, I could remove one patch, as it has been merged upstream. --- ...003-Search-PATH-for-aria2c-on-darwin.patch | 2 +- pkgs/tools/networking/persepolis/default.nix | 19 ++++++------------- 2 files changed, 7 insertions(+), 14 deletions(-) diff --git a/pkgs/tools/networking/persepolis/0003-Search-PATH-for-aria2c-on-darwin.patch b/pkgs/tools/networking/persepolis/0003-Search-PATH-for-aria2c-on-darwin.patch index ab3c957ef4b1..505961d1ce6b 100644 --- a/pkgs/tools/networking/persepolis/0003-Search-PATH-for-aria2c-on-darwin.patch +++ b/pkgs/tools/networking/persepolis/0003-Search-PATH-for-aria2c-on-darwin.patch @@ -9,7 +9,7 @@ index aaabb35..69676d3 100644 @@ -72,16 +72,8 @@ def startAria(): # in macintosh - elif os_type == 'Darwin': + elif os_type == OS.OSX: - if aria2_path == "" or aria2_path == None or os.path.isfile(str(aria2_path)) == False: - - cwd = sys.argv[0] diff --git a/pkgs/tools/networking/persepolis/default.nix b/pkgs/tools/networking/persepolis/default.nix index b3b084c22596..09fbe59099d1 100644 --- a/pkgs/tools/networking/persepolis/default.nix +++ b/pkgs/tools/networking/persepolis/default.nix @@ -18,33 +18,26 @@ buildPythonApplication rec { pname = "persepolis"; - version = "3.2.0"; + version = "4.0.0"; src = fetchFromGitHub { owner = "persepolisdm"; repo = "persepolis"; - rev = version; - sha256 = "1rh7q432ynbysapsd075nif975ync71icpb71x2mb4j8jx1vzs45"; + rev = "refs/tags/${version}"; + sha256 = "sha256-2S6s/tWhI9RBFA26jkwxYTGeaok8S8zv/bY+Zr8TOak="; }; # see: https://github.com/persepolisdm/persepolis/blob/3.2.0/setup.py#L130 doCheck = false; - preBuild= # Make setup automatic - '' + preBuild= '' substituteInPlace setup.py --replace "answer = input(" "answer = 'y'#" - '' + - # Replace abandoned youtube-dl with maintained fork yt-dlp. Fixes https://github.com/persepolisdm/persepolis/issues/930, - # can be removed if that issue is fixed and/or https://github.com/persepolisdm/persepolis/pull/936 is merged - '' - substituteInPlace setup.py ./persepolis/scripts/video_finder_addlink.py --replace \ - "import youtube_dl" "import yt_dlp as youtube_dl" ''; patches = lib.optionals stdenv.isDarwin [ - # Upstream is abandonware, the last commit to master was on 2021-08-26. - # If it is forked or picked up again, consider upstreaming these patches. + # Upstream does currently not allow building from source on macOS. These patches can likely + # be removed if https://github.com/persepolisdm/persepolis/issues/943 is fixed upstream ./0001-Allow-building-on-darwin.patch ./0002-Fix-startup-crash-on-darwin.patch ./0003-Search-PATH-for-aria2c-on-darwin.patch From cc0a9478d4aae9ee0a83e091bef99282ba4703c8 Mon Sep 17 00:00:00 2001 From: Felix Uhl Date: Tue, 5 Mar 2024 16:44:55 +0100 Subject: [PATCH 2/7] persepolis: refactor: re-enable checkPhase --- .../0001-Allow-building-on-darwin.patch | 8 ------- pkgs/tools/networking/persepolis/default.nix | 22 ++++++++++++++----- 2 files changed, 17 insertions(+), 13 deletions(-) diff --git a/pkgs/tools/networking/persepolis/0001-Allow-building-on-darwin.patch b/pkgs/tools/networking/persepolis/0001-Allow-building-on-darwin.patch index 4ddd18bbd468..46790103f3d1 100644 --- a/pkgs/tools/networking/persepolis/0001-Allow-building-on-darwin.patch +++ b/pkgs/tools/networking/persepolis/0001-Allow-building-on-darwin.patch @@ -23,14 +23,6 @@ index 985d28d..933f3df 100755 # Checking dependencies! not_installed = '' -@@ -100,6 +96,7 @@ else: - print('paplay is found!') - - # sound-theme-freedesktop -+notifications_path = '' - if os_type == 'Linux': - notifications_path = '/usr/share/sounds/freedesktop/stereo/' - elif os_type == 'FreeBSD' or os_type == 'OpenBSD': @@ -139,7 +136,7 @@ if sys.argv[1] == "test": DESCRIPTION = 'Persepolis Download Manager' diff --git a/pkgs/tools/networking/persepolis/default.nix b/pkgs/tools/networking/persepolis/default.nix index 09fbe59099d1..91be1b4da498 100644 --- a/pkgs/tools/networking/persepolis/default.nix +++ b/pkgs/tools/networking/persepolis/default.nix @@ -27,11 +27,8 @@ buildPythonApplication rec { sha256 = "sha256-2S6s/tWhI9RBFA26jkwxYTGeaok8S8zv/bY+Zr8TOak="; }; - # see: https://github.com/persepolisdm/persepolis/blob/3.2.0/setup.py#L130 - doCheck = false; - # Make setup automatic - preBuild= '' + preBuild = '' substituteInPlace setup.py --replace "answer = input(" "answer = 'y'#" ''; @@ -45,8 +42,13 @@ buildPythonApplication rec { ]; postPatch = '' - sed -i 's|/usr/share/sounds/freedesktop/stereo/|${sound-theme-freedesktop}/share/sounds/freedesktop/stereo/|' setup.py sed -i "s|'persepolis = persepolis.__main__'|'persepolis = persepolis.scripts.persepolis:main'|" setup.py + + # Ensure dependencies with hard-coded FHS paths are properly detected + substituteInPlace setup.py --replace-fail "isdir(notifications_path)" "isdir('${sound-theme-freedesktop}/share/sounds/freedesktop')" + + # Fix oversight in test script (can be removed once https://github.com/persepolisdm/persepolis/pull/942 is merged upstream) + substituteInPlace setup.py --replace-fail "sys.exit('0')" "sys.exit(0)" ''; postInstall = '' @@ -64,6 +66,16 @@ buildPythonApplication rec { "\${qtWrapperArgs[@]}" ]; + # The presence of these dependencies is checked during setuptoolsCheckPhase, + # but apart from that, they're not required during build, only runtime + nativeCheckInputs = [ + aria2 + libnotify + pulseaudio + sound-theme-freedesktop + ffmpeg + ]; + propagatedBuildInputs = [ pulseaudio psutil From ecd975fffb8f202f1eb5c0485ca230f86e1f5cbe Mon Sep 17 00:00:00 2001 From: Felix Uhl Date: Tue, 5 Mar 2024 16:54:30 +0100 Subject: [PATCH 3/7] persepolis: formatting Addressing review comments of https://github.com/NixOS/nixpkgs/pull/292837 --- pkgs/tools/networking/persepolis/default.nix | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/pkgs/tools/networking/persepolis/default.nix b/pkgs/tools/networking/persepolis/default.nix index 91be1b4da498..d3b1441a4bb0 100644 --- a/pkgs/tools/networking/persepolis/default.nix +++ b/pkgs/tools/networking/persepolis/default.nix @@ -24,14 +24,9 @@ buildPythonApplication rec { owner = "persepolisdm"; repo = "persepolis"; rev = "refs/tags/${version}"; - sha256 = "sha256-2S6s/tWhI9RBFA26jkwxYTGeaok8S8zv/bY+Zr8TOak="; + hash = "sha256-2S6s/tWhI9RBFA26jkwxYTGeaok8S8zv/bY+Zr8TOak="; }; - # Make setup automatic - preBuild = '' - substituteInPlace setup.py --replace "answer = input(" "answer = 'y'#" - ''; - patches = lib.optionals stdenv.isDarwin [ # Upstream does currently not allow building from source on macOS. These patches can likely # be removed if https://github.com/persepolisdm/persepolis/issues/943 is fixed upstream @@ -44,6 +39,9 @@ buildPythonApplication rec { postPatch = '' sed -i "s|'persepolis = persepolis.__main__'|'persepolis = persepolis.scripts.persepolis:main'|" setup.py + # Automatically answer yes to all interactive questions during setup + substituteInPlace setup.py --replace-fail "answer = input(" "answer = 'y'#" + # Ensure dependencies with hard-coded FHS paths are properly detected substituteInPlace setup.py --replace-fail "isdir(notifications_path)" "isdir('${sound-theme-freedesktop}/share/sounds/freedesktop')" @@ -52,8 +50,8 @@ buildPythonApplication rec { ''; postInstall = '' - mkdir -p $out/share/applications - cp $src/xdg/com.github.persepolisdm.persepolis.desktop $out/share/applications + mkdir -p $out/share/applications + cp $src/xdg/com.github.persepolisdm.persepolis.desktop $out/share/applications ''; # prevent double wrapping From 5047bcf30a3b8e592c0656fb7093661e7cea55dc Mon Sep 17 00:00:00 2001 From: Felix Uhl Date: Tue, 5 Mar 2024 16:56:21 +0100 Subject: [PATCH 4/7] persepolis: apply Darwin patches on Linux as well This will aid maintainability, as maintainers changing the package on Linux will immediately see if the patches break without having to wait for ofborg to tell them. --- pkgs/tools/networking/persepolis/default.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkgs/tools/networking/persepolis/default.nix b/pkgs/tools/networking/persepolis/default.nix index d3b1441a4bb0..6c51bbc437eb 100644 --- a/pkgs/tools/networking/persepolis/default.nix +++ b/pkgs/tools/networking/persepolis/default.nix @@ -27,7 +27,7 @@ buildPythonApplication rec { hash = "sha256-2S6s/tWhI9RBFA26jkwxYTGeaok8S8zv/bY+Zr8TOak="; }; - patches = lib.optionals stdenv.isDarwin [ + patches = [ # Upstream does currently not allow building from source on macOS. These patches can likely # be removed if https://github.com/persepolisdm/persepolis/issues/943 is fixed upstream ./0001-Allow-building-on-darwin.patch From b502a1d4d5f4e4f7f68afc26bbdb1d8bbab421ec Mon Sep 17 00:00:00 2001 From: Felix Uhl Date: Tue, 5 Mar 2024 16:59:59 +0100 Subject: [PATCH 5/7] persepolis: fix incorrect meta fields --- pkgs/tools/networking/persepolis/default.nix | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkgs/tools/networking/persepolis/default.nix b/pkgs/tools/networking/persepolis/default.nix index 6c51bbc437eb..79d936ee3b1a 100644 --- a/pkgs/tools/networking/persepolis/default.nix +++ b/pkgs/tools/networking/persepolis/default.nix @@ -86,10 +86,10 @@ buildPythonApplication rec { ]; meta = with lib; { - description = "Persepolis Download Manager is a GUI for aria2"; + description = "A GUI for aria2"; mainProgram = "persepolis"; homepage = "https://persepolisdm.github.io/"; - license = licenses.gpl3; + license = licenses.gpl3Plus; maintainers = with maintainers; [ iFreilicht ]; }; } From 1e04dc2a54cbf84b041509cce01b89295751f882 Mon Sep 17 00:00:00 2001 From: Felix Uhl Date: Tue, 5 Mar 2024 17:02:33 +0100 Subject: [PATCH 6/7] persepolis: migrate to by-name --- .../0001-Allow-building-on-darwin.patch | 0 .../0002-Fix-startup-crash-on-darwin.patch | 0 ...003-Search-PATH-for-aria2c-on-darwin.patch | 0 ...004-Search-PATH-for-ffmpeg-on-darwin.patch | 0 .../pe/persepolis/package.nix} | 19 +++++++------------ pkgs/top-level/all-packages.nix | 4 ---- 6 files changed, 7 insertions(+), 16 deletions(-) rename pkgs/{tools/networking => by-name/pe}/persepolis/0001-Allow-building-on-darwin.patch (100%) rename pkgs/{tools/networking => by-name/pe}/persepolis/0002-Fix-startup-crash-on-darwin.patch (100%) rename pkgs/{tools/networking => by-name/pe}/persepolis/0003-Search-PATH-for-aria2c-on-darwin.patch (100%) rename pkgs/{tools/networking => by-name/pe}/persepolis/0004-Search-PATH-for-ffmpeg-on-darwin.patch (100%) rename pkgs/{tools/networking/persepolis/default.nix => by-name/pe/persepolis/package.nix} (92%) diff --git a/pkgs/tools/networking/persepolis/0001-Allow-building-on-darwin.patch b/pkgs/by-name/pe/persepolis/0001-Allow-building-on-darwin.patch similarity index 100% rename from pkgs/tools/networking/persepolis/0001-Allow-building-on-darwin.patch rename to pkgs/by-name/pe/persepolis/0001-Allow-building-on-darwin.patch diff --git a/pkgs/tools/networking/persepolis/0002-Fix-startup-crash-on-darwin.patch b/pkgs/by-name/pe/persepolis/0002-Fix-startup-crash-on-darwin.patch similarity index 100% rename from pkgs/tools/networking/persepolis/0002-Fix-startup-crash-on-darwin.patch rename to pkgs/by-name/pe/persepolis/0002-Fix-startup-crash-on-darwin.patch diff --git a/pkgs/tools/networking/persepolis/0003-Search-PATH-for-aria2c-on-darwin.patch b/pkgs/by-name/pe/persepolis/0003-Search-PATH-for-aria2c-on-darwin.patch similarity index 100% rename from pkgs/tools/networking/persepolis/0003-Search-PATH-for-aria2c-on-darwin.patch rename to pkgs/by-name/pe/persepolis/0003-Search-PATH-for-aria2c-on-darwin.patch diff --git a/pkgs/tools/networking/persepolis/0004-Search-PATH-for-ffmpeg-on-darwin.patch b/pkgs/by-name/pe/persepolis/0004-Search-PATH-for-ffmpeg-on-darwin.patch similarity index 100% rename from pkgs/tools/networking/persepolis/0004-Search-PATH-for-ffmpeg-on-darwin.patch rename to pkgs/by-name/pe/persepolis/0004-Search-PATH-for-ffmpeg-on-darwin.patch diff --git a/pkgs/tools/networking/persepolis/default.nix b/pkgs/by-name/pe/persepolis/package.nix similarity index 92% rename from pkgs/tools/networking/persepolis/default.nix rename to pkgs/by-name/pe/persepolis/package.nix index 79d936ee3b1a..0aa47b37fe17 100644 --- a/pkgs/tools/networking/persepolis/default.nix +++ b/pkgs/by-name/pe/persepolis/package.nix @@ -1,22 +1,16 @@ { lib , stdenv -, buildPythonApplication +, qt5 +, python3 , fetchFromGitHub , aria2 , ffmpeg , libnotify , pulseaudio -, psutil -, pyqt5 -, requests -, setproctitle -, setuptools , sound-theme-freedesktop -, wrapQtAppsHook -, yt-dlp }: -buildPythonApplication rec { +python3.pkgs.buildPythonApplication rec { pname = "persepolis"; version = "4.0.0"; @@ -56,7 +50,7 @@ buildPythonApplication rec { # prevent double wrapping dontWrapQtApps = true; - nativeBuildInputs = [ wrapQtAppsHook ]; + nativeBuildInputs = [ qt5.wrapQtAppsHook ]; # feed args to wrapPythonApp makeWrapperArgs = [ @@ -76,14 +70,15 @@ buildPythonApplication rec { propagatedBuildInputs = [ pulseaudio + sound-theme-freedesktop + ] ++ (with python3.pkgs; [ psutil pyqt5 requests setproctitle setuptools - sound-theme-freedesktop yt-dlp - ]; + ]); meta = with lib; { description = "A GUI for aria2"; diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index d27dce0cd59a..fcf396fee365 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -6139,10 +6139,6 @@ with pkgs; pcp = callPackage ../tools/misc/pcp { }; - persepolis = python3Packages.callPackage ../tools/networking/persepolis { - wrapQtAppsHook = qt5.wrapQtAppsHook; - }; - pev = callPackage ../development/tools/analysis/pev { }; phd2 = callPackage ../applications/science/astronomy/phd2 { }; From 0535756bb00c8313624e98a4a95b2459a71c60ea Mon Sep 17 00:00:00 2001 From: Felix Uhl Date: Sat, 9 Mar 2024 14:07:50 +0100 Subject: [PATCH 7/7] persepolis: 4.0.0 -> 4.0.1 See https://github.com/persepolisdm/persepolis/releases/tag/4.0.1 This version changed the build system from setuptools to meson. It also fixed notifications on macOS when building from source. This means that two patches could be deleted. --- .../0001-Allow-building-on-darwin.patch | 37 ----------------- .../0002-Fix-startup-crash-on-darwin.patch | 41 ------------------- pkgs/by-name/pe/persepolis/package.nix | 26 +++++------- 3 files changed, 10 insertions(+), 94 deletions(-) delete mode 100644 pkgs/by-name/pe/persepolis/0001-Allow-building-on-darwin.patch delete mode 100644 pkgs/by-name/pe/persepolis/0002-Fix-startup-crash-on-darwin.patch diff --git a/pkgs/by-name/pe/persepolis/0001-Allow-building-on-darwin.patch b/pkgs/by-name/pe/persepolis/0001-Allow-building-on-darwin.patch deleted file mode 100644 index 46790103f3d1..000000000000 --- a/pkgs/by-name/pe/persepolis/0001-Allow-building-on-darwin.patch +++ /dev/null @@ -1,37 +0,0 @@ ---- - setup.py | 13 +++++-------- - 1 file changed, 5 insertions(+), 8 deletions(-) - -diff --git a/setup.py b/setup.py -index 985d28d..933f3df 100755 ---- a/setup.py -+++ b/setup.py -@@ -24,13 +24,9 @@ import shutil - # finding os platform - os_type = platform.system() - --if os_type == 'Linux' or os_type == 'FreeBSD' or os_type == 'OpenBSD': -- from setuptools import setup, Command, find_packages -- setuptools_available = True -- print(os_type + " detected!") --else: -- print('This script is only work for GNU/Linux or BSD!') -- sys.exit(1) -+from setuptools import setup, Command, find_packages -+setuptools_available = True -+print(os_type + " detected!") - - # Checking dependencies! - not_installed = '' -@@ -139,7 +136,7 @@ if sys.argv[1] == "test": - - DESCRIPTION = 'Persepolis Download Manager' - --if os_type == 'Linux': -+if os_type in ['Linux', 'Darwin']: - DATA_FILES = [ - ('/usr/share/man/man1/', ['man/persepolis.1.gz']), - ('/usr/share/applications/', ['xdg/com.github.persepolisdm.persepolis.desktop']), --- -2.39.3 (Apple Git-145) - diff --git a/pkgs/by-name/pe/persepolis/0002-Fix-startup-crash-on-darwin.patch b/pkgs/by-name/pe/persepolis/0002-Fix-startup-crash-on-darwin.patch deleted file mode 100644 index 50252c8cd72a..000000000000 --- a/pkgs/by-name/pe/persepolis/0002-Fix-startup-crash-on-darwin.patch +++ /dev/null @@ -1,41 +0,0 @@ ---- - persepolis/scripts/mac_notification.py | 25 +++++++++---------------- - 1 file changed, 9 insertions(+), 16 deletions(-) - -diff --git a/persepolis/scripts/mac_notification.py b/persepolis/scripts/mac_notification.py -index 4d69929..9a9a7cf 100644 ---- a/persepolis/scripts/mac_notification.py -+++ b/persepolis/scripts/mac_notification.py -@@ -15,20 +15,13 @@ - - # native notification on mac! needs Xcode (latest version) installed and pyobjc - # library from pip --import Foundation --import AppKit --import objc -- --NSUserNotification = objc.lookUpClass('NSUserNotification') --NSUserNotificationCenter = objc.lookUpClass('NSUserNotificationCenter') -- -- - def notifyMac(title, subtitle, info_text, delay=0): -- notification = NSUserNotification.alloc().init() -- notification.setTitle_(title) -- notification.setSubtitle_(subtitle) -- notification.setInformativeText_(info_text) -- notification.setDeliveryDate_(Foundation.NSDate.dateWithTimeInterval_sinceDate_( -- delay, Foundation.NSDate.date())) -- NSUserNotificationCenter.defaultUserNotificationCenter( -- ).scheduleNotification_(notification) -+ print(f""" -+Warning: Persepolis was installed from nixpkgs, which currently breaks notifications -+ on macOS. Until https://github.com/NixOS/nixpkgs/issues/105156 is resolved, -+ this cannot be fixed. The notification that should've been displayed was: -+ -+ title: {title} -+ subtitle: {subtitle} -+ info_text: {info_text} -+ """) --- -2.39.3 (Apple Git-145) - diff --git a/pkgs/by-name/pe/persepolis/package.nix b/pkgs/by-name/pe/persepolis/package.nix index 0aa47b37fe17..3105cd8621f3 100644 --- a/pkgs/by-name/pe/persepolis/package.nix +++ b/pkgs/by-name/pe/persepolis/package.nix @@ -8,39 +8,33 @@ , libnotify , pulseaudio , sound-theme-freedesktop +, pkg-config +, meson +, ninja }: python3.pkgs.buildPythonApplication rec { pname = "persepolis"; - version = "4.0.0"; + version = "4.0.1"; + format = "other"; src = fetchFromGitHub { owner = "persepolisdm"; repo = "persepolis"; - rev = "refs/tags/${version}"; - hash = "sha256-2S6s/tWhI9RBFA26jkwxYTGeaok8S8zv/bY+Zr8TOak="; + rev = "57dc9d438bb3f126070a17c7a3677c45ea4dd332"; + hash = "sha256-7OXAITFQJ2/aY0QmqlAo7if7cY7+T3j6PUjfJJV8Z2Q="; }; patches = [ # Upstream does currently not allow building from source on macOS. These patches can likely # be removed if https://github.com/persepolisdm/persepolis/issues/943 is fixed upstream - ./0001-Allow-building-on-darwin.patch - ./0002-Fix-startup-crash-on-darwin.patch ./0003-Search-PATH-for-aria2c-on-darwin.patch ./0004-Search-PATH-for-ffmpeg-on-darwin.patch ]; postPatch = '' - sed -i "s|'persepolis = persepolis.__main__'|'persepolis = persepolis.scripts.persepolis:main'|" setup.py - - # Automatically answer yes to all interactive questions during setup - substituteInPlace setup.py --replace-fail "answer = input(" "answer = 'y'#" - - # Ensure dependencies with hard-coded FHS paths are properly detected - substituteInPlace setup.py --replace-fail "isdir(notifications_path)" "isdir('${sound-theme-freedesktop}/share/sounds/freedesktop')" - - # Fix oversight in test script (can be removed once https://github.com/persepolisdm/persepolis/pull/942 is merged upstream) - substituteInPlace setup.py --replace-fail "sys.exit('0')" "sys.exit(0)" + # Ensure dependencies with hard-coded FHS dependencies are properly detected + substituteInPlace check_dependencies.py --replace-fail "isdir(notifications_path)" "isdir('${sound-theme-freedesktop}/share/sounds/freedesktop')" ''; postInstall = '' @@ -50,7 +44,7 @@ python3.pkgs.buildPythonApplication rec { # prevent double wrapping dontWrapQtApps = true; - nativeBuildInputs = [ qt5.wrapQtAppsHook ]; + nativeBuildInputs = [ meson ninja pkg-config qt5.wrapQtAppsHook ]; # feed args to wrapPythonApp makeWrapperArgs = [