diff options
author | Felix Uhl <github@mail.felix-uhl.de> | 2024-03-05 17:02:33 +0100 |
---|---|---|
committer | Felix Uhl <github@mail.felix-uhl.de> | 2024-04-08 14:54:32 +0200 |
commit | 1e04dc2a54cbf84b041509cce01b89295751f882 (patch) | |
tree | b003722eb0ada1ee946e0a1df2c09230e04682b1 /pkgs/by-name/pe | |
parent | b502a1d4d5f4e4f7f68afc26bbdb1d8bbab421ec (diff) |
persepolis: migrate to by-name
Diffstat (limited to 'pkgs/by-name/pe')
5 files changed, 231 insertions, 0 deletions
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 new file mode 100644 index 0000000000000..46790103f3d12 --- /dev/null +++ b/pkgs/by-name/pe/persepolis/0001-Allow-building-on-darwin.patch @@ -0,0 +1,37 @@ +--- + 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 new file mode 100644 index 0000000000000..50252c8cd72a8 --- /dev/null +++ b/pkgs/by-name/pe/persepolis/0002-Fix-startup-crash-on-darwin.patch @@ -0,0 +1,41 @@ +--- + 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/0003-Search-PATH-for-aria2c-on-darwin.patch b/pkgs/by-name/pe/persepolis/0003-Search-PATH-for-aria2c-on-darwin.patch new file mode 100644 index 0000000000000..505961d1ce6b7 --- /dev/null +++ b/pkgs/by-name/pe/persepolis/0003-Search-PATH-for-aria2c-on-darwin.patch @@ -0,0 +1,29 @@ +--- + persepolis/scripts/download.py | 10 +--------- + 1 file changed, 1 insertion(+), 9 deletions(-) + +diff --git a/persepolis/scripts/download.py b/persepolis/scripts/download.py +index aaabb35..69676d3 100644 +--- a/persepolis/scripts/download.py ++++ b/persepolis/scripts/download.py +@@ -72,16 +72,8 @@ def startAria(): + + # in macintosh + elif os_type == OS.OSX: +- if aria2_path == "" or aria2_path == None or os.path.isfile(str(aria2_path)) == False: +- +- cwd = sys.argv[0] +- current_directory = os.path.dirname(cwd) +- aria2d = os.path.join(current_directory, 'aria2c') + +- else: +- aria2d = aria2_path +- +- subprocess.Popen([aria2d, '--no-conf', ++ subprocess.Popen(['aria2c', '--no-conf', + '--enable-rpc', '--rpc-listen-port=' + str(port), + '--rpc-max-request-size=2M', + '--rpc-listen-all', '--quiet=true'], +-- +2.39.3 (Apple Git-145) + diff --git a/pkgs/by-name/pe/persepolis/0004-Search-PATH-for-ffmpeg-on-darwin.patch b/pkgs/by-name/pe/persepolis/0004-Search-PATH-for-ffmpeg-on-darwin.patch new file mode 100644 index 0000000000000..800f7bddd4086 --- /dev/null +++ b/pkgs/by-name/pe/persepolis/0004-Search-PATH-for-ffmpeg-on-darwin.patch @@ -0,0 +1,34 @@ +--- + persepolis/scripts/mainwindow.py | 2 +- + persepolis/scripts/useful_tools.py | 2 +- + 2 files changed, 2 insertions(+), 2 deletions(-) + +diff --git a/persepolis/scripts/mainwindow.py b/persepolis/scripts/mainwindow.py +index d21f3f4..a0e3674 100644 +--- a/persepolis/scripts/mainwindow.py ++++ b/persepolis/scripts/mainwindow.py +@@ -161,7 +161,7 @@ class CheckVersionsThread(QThread): + + else: + pipe = subprocess.Popen( +- [ffmpeg_path, '-version'], ++ ['ffmpeg', '-version'], + stdout=subprocess.PIPE, + stdin=subprocess.PIPE, + stderr=subprocess.PIPE, +diff --git a/persepolis/scripts/useful_tools.py b/persepolis/scripts/useful_tools.py +index b780967..31733eb 100644 +--- a/persepolis/scripts/useful_tools.py ++++ b/persepolis/scripts/useful_tools.py +@@ -342,7 +342,7 @@ def muxer(parent, video_finder_dictionary): + current_directory = os.path.dirname(cwd) + ffmpeg_path = os.path.join(current_directory, 'ffmpeg') + +- pipe = subprocess.Popen([ffmpeg_path, '-i', video_file_path, ++ pipe = subprocess.Popen(['ffmpeg', '-i', video_file_path, + '-i', audio_file_path, + '-c', 'copy', + '-shortest', +-- +2.39.3 (Apple Git-145) + diff --git a/pkgs/by-name/pe/persepolis/package.nix b/pkgs/by-name/pe/persepolis/package.nix new file mode 100644 index 0000000000000..0aa47b37fe177 --- /dev/null +++ b/pkgs/by-name/pe/persepolis/package.nix @@ -0,0 +1,90 @@ +{ lib +, stdenv +, qt5 +, python3 +, fetchFromGitHub +, aria2 +, ffmpeg +, libnotify +, pulseaudio +, sound-theme-freedesktop +}: + +python3.pkgs.buildPythonApplication rec { + pname = "persepolis"; + version = "4.0.0"; + + src = fetchFromGitHub { + owner = "persepolisdm"; + repo = "persepolis"; + rev = "refs/tags/${version}"; + hash = "sha256-2S6s/tWhI9RBFA26jkwxYTGeaok8S8zv/bY+Zr8TOak="; + }; + + 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)" + ''; + + postInstall = '' + mkdir -p $out/share/applications + cp $src/xdg/com.github.persepolisdm.persepolis.desktop $out/share/applications + ''; + + # prevent double wrapping + dontWrapQtApps = true; + nativeBuildInputs = [ qt5.wrapQtAppsHook ]; + + # feed args to wrapPythonApp + makeWrapperArgs = [ + "--prefix PATH : ${lib.makeBinPath [ aria2 ffmpeg libnotify ]}" + "\${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 + sound-theme-freedesktop + ] ++ (with python3.pkgs; [ + psutil + pyqt5 + requests + setproctitle + setuptools + yt-dlp + ]); + + meta = with lib; { + description = "A GUI for aria2"; + mainProgram = "persepolis"; + homepage = "https://persepolisdm.github.io/"; + license = licenses.gpl3Plus; + maintainers = with maintainers; [ iFreilicht ]; + }; +} |