about summary refs log tree commit diff
path: root/pkgs/applications
diff options
context:
space:
mode:
authorDamien Cassou <damien@cassou.me>2016-10-07 17:23:19 +0200
committerGitHub <noreply@github.com>2016-10-07 17:23:19 +0200
commit0e69fb2f196d553e1db04aff46f50868aec42424 (patch)
tree7643a64b709b9031a5742153bb1f54081666af6c /pkgs/applications
parenteca0f17ad20e9604a60efa57c7fa717ee2c8f1b7 (diff)
parentf5a98e49f6e31b67369978cb4aae9287393e1114 (diff)
downloadnixlib-0e69fb2f196d553e1db04aff46f50868aec42424.tar
nixlib-0e69fb2f196d553e1db04aff46f50868aec42424.tar.gz
nixlib-0e69fb2f196d553e1db04aff46f50868aec42424.tar.bz2
nixlib-0e69fb2f196d553e1db04aff46f50868aec42424.tar.lz
nixlib-0e69fb2f196d553e1db04aff46f50868aec42424.tar.xz
nixlib-0e69fb2f196d553e1db04aff46f50868aec42424.tar.zst
nixlib-0e69fb2f196d553e1db04aff46f50868aec42424.zip
Merge pull request #18985 from dudebout/emacs-with-c-src
emacs: add an option to install the C source
Diffstat (limited to 'pkgs/applications')
-rw-r--r--pkgs/applications/editors/emacs/default.nix21
-rw-r--r--pkgs/applications/editors/emacs/site-start.el24
2 files changed, 40 insertions, 5 deletions
diff --git a/pkgs/applications/editors/emacs/default.nix b/pkgs/applications/editors/emacs/default.nix
index 4a729ba3da3f..08223ef82ef0 100644
--- a/pkgs/applications/editors/emacs/default.nix
+++ b/pkgs/applications/editors/emacs/default.nix
@@ -6,6 +6,7 @@
 , withGTK2 ? true, gtk2 ? null
 , withGTK3 ? false, gtk3 ? null
 , withXwidgets ? false, webkitgtk24x ? null, wrapGAppsHook ? null, glib_networking ? null
+, withCsrc ? true
 , srcRepo ? false, autoconf ? null, automake ? null, texinfo ? null
 }:
 
@@ -24,7 +25,9 @@ let
     else "lucid";
 in
 stdenv.mkDerivation rec {
-  name = "emacs-25.1";
+  name = "emacs-${version}${versionModifier}";
+  version = "25.1";
+  versionModifier = "";
 
   src = fetchurl {
     url = "mirror://gnu//emacs/${name}.tar.xz";
@@ -71,9 +74,23 @@ stdenv.mkDerivation rec {
     done
   '';
 
+  installTargets = "tags install";
+
   postInstall = ''
-    mkdir -p $out/share/emacs/site-lisp/
+    mkdir -p $out/share/emacs/site-lisp
     cp ${./site-start.el} $out/share/emacs/site-lisp/site-start.el
+    $out/bin/emacs --batch -f batch-byte-compile $out/share/emacs/site-lisp/site-start.el
+
+    rm -rf $out/var
+    rm -rf $out/share/emacs/${version}/site-lisp
+  '' + lib.optionalString withCsrc ''
+    for srcdir in src lisp lwlib ; do
+      dstdir=$out/share/emacs/${version}/$srcdir
+      mkdir -p $dstdir
+      find $srcdir -name "*.[chm]" -exec cp {} $dstdir \;
+      cp $srcdir/TAGS $dstdir
+      echo '((nil . ((tags-file-name . "TAGS"))))' > $dstdir/.dir-locals.el
+    done
   '' + lib.optionalString stdenv.isDarwin ''
     mkdir -p $out/Applications
     mv nextstep/Emacs.app $out/Applications
diff --git a/pkgs/applications/editors/emacs/site-start.el b/pkgs/applications/editors/emacs/site-start.el
index 023d6412ed84..b41ca92db086 100644
--- a/pkgs/applications/editors/emacs/site-start.el
+++ b/pkgs/applications/editors/emacs/site-start.el
@@ -1,4 +1,4 @@
-;; NixOS specific load-path
+;;; NixOS specific load-path
 (setq load-path
       (append (reverse (mapcar (lambda (x) (concat x "/share/emacs/site-lisp/"))
                                (split-string (or (getenv "NIX_PROFILES") ""))))
@@ -11,7 +11,25 @@
                                   (split-string (or (getenv "NIX_PROFILES") ""))))
                  woman-manpath)))
 
-;; Make tramp work for remote NixOS machines
-;;; NOTE: You might want to add 
+;;; Make tramp work for remote NixOS machines
 (eval-after-load 'tramp
   '(add-to-list 'tramp-remote-path "/run/current-system/sw/bin"))
+
+;;; C source directory
+;;;
+;;; Computes the location of the C source directory from the path of
+;;; the current file:
+;;; from: /nix/store/<hash>-emacs-<version>/share/emacs/site-lisp/site-start.el
+;;; to:   /nix/store/<hash>-emacs-<version>/share/emacs/<version>/src/
+(let ((emacs
+       (file-name-directory                      ;; .../emacs/
+        (directory-file-name                     ;; .../emacs/site-lisp
+         (file-name-directory load-file-name)))) ;; .../emacs/site-lisp/
+      (version
+       (file-name-as-directory
+        (concat
+         (number-to-string emacs-major-version)
+         "."
+         (number-to-string emacs-minor-version))))
+      (src (file-name-as-directory "src")))
+  (setq find-function-C-source-directory (concat emacs version src)))