summary refs log tree commit diff
path: root/pkgs/applications/editors/emacs
diff options
context:
space:
mode:
Diffstat (limited to 'pkgs/applications/editors/emacs')
-rw-r--r--pkgs/applications/editors/emacs/at-fdcwd.patch15
-rw-r--r--pkgs/applications/editors/emacs/builder.sh40
-rw-r--r--pkgs/applications/editors/emacs/default.nix109
-rw-r--r--pkgs/applications/editors/emacs/macport-24.5.nix90
-rw-r--r--pkgs/applications/editors/emacs/site-start.el17
5 files changed, 271 insertions, 0 deletions
diff --git a/pkgs/applications/editors/emacs/at-fdcwd.patch b/pkgs/applications/editors/emacs/at-fdcwd.patch
new file mode 100644
index 000000000000..2d8099b73736
--- /dev/null
+++ b/pkgs/applications/editors/emacs/at-fdcwd.patch
@@ -0,0 +1,15 @@
+diff --git a/lib/careadlinkat.h b/lib/careadlinkat.h
+index 84ede3e..8e8f42e 100644
+--- a/lib/careadlinkat.h
++++ b/lib/careadlinkat.h
+@@ -23,6 +23,10 @@
+ #include <fcntl.h>
+ #include <unistd.h>
+ 
++#ifndef AT_FDCWD
++#define AT_FDCWD -2
++#endif
++
+ struct allocator;
+ 
+ /* Assuming the current directory is FD, get the symbolic link value
diff --git a/pkgs/applications/editors/emacs/builder.sh b/pkgs/applications/editors/emacs/builder.sh
new file mode 100644
index 000000000000..545520cca7c0
--- /dev/null
+++ b/pkgs/applications/editors/emacs/builder.sh
@@ -0,0 +1,40 @@
+source $stdenv/setup
+
+# This hook is supposed to be run on Linux. It patches the proper locations of
+# the crt{1,i,n}.o files into the build to ensure that Emacs is linked with
+# *our* versions, not the ones found in the system, as it would do by default.
+# On other platforms, this appears to be unnecessary.
+preConfigure() {
+    ./autogen.sh
+
+    for i in Makefile.in ./src/Makefile.in ./lib-src/Makefile.in ./leim/Makefile.in; do
+        substituteInPlace $i --replace /bin/pwd pwd
+    done
+
+    case "${system}" in
+	x86_64-linux)	glibclibdir=lib64 ;;
+	i686-linux)	glibclibdir=lib ;;
+        *)              return;
+    esac
+
+    libc=$(cat ${NIX_CC}/nix-support/orig-libc)
+    echo "libc: $libc"
+
+    for i in src/s/*.h src/m/*.h; do
+        substituteInPlace $i \
+            --replace /usr/${glibclibdir}/crt1.o $libc/${glibclibdir}/crt1.o \
+            --replace /usr/${glibclibdir}/crti.o $libc/${glibclibdir}/crti.o \
+            --replace /usr/${glibclibdir}/crtn.o $libc/${glibclibdir}/crtn.o \
+            --replace /usr/lib/crt1.o $libc/${glibclibdir}/crt1.o \
+            --replace /usr/lib/crti.o $libc/${glibclibdir}/crti.o \
+            --replace /usr/lib/crtn.o $libc/${glibclibdir}/crtn.o
+    done
+}
+
+preInstall () {
+    for i in Makefile.in ./src/Makefile.in ./lib-src/Makefile.in ./leim/Makefile.in; do
+        substituteInPlace $i --replace /bin/pwd pwd
+    done
+}
+
+genericBuild
diff --git a/pkgs/applications/editors/emacs/default.nix b/pkgs/applications/editors/emacs/default.nix
new file mode 100644
index 000000000000..aa25c96ccb3e
--- /dev/null
+++ b/pkgs/applications/editors/emacs/default.nix
@@ -0,0 +1,109 @@
+{ stdenv, lib, fetchurl, ncurses, xlibsWrapper, libXaw, libXpm, Xaw3d
+, pkgconfig, gettext, libXft, dbus, libpng, libjpeg, libungif
+, libtiff, librsvg, texinfo, gconf, libxml2, imagemagick, gnutls
+, alsaLib, cairo, acl, gpm, AppKit, CoreWLAN, Kerberos, GSS, ImageIO
+, autoconf, automake
+, withX ? !stdenv.isDarwin
+, withGTK3 ? false, gtk3 ? null
+, withXwidgets ? false, webkitgtk24x ? null, wrapGAppsHook ? null, glib_networking ? null
+, withGTK2 ? true, gtk2
+}:
+
+assert (libXft != null) -> libpng != null;      # probably a bug
+assert stdenv.isDarwin -> libXaw != null;       # fails to link otherwise
+assert withGTK2 -> withX || stdenv.isDarwin;
+assert withGTK3 -> withX || stdenv.isDarwin;
+assert withGTK2 -> !withGTK3 && gtk2 != null;
+assert withGTK3 -> !withGTK2 && gtk3 != null;
+assert withXwidgets -> withGTK3 && webkitgtk24x != null;
+
+let
+  toolkit =
+    if withGTK3 then "gtk3"
+    else if withGTK2 then "gtk2"
+    else "lucid";
+in
+stdenv.mkDerivation rec {
+  name = "emacs-25.1";
+
+  builder = ./builder.sh;
+
+  src = fetchurl {
+    url = "mirror://gnu//emacs/${name}.tar.xz";
+    sha256 = "0cwgyiyymnx4xdg99dm2drfxcyhy2jmyf0rkr9fwj9mwwf77kwhr";
+  };
+
+  patches = lib.optionals stdenv.isDarwin [
+    ./at-fdcwd.patch
+  ];
+
+  postPatch = ''
+    substituteInPlace lisp/international/mule-cmds.el \
+      --replace "/usr/share/locale" "${gettext}/share/locale"
+  '';
+
+  buildInputs =
+    [ ncurses gconf libxml2 gnutls alsaLib pkgconfig texinfo acl gpm gettext
+      autoconf automake ]
+    ++ lib.optional stdenv.isLinux dbus
+    ++ lib.optionals withX
+      [ xlibsWrapper libXaw Xaw3d libXpm libpng libjpeg libungif libtiff librsvg libXft
+        imagemagick gconf ]
+    ++ lib.optional (withX && withGTK2) gtk2
+    ++ lib.optional (withX && withGTK3) gtk3
+    ++ lib.optional (stdenv.isDarwin && withX) cairo
+    ++ lib.optionals withXwidgets [ webkitgtk24x wrapGAppsHook glib_networking ];
+
+  propagatedBuildInputs = lib.optionals stdenv.isDarwin [ AppKit GSS ImageIO ];
+
+  hardeningDisable = [ "format" ];
+
+  configureFlags = [ "--with-modules" ] ++
+   (if stdenv.isDarwin
+      then [ "--with-ns" "--disable-ns-self-contained" ]
+    else if withX
+      then [ "--with-x-toolkit=${toolkit}" "--with-xft" ]
+      else [ "--with-x=no" "--with-xpm=no" "--with-jpeg=no" "--with-png=no"
+             "--with-gif=no" "--with-tiff=no" ])
+    ++ lib.optional withXwidgets "--with-xwidgets";
+
+  NIX_CFLAGS_COMPILE = lib.optionalString (stdenv.isDarwin && withX)
+    "-I${cairo.dev}/include/cairo";
+
+  preBuild = ''
+    find . -name '*.elc' -delete
+  '';
+
+  postInstall = ''
+    mkdir -p $out/share/emacs/site-lisp/
+    cp ${./site-start.el} $out/share/emacs/site-lisp/site-start.el
+  '' + lib.optionalString stdenv.isDarwin ''
+    mkdir -p $out/Applications
+    mv nextstep/Emacs.app $out/Applications
+  '';
+
+  meta = with stdenv.lib; {
+    description = "The extensible, customizable GNU text editor";
+    homepage    = http://www.gnu.org/software/emacs/;
+    license     = licenses.gpl3Plus;
+    maintainers = with maintainers; [ chaoflow lovek323 peti the-kenny jwiegley ];
+    platforms   = platforms.all;
+
+    longDescription = ''
+      GNU Emacs is an extensible, customizable text editor—and more.  At its
+      core is an interpreter for Emacs Lisp, a dialect of the Lisp
+      programming language with extensions to support text editing.
+
+      The features of GNU Emacs include: content-sensitive editing modes,
+      including syntax coloring, for a wide variety of file types including
+      plain text, source code, and HTML; complete built-in documentation,
+      including a tutorial for new users; full Unicode support for nearly all
+      human languages and their scripts; highly customizable, using Emacs
+      Lisp code or a graphical interface; a large number of extensions that
+      add other functionality, including a project planner, mail and news
+      reader, debugger interface, calendar, and more.  Many of these
+      extensions are distributed with GNU Emacs; others are available
+      separately.
+    '';
+  };
+}
diff --git a/pkgs/applications/editors/emacs/macport-24.5.nix b/pkgs/applications/editors/emacs/macport-24.5.nix
new file mode 100644
index 000000000000..885538dc8837
--- /dev/null
+++ b/pkgs/applications/editors/emacs/macport-24.5.nix
@@ -0,0 +1,90 @@
+{ stdenv, fetchurl, ncurses, pkgconfig, texinfo, libxml2, gnutls, gettext
+, AppKit, Carbon, Cocoa, IOKit, OSAKit, Quartz, QuartzCore, WebKit
+, ImageCaptureCore, GSS, ImageIO # These may be optional
+}:
+
+stdenv.mkDerivation rec {
+  emacsName = "emacs-24.5";
+  name = "${emacsName}-mac-5.15";
+
+  builder = ./builder.sh;
+
+  src = fetchurl {
+    url = "mirror://gnu/emacs/${emacsName}.tar.xz";
+    sha256 = "0kn3rzm91qiswi0cql89kbv6mqn27rwsyjfb8xmwy9m5s8fxfiyx";
+  };
+
+  macportSrc = fetchurl {
+    url = "ftp://ftp.math.s.chiba-u.ac.jp/emacs/${name}.tar.gz";
+    sha256 = "1r47bm1pf5av2yr37byz91y7bp6vdw9smahiy18g5qp4jp6mz193";
+  };
+
+  enableParallelBuilding = true;
+
+  buildInputs = [ ncurses libxml2 gnutls pkgconfig texinfo gettext ];
+
+  propagatedBuildInputs = [
+    AppKit Carbon Cocoa IOKit OSAKit Quartz QuartzCore WebKit
+    ImageCaptureCore GSS ImageIO   # may be optional
+  ];
+
+  postUnpack = ''
+    mv $emacsName $name
+    tar xzf $macportSrc
+    mv $name $emacsName
+  '';
+
+  postPatch = ''
+    patch -p1 < patch-mac
+    sed -i 's|/usr/share/locale|${gettext}/share/locale|g' lisp/international/mule-cmds.el
+  '';
+
+  configureFlags = [
+    "LDFLAGS=-L${ncurses.out}/lib"
+    "--with-xml2=yes"
+    "--with-gnutls=yes"
+    "--with-mac"
+    "--enable-mac-app=$$out/Applications"
+  ];
+
+  CFLAGS = "-O3 -DMAC_OS_X_VERSION_MAX_ALLOWED=1090";
+  LDFLAGS = "-O3 -L${ncurses.out}/lib";
+
+  postInstall = ''
+    mkdir -p $out/share/emacs/site-lisp/
+    cp ${./site-start.el} $out/share/emacs/site-lisp/site-start.el
+  '';
+
+  doCheck = true;
+
+  meta = with stdenv.lib; {
+    description = "GNU Emacs 24, the extensible, customizable text editor";
+    homepage    = http://www.gnu.org/software/emacs/;
+    license     = licenses.gpl3Plus;
+    maintainers = with maintainers; [ jwiegley ];
+    platforms   = platforms.darwin;
+
+    longDescription = ''
+      GNU Emacs is an extensible, customizable text editor—and more.  At its
+      core is an interpreter for Emacs Lisp, a dialect of the Lisp
+      programming language with extensions to support text editing.
+
+      The features of GNU Emacs include: content-sensitive editing modes,
+      including syntax coloring, for a wide variety of file types including
+      plain text, source code, and HTML; complete built-in documentation,
+      including a tutorial for new users; full Unicode support for nearly all
+      human languages and their scripts; highly customizable, using Emacs
+      Lisp code or a graphical interface; a large number of extensions that
+      add other functionality, including a project planner, mail and news
+      reader, debugger interface, calendar, and more.  Many of these
+      extensions are distributed with GNU Emacs; others are available
+      separately.
+
+      This is "Mac port" addition to GNU Emacs 24. This provides a native
+      GUI support for Mac OS X 10.4 - 10.11. Note that Emacs 23 and later
+      already contain the official GUI support via the NS (Cocoa) port for
+      Mac OS X 10.4 and later. So if it is good enough for you, then you
+      don't need to try this.
+    '';
+  };
+}
diff --git a/pkgs/applications/editors/emacs/site-start.el b/pkgs/applications/editors/emacs/site-start.el
new file mode 100644
index 000000000000..023d6412ed84
--- /dev/null
+++ b/pkgs/applications/editors/emacs/site-start.el
@@ -0,0 +1,17 @@
+;; NixOS specific load-path
+(setq load-path
+      (append (reverse (mapcar (lambda (x) (concat x "/share/emacs/site-lisp/"))
+                               (split-string (or (getenv "NIX_PROFILES") ""))))
+              load-path))
+
+;;; Make `woman' find the man pages
+(eval-after-load 'woman
+  '(setq woman-manpath
+         (append (reverse (mapcar (lambda (x) (concat x "/share/man/"))
+                                  (split-string (or (getenv "NIX_PROFILES") ""))))
+                 woman-manpath)))
+
+;; Make tramp work for remote NixOS machines
+;;; NOTE: You might want to add 
+(eval-after-load 'tramp
+  '(add-to-list 'tramp-remote-path "/run/current-system/sw/bin"))