persepolis: fix build and startup on darwin

Notifications will be broken until
https://github.com/NixOS/nixpkgs/issues/105156 is resolved.

ZHF: #265948

authored by Felix Uhl and committed by Weijia Wang 89f02336 e5f2b7e7

+126 -3
+45
pkgs/tools/networking/persepolis/0001-Allow-building-on-darwin.patch
··· 1 + --- 2 + setup.py | 13 +++++-------- 3 + 1 file changed, 5 insertions(+), 8 deletions(-) 4 + 5 + diff --git a/setup.py b/setup.py 6 + index 985d28d..933f3df 100755 7 + --- a/setup.py 8 + +++ b/setup.py 9 + @@ -24,13 +24,9 @@ import shutil 10 + # finding os platform 11 + os_type = platform.system() 12 + 13 + -if os_type == 'Linux' or os_type == 'FreeBSD' or os_type == 'OpenBSD': 14 + - from setuptools import setup, Command, find_packages 15 + - setuptools_available = True 16 + - print(os_type + " detected!") 17 + -else: 18 + - print('This script is only work for GNU/Linux or BSD!') 19 + - sys.exit(1) 20 + +from setuptools import setup, Command, find_packages 21 + +setuptools_available = True 22 + +print(os_type + " detected!") 23 + 24 + # Checking dependencies! 25 + not_installed = '' 26 + @@ -100,6 +96,7 @@ else: 27 + print('paplay is found!') 28 + 29 + # sound-theme-freedesktop 30 + +notifications_path = '' 31 + if os_type == 'Linux': 32 + notifications_path = '/usr/share/sounds/freedesktop/stereo/' 33 + elif os_type == 'FreeBSD' or os_type == 'OpenBSD': 34 + @@ -139,7 +136,7 @@ if sys.argv[1] == "test": 35 + 36 + DESCRIPTION = 'Persepolis Download Manager' 37 + 38 + -if os_type == 'Linux': 39 + +if os_type in ['Linux', 'Darwin']: 40 + DATA_FILES = [ 41 + ('/usr/share/man/man1/', ['man/persepolis.1.gz']), 42 + ('/usr/share/applications/', ['xdg/com.github.persepolisdm.persepolis.desktop']), 43 + -- 44 + 2.39.3 (Apple Git-145) 45 +
+41
pkgs/tools/networking/persepolis/0002-Fix-startup-crash-on-darwin.patch
··· 1 + --- 2 + persepolis/scripts/mac_notification.py | 25 +++++++++---------------- 3 + 1 file changed, 9 insertions(+), 16 deletions(-) 4 + 5 + diff --git a/persepolis/scripts/mac_notification.py b/persepolis/scripts/mac_notification.py 6 + index 4d69929..9a9a7cf 100644 7 + --- a/persepolis/scripts/mac_notification.py 8 + +++ b/persepolis/scripts/mac_notification.py 9 + @@ -15,20 +15,13 @@ 10 + 11 + # native notification on mac! needs Xcode (latest version) installed and pyobjc 12 + # library from pip 13 + -import Foundation 14 + -import AppKit 15 + -import objc 16 + - 17 + -NSUserNotification = objc.lookUpClass('NSUserNotification') 18 + -NSUserNotificationCenter = objc.lookUpClass('NSUserNotificationCenter') 19 + - 20 + - 21 + def notifyMac(title, subtitle, info_text, delay=0): 22 + - notification = NSUserNotification.alloc().init() 23 + - notification.setTitle_(title) 24 + - notification.setSubtitle_(subtitle) 25 + - notification.setInformativeText_(info_text) 26 + - notification.setDeliveryDate_(Foundation.NSDate.dateWithTimeInterval_sinceDate_( 27 + - delay, Foundation.NSDate.date())) 28 + - NSUserNotificationCenter.defaultUserNotificationCenter( 29 + - ).scheduleNotification_(notification) 30 + + print(f""" 31 + +Warning: Persepolis was installed from nixpkgs, which currently breaks notifications 32 + + on macOS. Until https://github.com/NixOS/nixpkgs/issues/105156 is resolved, 33 + + this cannot be fixed. The notification that should've been displayed was: 34 + + 35 + + title: {title} 36 + + subtitle: {subtitle} 37 + + info_text: {info_text} 38 + + """) 39 + -- 40 + 2.39.3 (Apple Git-145) 41 +
+29
pkgs/tools/networking/persepolis/0003-Search-PATH-for-aria2c-on-darwin.patch
··· 1 + --- 2 + persepolis/scripts/download.py | 10 +--------- 3 + 1 file changed, 1 insertion(+), 9 deletions(-) 4 + 5 + diff --git a/persepolis/scripts/download.py b/persepolis/scripts/download.py 6 + index aaabb35..69676d3 100644 7 + --- a/persepolis/scripts/download.py 8 + +++ b/persepolis/scripts/download.py 9 + @@ -72,16 +72,8 @@ def startAria(): 10 + 11 + # in macintosh 12 + elif os_type == 'Darwin': 13 + - if aria2_path == "" or aria2_path == None or os.path.isfile(str(aria2_path)) == False: 14 + - 15 + - cwd = sys.argv[0] 16 + - current_directory = os.path.dirname(cwd) 17 + - aria2d = os.path.join(current_directory, 'aria2c') 18 + 19 + - else: 20 + - aria2d = aria2_path 21 + - 22 + - subprocess.Popen([aria2d, '--no-conf', 23 + + subprocess.Popen(['aria2c', '--no-conf', 24 + '--enable-rpc', '--rpc-listen-port=' + str(port), 25 + '--rpc-max-request-size=2M', 26 + '--rpc-listen-all', '--quiet=true'], 27 + -- 28 + 2.39.3 (Apple Git-145) 29 +
+11 -3
pkgs/tools/networking/persepolis/default.nix
··· 1 - { lib, stdenv, buildPythonApplication, fetchFromGitHub 1 + { lib 2 + , stdenv 3 + , buildPythonApplication 4 + , fetchFromGitHub 2 5 , aria 3 6 , libnotify 4 7 , pulseaudio ··· 30 33 substituteInPlace setup.py --replace "answer = input(" "answer = 'y'#" 31 34 ''; 32 35 36 + patches = lib.optionals stdenv.isDarwin [ 37 + ./0001-Allow-building-on-darwin.patch 38 + ./0002-Fix-startup-crash-on-darwin.patch 39 + ./0003-Search-PATH-for-aria2c-on-darwin.patch 40 + ]; 41 + 33 42 postPatch = '' 34 43 sed -i 's|/usr/share/sounds/freedesktop/stereo/|${sound-theme-freedesktop}/share/sounds/freedesktop/stereo/|' setup.py 35 44 sed -i "s|'persepolis = persepolis.__main__'|'persepolis = persepolis.scripts.persepolis:main'|" setup.py ··· 46 55 47 56 # feed args to wrapPythonApp 48 57 makeWrapperArgs = [ 49 - "--prefix PATH : ${lib.makeBinPath [aria libnotify ]}" 58 + "--prefix PATH : ${lib.makeBinPath [ aria libnotify ]}" 50 59 "\${qtWrapperArgs[@]}" 51 60 ]; 52 61 ··· 64 73 meta = with lib; { 65 74 description = "Persepolis Download Manager is a GUI for aria2"; 66 75 homepage = "https://persepolisdm.github.io/"; 67 - broken = stdenv.isDarwin; # Upstream’s build scripts check and fail on Darwin. 68 76 license = licenses.gpl3; 69 77 maintainers = [ ]; 70 78 };