Loading pkgs/by-name/z-/z-library-desktop/Info.plist 0 → 100644 +91 −0 Original line number Diff line number Diff line <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> <plist version="1.0"> <dict> <key>CFBundleDisplayName</key> <string>Z-Library</string> <key>CFBundleExecutable</key> <string>Z-Library</string> <key>CFBundleIconFile</key> <string>icon.icns</string> <key>CFBundleIdentifier</key> <string>zlibrary</string> <key>CFBundleInfoDictionaryVersion</key> <string>6.0</string> <key>CFBundleName</key> <string>Z-Library</string> <key>CFBundlePackageType</key> <string>APPL</string> <key>CFBundleShortVersionString</key> <string>@version@</string> <key>CFBundleVersion</key> <string>@version@</string> <key>LSApplicationCategoryType</key> <string>public.app-category.developer-tools</string> <key>LSEnvironment</key> <dict> <key>MallocNanoZone</key> <string>0</string> </dict> <key>LSMinimumSystemVersion</key> <string>10.13</string> <key>NSAppTransportSecurity</key> <dict> <key>NSAllowsArbitraryLoads</key> <true/> <key>NSAllowsLocalNetworking</key> <true/> <key>NSExceptionDomains</key> <dict> <key>127.0.0.1</key> <dict> <key>NSIncludesSubdomains</key> <false/> <key>NSTemporaryExceptionAllowsInsecureHTTPLoads</key> <true/> <key>NSTemporaryExceptionAllowsInsecureHTTPSLoads</key> <false/> <key>NSTemporaryExceptionMinimumTLSVersion</key> <string>1.0</string> <key>NSTemporaryExceptionRequiresForwardSecrecy</key> <false/> </dict> <key>localhost</key> <dict> <key>NSIncludesSubdomains</key> <false/> <key>NSTemporaryExceptionAllowsInsecureHTTPLoads</key> <true/> <key>NSTemporaryExceptionAllowsInsecureHTTPSLoads</key> <false/> <key>NSTemporaryExceptionMinimumTLSVersion</key> <string>1.0</string> <key>NSTemporaryExceptionRequiresForwardSecrecy</key> <false/> </dict> </dict> </dict> <key>NSBluetoothAlwaysUsageDescription</key> <string>This app needs access to Bluetooth</string> <key>NSBluetoothPeripheralUsageDescription</key> <string>This app needs access to Bluetooth</string> <key>NSCameraUsageDescription</key> <string>This app needs access to the camera</string> <key>NSHighResolutionCapable</key> <true/> <key>NSHumanReadableCopyright</key> <string>Copyright © 2024 Deniz Terzi</string> <key>NSMainNibFile</key> <string>MainMenu</string> <key>NSMicrophoneUsageDescription</key> <string>This app needs access to the microphone</string> <key>NSPrincipalClass</key> <string>AtomApplication</string> <key>NSQuitAlwaysKeepsWindows</key> <false/> <key>NSRequiresAquaSystemAppearance</key> <false/> <key>NSSupportsAutomaticGraphicsSwitching</key> <true/> </dict> </plist> pkgs/by-name/z-/z-library-desktop/package.nix 0 → 100644 +88 −0 Original line number Diff line number Diff line { lib, stdenv, fetchurl, fetchFromGitHub, makeBinaryWrapper, replaceVars, dpkg, asar, electron, darwin, libsecret, pkg-config, buildNpmPackage, removeReferencesTo, xcbuild, }: stdenv.mkDerivation (finalAttrs: { pname = "z-library-desktop"; version = "3.1.0"; src = fetchurl { url = "https://web.archive.org/web/20260301212456/https://s3proxy-alp.cdn-zlib.sk/swfs_second_public_files/soft/desktop/Z-Library_3.1.0_amd64.deb"; hash = "sha256-m1axR0HrqHfoz+1tvhCOr1xq0lVkHjxrrf2KnTA7ZVg="; }; nativeBuildInputs = [ dpkg makeBinaryWrapper asar ] ++ lib.optional stdenv.hostPlatform.isDarwin darwin.autoSignDarwinBinariesHook; buildPhase = '' runHook preBuild pushd opt/Z-Library/resources asar e app.asar app rm app.asar popd runHook postBuild ''; installPhase = '' runHook preInstall phome=$out/opt/Z-Library mkdir -p $phome/resources cp -r opt/Z-Library/resources/app $phome/resources makeWrapper ${lib.getExe electron} $out/bin/Z-Library \ --set-default ELECTRON_FORCE_IS_PACKAGED 1 \ --add-flags $phome/resources/app \ --add-flags "\''${NIXOS_OZONE_WL:+\''${WAYLAND_DISPLAY:+--ozone-platform-hint=auto --enable-features=WaylandWindowDecorations --enable-wayland-ime=true}}" \ --inherit-argv0 cp -r usr/* $out substituteInPlace $out/share/applications/Z-Library.desktop \ --replace-fail "/opt/Z-Library/Z-Library" "Z-Library" runHook postInstall ''; postInstall = lib.optionalString stdenv.hostPlatform.isDarwin '' mkdir -p $out/Applications/Z-Library.app/Contents/{MacOS,Resources} ln -s $out/bin/z-library $out/Applications/Z-Library.app/Contents/MacOS/Z-Library ln -s $phome/resources/app/dist/icon.icns $out/Applications/Z-Library.app/Contents/Resources/icon.icns install -Dm444 ${ # Adapted from the dmg package from upstream. # Note that the upstream distributed version for macOS is actually older than those for other systems, # but here we packaged it for macOS using the deb package, so it has the same version as the Linux version. replaceVars ./Info.plist { inherit (finalAttrs) version; } } $out/Applications/Z-Library.app/Contents/Info.plist ''; passthru.updateScript = ./update.rb; meta = { homepage = "https://z-library.sk"; description = "Client for the online library Z-Library"; license = lib.licenses.unfree; # Maintainers on AUR emailed the dev to confirm: https://pastebin.com/ss4Nr8pW platforms = lib.platforms.all; maintainers = with lib.maintainers; [ ulysseszhan ]; mainProgram = "Z-Library"; }; }) pkgs/by-name/z-/z-library-desktop/update.rb 0 → 100755 +79 −0 Original line number Diff line number Diff line #!/usr/bin/env nix-shell #!nix-shell -i ruby -p ruby ruby.gems.nokogiri require 'net/http' require 'nokogiri' PACKAGE = 'z-library-desktop' def log(...) = $stderr.puts(...) def finish(...) = log(...) || exit def archive url log "Archiving #{url} on Wayback Machine..." req = Net::HTTP::Get.new URI "https://web.archive.org/save/#{url}" res = Net::HTTP.start req.uri.host, req.uri.port, use_ssl: true do |http| http.open_timeout = 30 http.read_timeout = 300 # sometimes WM is very slow http.request req end location = res['Content-Location'] return "https://web.archive.org#{location}" if location&.start_with? '/web/' redirect = res['Location'] return redirect if redirect&.include? '/web/' res_url = res.uri.to_s return res_url if res_url&.include? '/web/' end def url_hash url prefetch_hash = `nix-prefetch-url #{url}`.strip `nix --extra-experimental-features nix-command hash convert --hash-algo sha256 #{prefetch_hash}`.strip end def n(attribute) = `nix-instantiate --eval --strict --attr #{PACKAGE}.#{attribute}`.strip.undump nix_file = n('meta.position')[/(.*):\d+$/, 1] current_version = n 'version' current_hash = n 'src.drvAttrs.outputHash' current_url = n 'src.drvAttrs.urls.0' current_homepage = n 'meta.homepage' nix = File.read nix_file wikipedia = Nokogiri::HTML Net::HTTP.get URI 'https://en.wikipedia.org/wiki/Z-Library' url = wikipedia.at_css('.infobox th.infobox-label:contains("URL") + td.infobox-data a[href^="https://"]')&.[] 'href' abort 'Could not find Z-Library URL on Wikipedia page.' unless url abort "Could not update homepage #{current_homepage} -> #{url}" unless nix.sub! current_homepage, url log "Z-Library URL: #{url}" page = Nokogiri::HTML Net::HTTP.get URI url unless page.at_css 'head link[rel="stylesheet"][href*="zaccess.css"]' page = Nokogiri::HTML Net::HTTP.get URI URI.join url, 'z-access' end item = page.at_css '.za-download-link-title:has(> .za-download-link-title-name:contains("Linux"))' abort 'Could not find Linux download link on Z-Library page.' unless item version = item.at_css('.za-download-link-title-version')&.text[/\d+\.\d+\.\d+/] abort 'Could not find version number in Linux download link.' unless version log "Version: #{version}" finish 'Version is up to date.' if version == current_version abort "Could not update version: #{current_version} -> #{version}" unless nix.sub! current_version, version download = item.at_css('a.za-download-href-link[href$=".deb"]')&.[] 'href' abort 'Could not find download link for Linux version.' unless download log "Download link: #{download}" archive_url = archive download abort 'Could not archive download link.' unless archive_url abort "Could not update URL: #{current_url} -> #{archive_url}" unless nix.sub! current_url, archive_url log "Archived download link: #{archive_url}" hash = url_hash download abort "Could not update hash: #{current_hash} -> #{hash}" unless nix.sub! current_hash, hash log "Updated hash: #{hash}" File.write nix_file, nix Loading
pkgs/by-name/z-/z-library-desktop/Info.plist 0 → 100644 +91 −0 Original line number Diff line number Diff line <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> <plist version="1.0"> <dict> <key>CFBundleDisplayName</key> <string>Z-Library</string> <key>CFBundleExecutable</key> <string>Z-Library</string> <key>CFBundleIconFile</key> <string>icon.icns</string> <key>CFBundleIdentifier</key> <string>zlibrary</string> <key>CFBundleInfoDictionaryVersion</key> <string>6.0</string> <key>CFBundleName</key> <string>Z-Library</string> <key>CFBundlePackageType</key> <string>APPL</string> <key>CFBundleShortVersionString</key> <string>@version@</string> <key>CFBundleVersion</key> <string>@version@</string> <key>LSApplicationCategoryType</key> <string>public.app-category.developer-tools</string> <key>LSEnvironment</key> <dict> <key>MallocNanoZone</key> <string>0</string> </dict> <key>LSMinimumSystemVersion</key> <string>10.13</string> <key>NSAppTransportSecurity</key> <dict> <key>NSAllowsArbitraryLoads</key> <true/> <key>NSAllowsLocalNetworking</key> <true/> <key>NSExceptionDomains</key> <dict> <key>127.0.0.1</key> <dict> <key>NSIncludesSubdomains</key> <false/> <key>NSTemporaryExceptionAllowsInsecureHTTPLoads</key> <true/> <key>NSTemporaryExceptionAllowsInsecureHTTPSLoads</key> <false/> <key>NSTemporaryExceptionMinimumTLSVersion</key> <string>1.0</string> <key>NSTemporaryExceptionRequiresForwardSecrecy</key> <false/> </dict> <key>localhost</key> <dict> <key>NSIncludesSubdomains</key> <false/> <key>NSTemporaryExceptionAllowsInsecureHTTPLoads</key> <true/> <key>NSTemporaryExceptionAllowsInsecureHTTPSLoads</key> <false/> <key>NSTemporaryExceptionMinimumTLSVersion</key> <string>1.0</string> <key>NSTemporaryExceptionRequiresForwardSecrecy</key> <false/> </dict> </dict> </dict> <key>NSBluetoothAlwaysUsageDescription</key> <string>This app needs access to Bluetooth</string> <key>NSBluetoothPeripheralUsageDescription</key> <string>This app needs access to Bluetooth</string> <key>NSCameraUsageDescription</key> <string>This app needs access to the camera</string> <key>NSHighResolutionCapable</key> <true/> <key>NSHumanReadableCopyright</key> <string>Copyright © 2024 Deniz Terzi</string> <key>NSMainNibFile</key> <string>MainMenu</string> <key>NSMicrophoneUsageDescription</key> <string>This app needs access to the microphone</string> <key>NSPrincipalClass</key> <string>AtomApplication</string> <key>NSQuitAlwaysKeepsWindows</key> <false/> <key>NSRequiresAquaSystemAppearance</key> <false/> <key>NSSupportsAutomaticGraphicsSwitching</key> <true/> </dict> </plist>
pkgs/by-name/z-/z-library-desktop/package.nix 0 → 100644 +88 −0 Original line number Diff line number Diff line { lib, stdenv, fetchurl, fetchFromGitHub, makeBinaryWrapper, replaceVars, dpkg, asar, electron, darwin, libsecret, pkg-config, buildNpmPackage, removeReferencesTo, xcbuild, }: stdenv.mkDerivation (finalAttrs: { pname = "z-library-desktop"; version = "3.1.0"; src = fetchurl { url = "https://web.archive.org/web/20260301212456/https://s3proxy-alp.cdn-zlib.sk/swfs_second_public_files/soft/desktop/Z-Library_3.1.0_amd64.deb"; hash = "sha256-m1axR0HrqHfoz+1tvhCOr1xq0lVkHjxrrf2KnTA7ZVg="; }; nativeBuildInputs = [ dpkg makeBinaryWrapper asar ] ++ lib.optional stdenv.hostPlatform.isDarwin darwin.autoSignDarwinBinariesHook; buildPhase = '' runHook preBuild pushd opt/Z-Library/resources asar e app.asar app rm app.asar popd runHook postBuild ''; installPhase = '' runHook preInstall phome=$out/opt/Z-Library mkdir -p $phome/resources cp -r opt/Z-Library/resources/app $phome/resources makeWrapper ${lib.getExe electron} $out/bin/Z-Library \ --set-default ELECTRON_FORCE_IS_PACKAGED 1 \ --add-flags $phome/resources/app \ --add-flags "\''${NIXOS_OZONE_WL:+\''${WAYLAND_DISPLAY:+--ozone-platform-hint=auto --enable-features=WaylandWindowDecorations --enable-wayland-ime=true}}" \ --inherit-argv0 cp -r usr/* $out substituteInPlace $out/share/applications/Z-Library.desktop \ --replace-fail "/opt/Z-Library/Z-Library" "Z-Library" runHook postInstall ''; postInstall = lib.optionalString stdenv.hostPlatform.isDarwin '' mkdir -p $out/Applications/Z-Library.app/Contents/{MacOS,Resources} ln -s $out/bin/z-library $out/Applications/Z-Library.app/Contents/MacOS/Z-Library ln -s $phome/resources/app/dist/icon.icns $out/Applications/Z-Library.app/Contents/Resources/icon.icns install -Dm444 ${ # Adapted from the dmg package from upstream. # Note that the upstream distributed version for macOS is actually older than those for other systems, # but here we packaged it for macOS using the deb package, so it has the same version as the Linux version. replaceVars ./Info.plist { inherit (finalAttrs) version; } } $out/Applications/Z-Library.app/Contents/Info.plist ''; passthru.updateScript = ./update.rb; meta = { homepage = "https://z-library.sk"; description = "Client for the online library Z-Library"; license = lib.licenses.unfree; # Maintainers on AUR emailed the dev to confirm: https://pastebin.com/ss4Nr8pW platforms = lib.platforms.all; maintainers = with lib.maintainers; [ ulysseszhan ]; mainProgram = "Z-Library"; }; })
pkgs/by-name/z-/z-library-desktop/update.rb 0 → 100755 +79 −0 Original line number Diff line number Diff line #!/usr/bin/env nix-shell #!nix-shell -i ruby -p ruby ruby.gems.nokogiri require 'net/http' require 'nokogiri' PACKAGE = 'z-library-desktop' def log(...) = $stderr.puts(...) def finish(...) = log(...) || exit def archive url log "Archiving #{url} on Wayback Machine..." req = Net::HTTP::Get.new URI "https://web.archive.org/save/#{url}" res = Net::HTTP.start req.uri.host, req.uri.port, use_ssl: true do |http| http.open_timeout = 30 http.read_timeout = 300 # sometimes WM is very slow http.request req end location = res['Content-Location'] return "https://web.archive.org#{location}" if location&.start_with? '/web/' redirect = res['Location'] return redirect if redirect&.include? '/web/' res_url = res.uri.to_s return res_url if res_url&.include? '/web/' end def url_hash url prefetch_hash = `nix-prefetch-url #{url}`.strip `nix --extra-experimental-features nix-command hash convert --hash-algo sha256 #{prefetch_hash}`.strip end def n(attribute) = `nix-instantiate --eval --strict --attr #{PACKAGE}.#{attribute}`.strip.undump nix_file = n('meta.position')[/(.*):\d+$/, 1] current_version = n 'version' current_hash = n 'src.drvAttrs.outputHash' current_url = n 'src.drvAttrs.urls.0' current_homepage = n 'meta.homepage' nix = File.read nix_file wikipedia = Nokogiri::HTML Net::HTTP.get URI 'https://en.wikipedia.org/wiki/Z-Library' url = wikipedia.at_css('.infobox th.infobox-label:contains("URL") + td.infobox-data a[href^="https://"]')&.[] 'href' abort 'Could not find Z-Library URL on Wikipedia page.' unless url abort "Could not update homepage #{current_homepage} -> #{url}" unless nix.sub! current_homepage, url log "Z-Library URL: #{url}" page = Nokogiri::HTML Net::HTTP.get URI url unless page.at_css 'head link[rel="stylesheet"][href*="zaccess.css"]' page = Nokogiri::HTML Net::HTTP.get URI URI.join url, 'z-access' end item = page.at_css '.za-download-link-title:has(> .za-download-link-title-name:contains("Linux"))' abort 'Could not find Linux download link on Z-Library page.' unless item version = item.at_css('.za-download-link-title-version')&.text[/\d+\.\d+\.\d+/] abort 'Could not find version number in Linux download link.' unless version log "Version: #{version}" finish 'Version is up to date.' if version == current_version abort "Could not update version: #{current_version} -> #{version}" unless nix.sub! current_version, version download = item.at_css('a.za-download-href-link[href$=".deb"]')&.[] 'href' abort 'Could not find download link for Linux version.' unless download log "Download link: #{download}" archive_url = archive download abort 'Could not archive download link.' unless archive_url abort "Could not update URL: #{current_url} -> #{archive_url}" unless nix.sub! current_url, archive_url log "Archived download link: #{archive_url}" hash = url_hash download abort "Could not update hash: #{current_hash} -> #{hash}" unless nix.sub! current_hash, hash log "Updated hash: #{hash}" File.write nix_file, nix