nixpkgs/pkgs/applications/networking/browsers/qutebrowser/default.nix

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

160 lines
5.0 KiB
Nix
Raw Normal View History

2022-10-06 23:13:00 +00:00
{ stdenv, lib, fetchurl, fetchzip, fetchFromGitHub, python3
, wrapQtAppsHook, glib-networking
, asciidoc, docbook_xml_dtd_45, docbook_xsl, libxml2
, libxslt, gst_all_1 ? null
, withPdfReader ? true
, withMediaPlayback ? true
, backend ? "webengine"
, pipewireSupport ? stdenv.isLinux
, pipewire_0_2
2022-10-06 23:13:00 +00:00
, qtwayland
, mkDerivationWith ? null
, qtbase ? null
, qtwebengine ? null
, wrapGAppsHook ? null
}: let
isQt6 = mkDerivationWith == null;
2015-06-23 01:25:25 +00:00
python3Packages = python3.pkgs;
pdfjs = let
version = "2.14.305";
in
2022-10-06 23:13:00 +00:00
fetchzip {
url = "https://github.com/mozilla/pdf.js/releases/download/v${version}/pdfjs-${version}-dist.zip";
hash = "sha256-E7t+0AUndrgi4zfJth0w28RmWLqLyXMUCnueNf/gNi4=";
stripRoot = false;
2016-08-23 16:18:22 +00:00
};
backendPackage =
2022-10-06 23:13:00 +00:00
if backend == "webengine" then if isQt6 then python3Packages.pyqt6-webengine else python3Packages.pyqtwebengine else
if backend == "webkit" then python3Packages.pyqt5_with_qtwebkit else
throw ''
Unknown qutebrowser backend "${backend}".
Valid choices are qtwebengine (recommended) or qtwebkit.
'';
2022-10-06 23:13:00 +00:00
buildPythonApplication = if isQt6 then python3Packages.buildPythonApplication else mkDerivationWith python3Packages.buildPythonApplication;
pname = "qutebrowser";
2022-10-06 23:13:00 +00:00
version = if isQt6 then "unstable-2022-09-16" else "2.5.2";
2015-06-23 01:25:25 +00:00
2022-10-06 23:13:00 +00:00
in
assert withMediaPlayback -> gst_all_1 != null;
assert isQt6 -> backend != "webkit";
buildPythonApplication {
inherit pname version;
src = if isQt6 then
# comes from qt6-v2 branch of upstream
# https://github.com/qutebrowser/qutebrowser/issues/7202
fetchFromGitHub {
owner = "qutebrowser";
repo = "qutebrowser";
rev = "5e11e6c7d413cf5c77056ba871a545aae1cfd66a";
sha256 = "sha256-5HNzPO07lUQe/Q3Nb4JiS9kb9GMQ5/FqM5029vLNNWo=";
}
2018-01-18 10:17:13 +00:00
# the release tarballs are different from the git checkout!
2022-10-06 23:13:00 +00:00
else fetchurl {
url = "https://github.com/qutebrowser/qutebrowser/releases/download/v${version}/${pname}-${version}.tar.gz";
hash = "sha256-qb/OFN3EA94N6y7t+YPCMc4APgdZmV7H706jTkl06Qg=";
};
# Needs tox
doCheck = false;
buildInputs = [
qtbase
glib-networking
] ++ lib.optionals withMediaPlayback (with gst_all_1; [
gst-plugins-base gst-plugins-good
gst-plugins-bad gst-plugins-ugly gst-libav
]);
nativeBuildInputs = [
wrapQtAppsHook wrapGAppsHook asciidoc
docbook_xml_dtd_45 docbook_xsl libxml2 libxslt
];
2021-01-29 18:04:17 +00:00
propagatedBuildInputs = with python3Packages; ([
pyyaml backendPackage jinja2 pygments
2018-09-12 00:41:03 +00:00
# scripts and userscripts libs
tldextract beautifulsoup4
2022-05-24 03:32:21 +00:00
readability-lxml pykeepass stem
pynacl
2021-01-29 18:04:17 +00:00
# extensive ad blocking
adblock
]
++ lib.optional (pythonOlder "3.9") importlib-resources
2022-10-06 23:13:00 +00:00
++ lib.optional stdenv.isLinux qtwayland
2021-01-29 18:04:17 +00:00
);
patches = [
./fix-restart.patch
];
dontWrapGApps = true;
dontWrapQtApps = true;
postPatch = ''
2020-07-16 16:49:57 +00:00
substituteInPlace qutebrowser/misc/quitter.py --subst-var-by qutebrowser "$out/bin/qutebrowser"
sed -i "s,/usr,$out,g" qutebrowser/utils/standarddir.py
'' + lib.optionalString withPdfReader ''
2016-08-23 16:18:22 +00:00
sed -i "s,/usr/share/pdf.js,${pdfjs},g" qutebrowser/browser/pdfjs.py
'';
postBuild = ''
a2x -f manpage doc/qutebrowser.1.asciidoc
'';
postInstall = ''
install -Dm644 doc/qutebrowser.1 "$out/share/man/man1/qutebrowser.1"
install -Dm644 misc/org.qutebrowser.qutebrowser.desktop \
"$out/share/applications/org.qutebrowser.qutebrowser.desktop"
2018-09-05 17:06:18 +00:00
# Install icons
for i in 16 24 32 48 64 128 256 512; do
2022-10-12 05:24:53 +00:00
install -Dm644 "${lib.optionalString isQt6 "qutebrowser/"}icons/qutebrowser-''${i}x''${i}.png" \
"$out/share/icons/hicolor/''${i}x''${i}/apps/qutebrowser.png"
done
2022-10-12 05:24:53 +00:00
install -Dm644 ${lib.optionalString isQt6 "qutebrowser/"}icons/qutebrowser.svg \
"$out/share/icons/hicolor/scalable/apps/qutebrowser.svg"
2018-09-05 17:06:18 +00:00
# Install scripts
2018-09-12 00:41:03 +00:00
sed -i "s,/usr/bin/,$out/bin/,g" scripts/open_url_in_instance.sh
2022-10-12 05:24:53 +00:00
${lib.optionalString isQt6 "rm -rf scripts/{testbrowser,dev}"}
2018-09-12 00:41:03 +00:00
install -Dm755 -t "$out/share/qutebrowser/scripts/" $(find scripts -type f)
install -Dm755 -t "$out/share/qutebrowser/userscripts/" misc/userscripts/*
2018-09-05 17:06:18 +00:00
2018-09-12 00:41:03 +00:00
# Patch python scripts
2018-09-05 17:06:18 +00:00
buildPythonPath "$out $propagatedBuildInputs"
2018-09-12 00:41:03 +00:00
scripts=$(grep -rl python "$out"/share/qutebrowser/{user,}scripts/)
for i in $scripts; do
patchPythonScript "$i"
2018-09-05 17:06:18 +00:00
done
'';
preFixup = let
libPath = lib.makeLibraryPath [ pipewire_0_2 ];
in
''
2021-04-01 16:28:18 +00:00
makeWrapperArgs+=(
"''${gappsWrapperArgs[@]}"
"''${qtWrapperArgs[@]}"
--add-flags '--backend ${backend}'
--set QUTE_QTWEBENGINE_VERSION_OVERRIDE "${lib.getVersion qtwebengine}"
${lib.optionalString (pipewireSupport && backend == "webengine") ''--prefix LD_LIBRARY_PATH : ${libPath}''}
2021-04-01 16:28:18 +00:00
)
'';
meta = with lib; {
homepage = "https://github.com/The-Compiler/qutebrowser";
description = "Keyboard-focused browser with a minimal GUI";
2018-09-12 00:41:03 +00:00
license = licenses.gpl3Plus;
2021-04-01 16:28:18 +00:00
maintainers = with maintainers; [ jagajaga rnhmjoj ebzzry dotlambda ];
inherit (backendPackage.meta) platforms;
2015-06-23 01:25:25 +00:00
};
}