nixpkgs mirror (for testing) github.com/NixOS/nixpkgs
nix
at devShellTools-shell 171 lines 4.5 kB view raw
1{ 2 stdenv, 3 lib, 4 fetchurl, 5 fetchzip, 6 python3, 7 glib-networking, 8 asciidoc, 9 docbook_xml_dtd_45, 10 docbook_xsl, 11 desktopToDarwinBundle, 12 libxml2, 13 libxslt, 14 withPdfReader ? true, 15 pipewireSupport ? stdenv.hostPlatform.isLinux, 16 pipewire, 17 qt6Packages, 18 enableWideVine ? false, 19 widevine-cdm, 20 # can cause issues on some graphics chips 21 enableVulkan ? false, 22 vulkan-loader, 23}: 24 25let 26 isQt6 = lib.versions.major qt6Packages.qtbase.version == "6"; 27 pdfjs = 28 let 29 version = "5.3.31"; 30 in 31 fetchzip { 32 url = "https://github.com/mozilla/pdf.js/releases/download/v${version}/pdfjs-${version}-dist.zip"; 33 hash = "sha256-8QNFCIRSaF0y98P1mmx0u+Uf0/Zd7nYlFGXp9SkURTc="; 34 stripRoot = false; 35 }; 36 37 version = "3.5.1"; 38in 39 40python3.pkgs.buildPythonApplication { 41 pname = "qutebrowser" + lib.optionalString (!isQt6) "-qt5"; 42 inherit version; 43 pyproject = true; 44 45 src = fetchurl { 46 url = "https://github.com/qutebrowser/qutebrowser/releases/download/v${version}/qutebrowser-${version}.tar.gz"; 47 hash = "sha256-gmu6MooINXJI1eWob6qwpzZVSXQ5rVTSaeISBVkms44="; 48 }; 49 50 # Needs tox 51 doCheck = false; 52 53 buildInputs = [ 54 qt6Packages.qtbase 55 glib-networking 56 ] 57 ++ lib.optionals stdenv.hostPlatform.isLinux [ 58 qt6Packages.qtwayland 59 ]; 60 61 build-system = with python3.pkgs; [ 62 setuptools 63 ]; 64 65 nativeBuildInputs = [ 66 qt6Packages.wrapQtAppsHook 67 asciidoc 68 docbook_xml_dtd_45 69 docbook_xsl 70 libxml2 71 libxslt 72 ] 73 ++ lib.optional stdenv.hostPlatform.isDarwin desktopToDarwinBundle; 74 75 dependencies = with python3.pkgs; [ 76 colorama 77 pyyaml 78 (if isQt6 then pyqt6-webengine else pyqtwebengine) 79 jinja2 80 pygments 81 # scripts and userscripts libs 82 tldextract 83 beautifulsoup4 84 readability-lxml 85 pykeepass 86 stem 87 pynacl 88 # extensive ad blocking 89 adblock 90 # for the qute-bitwarden user script to be able to copy the TOTP token to clipboard 91 pyperclip 92 ]; 93 94 patches = [ 95 ./fix-restart.patch 96 ]; 97 98 dontWrapQtApps = true; 99 100 postPatch = '' 101 substituteInPlace qutebrowser/misc/quitter.py --subst-var-by qutebrowser "$out/bin/qutebrowser" 102 103 sed -i "s,/usr,$out,g" qutebrowser/utils/standarddir.py 104 '' 105 + lib.optionalString withPdfReader '' 106 sed -i "s,/usr/share/pdf.js,${pdfjs},g" qutebrowser/browser/pdfjs.py 107 ''; 108 109 installPhase = '' 110 runHook preInstall 111 112 make -f misc/Makefile \ 113 PYTHON=${(python3.pythonOnBuildForHost.withPackages (ps: with ps; [ setuptools ])).interpreter} \ 114 PREFIX=. \ 115 DESTDIR="$out" \ 116 DATAROOTDIR=/share \ 117 install 118 119 runHook postInstall 120 ''; 121 122 postInstall = '' 123 # Patch python scripts 124 buildPythonPath "$out $propagatedBuildInputs" 125 scripts=$(grep -rl python "$out"/share/qutebrowser/{user,}scripts/) 126 for i in $scripts; do 127 patchPythonScript "$i" 128 done 129 ''; 130 131 preFixup = 132 let 133 libPath = lib.makeLibraryPath [ pipewire ]; 134 resourcesPath = 135 if (isQt6 && stdenv.hostPlatform.isDarwin) then 136 "${qt6Packages.qtwebengine}/lib/QtWebEngineCore.framework/Resources" 137 else 138 "${qt6Packages.qtwebengine}/resources"; 139 in 140 '' 141 makeWrapperArgs+=( 142 # Force the app to use QT_PLUGIN_PATH values from wrapper 143 --unset QT_PLUGIN_PATH 144 "''${qtWrapperArgs[@]}" 145 # avoid persistant warning on starup 146 --set QT_STYLE_OVERRIDE Fusion 147 ${lib.optionalString pipewireSupport ''--prefix LD_LIBRARY_PATH : ${libPath}''} 148 ${lib.optionalString (enableVulkan) '' 149 --prefix LD_LIBRARY_PATH : ${lib.makeLibraryPath [ vulkan-loader ]} 150 --set-default QSG_RHI_BACKEND vulkan 151 ''} 152 ${lib.optionalString enableWideVine ''--add-flags "--qt-flag widevine-path=${widevine-cdm}/share/google/chrome/WidevineCdm/_platform_specific/linux_x64/libwidevinecdm.so"''} 153 --set QTWEBENGINE_RESOURCES_PATH "${resourcesPath}" 154 ) 155 ''; 156 157 meta = { 158 homepage = "https://github.com/qutebrowser/qutebrowser"; 159 changelog = "https://github.com/qutebrowser/qutebrowser/blob/v${version}/doc/changelog.asciidoc"; 160 description = "Keyboard-focused browser with a minimal GUI"; 161 license = lib.licenses.gpl3Plus; 162 mainProgram = "qutebrowser"; 163 platforms = if enableWideVine then [ "x86_64-linux" ] else qt6Packages.qtwebengine.meta.platforms; 164 maintainers = with lib.maintainers; [ 165 jagajaga 166 rnhmjoj 167 ebzzry 168 dotlambda 169 ]; 170 }; 171}