1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
|
{ stdenv, lib, fetchurl, fetchzip, python3
, wrapQtAppsHook, glib-networking
, asciidoc, docbook_xml_dtd_45, docbook_xsl, libxml2
, libxslt
, withPdfReader ? true
, pipewireSupport ? stdenv.isLinux
, pipewire
, qtwayland
, qtbase
, qtwebengine
, enableWideVine ? false
, widevine-cdm
# can cause issues on some graphics chips
, enableVulkan ? false
, vulkan-loader
}:
let
isQt6 = lib.versions.major qtbase.version == "6";
pdfjs = let
version = "3.9.179";
in
fetchzip {
url = "https://github.com/mozilla/pdf.js/releases/download/v${version}/pdfjs-${version}-dist.zip";
hash = "sha256-QoJFb7MlZN6lDe2Yalsd10sseukL6+tNRi6JzLPVBYw=";
stripRoot = false;
};
pname = "qutebrowser";
version = "3.0.2";
in
python3.pkgs.buildPythonApplication {
inherit pname version;
src = fetchurl {
url = "https://github.com/qutebrowser/qutebrowser/releases/download/v${version}/${pname}-${version}.tar.gz";
hash = "sha256-pRiT3koSNRmvuDcjuc7SstmPTKUoUnjIHpvdqR7VvFE=";
};
# Needs tox
doCheck = false;
buildInputs = [
qtbase
glib-networking
];
nativeBuildInputs = [
wrapQtAppsHook asciidoc
docbook_xml_dtd_45 docbook_xsl libxml2 libxslt
python3.pkgs.pygments
];
propagatedBuildInputs = with python3.pkgs; ([
pyyaml (if isQt6 then pyqt6-webengine else pyqtwebengine) jinja2 pygments
# scripts and userscripts libs
tldextract beautifulsoup4
readability-lxml pykeepass
stem
pynacl
# extensive ad blocking
adblock
# for the qute-bitwarden user script to be able to copy the TOTP token to clipboard
pyperclip
] ++ lib.optional stdenv.isLinux qtwayland
);
patches = [
./fix-restart.patch
];
dontWrapQtApps = true;
postPatch = ''
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 ''
sed -i "s,/usr/share/pdf.js,${pdfjs},g" qutebrowser/browser/pdfjs.py
'';
installPhase = ''
runHook preInstall
make -f misc/Makefile \
PYTHON=${python3.pythonOnBuildForHost.interpreter} \
PREFIX=. \
DESTDIR="$out" \
DATAROOTDIR=/share \
install
runHook postInstall
'';
postInstall = ''
# Patch python scripts
buildPythonPath "$out $propagatedBuildInputs"
scripts=$(grep -rl python "$out"/share/qutebrowser/{user,}scripts/)
for i in $scripts; do
patchPythonScript "$i"
done
'';
preFixup = let
libPath = lib.makeLibraryPath [ pipewire ];
in
''
makeWrapperArgs+=(
# Force the app to use QT_PLUGIN_PATH values from wrapper
--unset QT_PLUGIN_PATH
"''${qtWrapperArgs[@]}"
# avoid persistant warning on starup
--set QT_STYLE_OVERRIDE Fusion
${lib.optionalString pipewireSupport ''--prefix LD_LIBRARY_PATH : ${libPath}''}
${lib.optionalString (enableVulkan) ''
--prefix LD_LIBRARY_PATH : ${lib.makeLibraryPath [vulkan-loader]}
--set-default QSG_RHI_BACKEND vulkan
''}
${lib.optionalString enableWideVine ''--add-flags "--qt-flag widevine-path=${widevine-cdm}/share/google/chrome/WidevineCdm/_platform_specific/linux_x64/libwidevinecdm.so"''}
)
'';
meta = with lib; {
homepage = "https://github.com/qutebrowser/qutebrowser";
changelog = "https://github.com/qutebrowser/qutebrowser/blob/v${version}/doc/changelog.asciidoc";
description = "Keyboard-focused browser with a minimal GUI";
license = licenses.gpl3Plus;
mainProgram = "qutebrowser";
platforms = if enableWideVine then [ "x86_64-linux" ] else qtwebengine.meta.platforms;
maintainers = with maintainers; [ jagajaga rnhmjoj ebzzry dotlambda nrdxp ];
};
}
|