For support of imagemagick, which is allows a lot of picture and even gif abilities, picture previews, in Emacs - pretty handy stuff - it is needed to overload Emacs closure and as so - compile it only for enabling that.
Install Emacs.
Run any imagemagic related feature.
Observe that there is no support of it.
helm-M-x: Emacs with ‘imagemagick’ support is required. (libmagickcore, libmagickwand, --with-imagemagick)
- system: `"x86_64-linux"`
- host os: `Linux 4.19.75, NixOS, 20.03pre194293.2436c27541b (Markhor)`
- multi-user?: `yes`
- sandbox: `yes`
- version: `nix-env (Nix) 2.3`
- channels(root): `"nixos, unstable-20.03pre194293.2436c27541b"`
- channels(pyro): `""`
- nixpkgs: `/nix/var/nix/profiles/per-user/root/channels/nixos`
I probably just wanted to analyze myself and hear the thoughts on this.
Probably I would just transform this issue into Emacs linkage issue.
Probably the right thing is to grow the Emacs closure if --with-imagemagic, but it a default case, and imagemagic closure is 630 Mb.
@matthewbauer Please say a word.
Should I include --with-imagemagic and extend Emacs with real Imagemagic support.
Since it would grow the closure, but really enable ImageMagic and extend, improve image and preview support in Emacs.
I made a diff between nix-store closures.
In common they would deduplicate:
cairo
fontconfig
freetype
gdk
glib
glibc
libICE
libjpeg
libpng
librsvg
libSM
libtiff
libX11
libXext
libxml2
zlib
And list of what is new to Emacs closure from ImageMagic:
bzip2
coreutils
djvulibre
fftw
gcc
ilmbase
imagemagick
lcms2
libde265
libwebp
libXt
openexr
openjpeg
xz
_(also why is gcc there, probably should be looked into)_
It seems like it would add ~50-150 MB.
What you would say, powerful by default (include in withX), or customizable (withImageMagic).
About GCC in ImageMagic created a report: https://github.com/NixOS/nixpkgs/issues/70647, it would be solved in time.
@jwiegley Good day, John.
Sorry to bother you, you are the maintainer that was last active regarding Emacs.
What do you think about the two messages above: https://github.com/NixOS/nixpkgs/issues/70631#issuecomment-539070404
I would like to see ImageMagick support included. And on both Darwin (which does not use X) and Linux.
So I suspect the issue is that "shrink-rpath" is removing imagemagick from the RPATH. A quick fix is to add "dontPatchELF" to the Emacs derivation. PatchELF should skip anything that has the DT_NEEDED flag set. Something must be off with ImageMagick that it doesn't get that flag.
One trick you can do to add imagemagick without recompiling is by setting LD_LIBRARY_PATH to the imagemagick directory. Something like LD_LIBRARY_PATH=$(nix-build '<nixpkgs>' -A imagemagick)/lib. I've wondered if setting LD_LIBRARY_PATH=/run/current-system/sw/lib globally would be a good idea? It would probably be controversial and result in bad contamination though.
Ok. I decided that raising lib question is a very dead horse topic. I also contradicted myself there, I've seen imagemagick already a build-dep in code, and wrote description thinking its support is already enabled, but there is no --with-imagemagick set in code, so I do not know why it is done so.
@jwiegley @matthewbauer
I rewrote & downscaled the issue to Emacs stuff.
I'm doing imagemagick because the man did a Telegram client in Emacs: https://github.com/zevlg/telega.el, which is, funny enough, objectively superior to all other Telegram desktop clients includding official app and Web service app, superior by implemented Telegram features.
Mainly I just want to be able to message people without waking them up. But that it is in Emacs is a bonus.
It looks like this can be closed safely, there's
pkgs.emacs.override { imagemagick = pkgs.imagemagickBig; }
which adds imagemagick support (at least it works for telega). @Anton-Latukha, can you try it?
@cab404 this works for me. I was using home manager and set program.emacs.package = pkgs.emacs.override { imagemagick = pkgs.imagemagickBig; }.
To easily check if this worked the following elisp should return t
(image-type-available-p 'imagemagick)
@cab404
You mentioned, "at least it works for telega".
'cuz I tried some time ago, telega server failed to build on NixOS. As an example, telega upstream doc mentions:
It will install headers to /usr/local/include and library itself into /usr/local/lib. These paths are hardcoded in telega.el.
AFAIR that is not the only hardcode place.
Upstream things are so upstream.
Is it working for you on NixOS and how you achieved it?
@Anton-Latukha
Is it working for you on NixOS and how you achieved it?
https://gitlab.com/cab404/nixos-config/-/blob/a7eaa0990fa9f1cda1e383ef2d01403a2b2aaf26/home.nix
telega changes: 13, 61, 260
It's pretty much the same in system config
@cab404
Aha.
Thanks.
@cab404
Aha.
Thanks.
So, that worked?
@cab404
Kind of...
Telega starts to intialize. But fails with error code:
error in process filter: telega--authorization-ready: TDLib version=1.5.0 < 1.6.0 (min required), please upgrade TDLib and recompile ‘telega-server’
error in process filter: TDLib version=1.5.0 < 1.6.0 (min required), please upgrade TDLib and recompile ‘telega-server’
I'm sitting on the current nixos-unstable and current TDLib is 1.6.0.
So it seems state in the link you provided needs additionally an old TDLib.
I would try up-to-date emacsPackages.telega, as you did now. I was puzzled before, and now I now know that Emacs uses both own package repo as also Emacs packages installed through NixOS. I've seen today that NixOS Emacs in package-directory-list from the get-go already provides a proper NixOS path to find provided Emacs NixPkgs.
...
Yep, it works.
This issue is also affecting emacs when using EXWM. I added a PR that fixes this and am happy for contributions (@exwm-people)
@moritzschaefer Does that actually solve the problem for you?
I use EXWM (but not through the module) and haven't been able to get my Emacs to reliably build with ImageMagick support at all.
@tazjin The code from the PR above #94648 does work for me (I can zoom in images in emacs and it doesnt complain about missing imagemagick-support anymore)
Most helpful comment
This issue is also affecting emacs when using EXWM. I added a PR that fixes this and am happy for contributions (@exwm-people)