{ stdenv, fetchurl, ncurses, x11, libXaw, libXpm, Xaw3d , pkgconfig, gtk, libXft, dbus, libpng, libjpeg, libungif , libtiff, librsvg, texinfo, gconf, libxml2, imagemagick, gnutls , alsaLib, cairo , withX ? !stdenv.isDarwin }: assert (libXft != null) -> libpng != null; # probably a bug assert stdenv.isDarwin -> libXaw != null; # fails to link otherwise stdenv.mkDerivation rec { name = "emacs-24.3"; builder = ./builder.sh; src = fetchurl { url = "mirror://gnu/emacs/${name}.tar.xz"; sha256 = "1385qzs3bsa52s5rcncbrkxlydkw0ajzrvfxgv8rws5fx512kakh"; }; buildInputs = [ ncurses gconf libxml2 gnutls alsaLib pkgconfig texinfo ] ++ stdenv.lib.optional stdenv.isLinux dbus ++ stdenv.lib.optionals withX [ x11 libXaw Xaw3d libXpm libpng libjpeg libungif libtiff librsvg libXft imagemagick gtk ] ++ stdenv.lib.optional stdenv.isDarwin cairo; configureFlags = ( if withX then [ "--with-x-toolkit=gtk" "--with-xft"] else [ "--with-x=no" "--with-xpm=no" "--with-jpeg=no" "--with-png=no" "--with-gif=no" "--with-tiff=no" ] ) # On NixOS, help Emacs find `crt*.o'. ++ stdenv.lib.optional (stdenv ? glibc) [ "--with-crt-dir=${stdenv.glibc}/lib" ]; NIX_CFLAGS_COMPILE = stdenv.lib.optionalString (stdenv.isDarwin && withX) "-I${cairo}/include/cairo"; postInstall = '' cat >$out/share/emacs/site-lisp/site-start.el <