From caed1528a3beb14b349bdfd76ce1caf7b7f9ea50 Mon Sep 17 00:00:00 2001 From: Jan Malakhovski Date: Tue, 18 Aug 2015 20:37:49 +0000 Subject: [PATCH 1/2] w3m: fix w3mimgdisplay, refactor the expression, make batch and nox versions, use batch version where appropriate --- .../networking/browsers/w3m/default.nix | 36 +++++++++++-------- .../networking/browsers/w3m/no-x11.patch | 15 ++++++++ pkgs/top-level/all-packages.nix | 26 +++++++++++--- 3 files changed, 59 insertions(+), 18 deletions(-) create mode 100644 pkgs/applications/networking/browsers/w3m/no-x11.patch diff --git a/pkgs/applications/networking/browsers/w3m/default.nix b/pkgs/applications/networking/browsers/w3m/default.nix index 32deafffe907..e71a733970ee 100644 --- a/pkgs/applications/networking/browsers/w3m/default.nix +++ b/pkgs/applications/networking/browsers/w3m/default.nix @@ -1,16 +1,18 @@ { stdenv, fetchurl -, sslSupport ? true -, graphicsSupport ? false -, mouseSupport ? false -, ncurses, openssl ? null, boehmgc, gettext, zlib -, imlib2 ? null, xlibsWrapper ? null, fbcon ? null -, gpm-ncurses ? null +, ncurses, boehmgc, gettext, zlib +, sslSupport ? true, openssl ? null +, graphicsSupport ? true, imlib2 ? null +, x11Support ? graphicsSupport, libX11 ? null +, mouseSupport ? true, gpm-ncurses ? null }: assert sslSupport -> openssl != null; -assert graphicsSupport -> imlib2 != null && (xlibsWrapper != null || fbcon != null); +assert graphicsSupport -> imlib2 != null; +assert x11Support -> graphicsSupport && libX11 != null; assert mouseSupport -> gpm-ncurses != null; +with stdenv.lib; + stdenv.mkDerivation rec { name = "w3m-0.5.3"; @@ -24,16 +26,19 @@ stdenv.mkDerivation rec { patches = [ ./glibc214.patch ] # Patch for the newer unstable boehm-gc 7.2alpha. Not all platforms use that # alpha. At the time of writing this, boehm-gc-7.1 is the last stable. - ++ stdenv.lib.optional (boehmgc.name != "boehm-gc-7.1") [ ./newgc.patch ] - ++ stdenv.lib.optional stdenv.isCygwin ./cygwin.patch; + ++ optional (boehmgc.name != "boehm-gc-7.1") [ ./newgc.patch ] + ++ optional stdenv.isCygwin ./cygwin.patch + # for frame buffer only version + ++ optional (graphicsSupport && !x11Support) [ ./no-x11.patch ]; buildInputs = [ncurses boehmgc gettext zlib] - ++ stdenv.lib.optional sslSupport openssl - ++ stdenv.lib.optional mouseSupport gpm-ncurses - ++ stdenv.lib.optionals graphicsSupport [imlib2 xlibsWrapper fbcon]; + ++ optional sslSupport openssl + ++ optional mouseSupport gpm-ncurses + ++ optional graphicsSupport imlib2 + ++ optional x11Support libX11; configureFlags = "--with-ssl=${openssl} --with-gc=${boehmgc}" - + stdenv.lib.optionalString graphicsSupport " --enable-image=x11,fb"; + + optionalString graphicsSupport " --enable-image=${optionalString x11Support "x11,"}fb"; preConfigure = '' substituteInPlace ./configure --replace "/lib /usr/lib /usr/local/lib /usr/ucblib /usr/ccslib /usr/ccs/lib /lib64 /usr/lib64" /no-such-path @@ -42,7 +47,10 @@ stdenv.mkDerivation rec { enableParallelBuilding = false; - meta = with stdenv.lib; { + # for w3mimgdisplay + LIBS = optionalString x11Support "-lX11"; + + meta = { homepage = http://w3m.sourceforge.net/; description = "A text-mode web browser"; maintainers = [ maintainers.mornfall ]; diff --git a/pkgs/applications/networking/browsers/w3m/no-x11.patch b/pkgs/applications/networking/browsers/w3m/no-x11.patch new file mode 100644 index 000000000000..83b3e96821f5 --- /dev/null +++ b/pkgs/applications/networking/browsers/w3m/no-x11.patch @@ -0,0 +1,15 @@ +Forget about X11 in fb module. +This breaks w3mimgdisplay under X11, but removes X11 dependency it in pure fb. +diff --git a/w3mimg/fb/fb_imlib2.c b/w3mimg/fb/fb_imlib2.c +index ea36637..d3d7bc3 100644 +--- a/w3mimg/fb/fb_imlib2.c ++++ b/w3mimg/fb/fb_imlib2.c +@@ -3,7 +3,7 @@ + fb_imlib2.c 0.3 Copyright (C) 2002, hito + **************************************************************************/ + +-#include ++#define X_DISPLAY_MISSING + #include + #include "fb.h" + #include "fb_img.h" diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 71535d831678..f372eaad368e 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -924,6 +924,7 @@ let asciidoc = callPackage ../tools/typesetting/asciidoc { inherit (pythonPackages) matplotlib numpy aafigure recursivePthLoader; + w3m = w3m-batch; enableStandardFeatures = false; }; @@ -3143,7 +3144,9 @@ let stricat = callPackage ../tools/security/stricat { }; - privoxy = callPackage ../tools/networking/privoxy { }; + privoxy = callPackage ../tools/networking/privoxy { + w3m = w3m-batch; + }; swaks = callPackage ../tools/networking/swaks { }; @@ -3597,7 +3600,7 @@ let xmlstarlet = callPackage ../tools/text/xml/xmlstarlet { }; xmlto = callPackage ../tools/typesetting/xmlto { - w3m = w3m.override { graphicsSupport = false; }; + w3m = w3m-batch; }; xmltv = callPackage ../tools/misc/xmltv { }; @@ -13388,8 +13391,21 @@ let vym = callPackage ../applications/misc/vym { }; - w3m = callPackage ../applications/networking/browsers/w3m { + w3m = callPackage ../applications/networking/browsers/w3m { }; + + # Should always be the version with the most features + w3m-full = w3m; + + # Version without X11 + w3m-nox = w3m.override { + x11Support = false; + }; + + # Version for batch text processing, not a good browser + w3m-batch = w3m.override { graphicsSupport = false; + x11Support = false; + mouseSupport = false; }; weechat = callPackage ../applications/networking/irc/weechat { @@ -13592,7 +13608,9 @@ let xdg-user-dirs = callPackage ../tools/X11/xdg-user-dirs { }; - xdg_utils = callPackage ../tools/X11/xdg-utils { }; + xdg_utils = callPackage ../tools/X11/xdg-utils { + w3m = w3m-batch; + }; xdotool = callPackage ../tools/X11/xdotool { }; From 244fba351c341dfc76efe3f1e7a7711368e36edd Mon Sep 17 00:00:00 2001 From: Jan Malakhovski Date: Wed, 25 Nov 2015 23:35:36 +0000 Subject: [PATCH 2/2] nixos: use w3m-nox for the manual --- nixos/modules/services/misc/nixos-manual.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nixos/modules/services/misc/nixos-manual.nix b/nixos/modules/services/misc/nixos-manual.nix index 7534eb0ae6a3..3e1f53e79f3e 100644 --- a/nixos/modules/services/misc/nixos-manual.nix +++ b/nixos/modules/services/misc/nixos-manual.nix @@ -117,7 +117,7 @@ in services.mingetty.helpLine = mkIf cfg.showManual "\nPress for the NixOS manual."; - services.nixosManual.browser = mkDefault "${pkgs.w3m}/bin/w3m"; + services.nixosManual.browser = mkDefault "${pkgs.w3m-nox}/bin/w3m"; };