Merge pull request #18985 from dudebout/emacs-with-c-src

emacs: add an option to install the C source
This commit is contained in:
Damien Cassou 2016-10-07 17:23:19 +02:00 committed by GitHub
commit 0e69fb2f19
4 changed files with 42 additions and 30 deletions

View File

@ -6,6 +6,7 @@
, withGTK2 ? true, gtk2 ? null , withGTK2 ? true, gtk2 ? null
, withGTK3 ? false, gtk3 ? null , withGTK3 ? false, gtk3 ? null
, withXwidgets ? false, webkitgtk24x ? null, wrapGAppsHook ? null, glib_networking ? null , withXwidgets ? false, webkitgtk24x ? null, wrapGAppsHook ? null, glib_networking ? null
, withCsrc ? true
, srcRepo ? false, autoconf ? null, automake ? null, texinfo ? null , srcRepo ? false, autoconf ? null, automake ? null, texinfo ? null
}: }:
@ -24,7 +25,9 @@ let
else "lucid"; else "lucid";
in in
stdenv.mkDerivation rec { stdenv.mkDerivation rec {
name = "emacs-25.1"; name = "emacs-${version}${versionModifier}";
version = "25.1";
versionModifier = "";
src = fetchurl { src = fetchurl {
url = "mirror://gnu//emacs/${name}.tar.xz"; url = "mirror://gnu//emacs/${name}.tar.xz";
@ -71,9 +74,23 @@ stdenv.mkDerivation rec {
done done
''; '';
installTargets = "tags install";
postInstall = '' 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 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 '' '' + lib.optionalString stdenv.isDarwin ''
mkdir -p $out/Applications mkdir -p $out/Applications
mv nextstep/Emacs.app $out/Applications mv nextstep/Emacs.app $out/Applications

View File

@ -1,4 +1,4 @@
;; NixOS specific load-path ;;; NixOS specific load-path
(setq load-path (setq load-path
(append (reverse (mapcar (lambda (x) (concat x "/share/emacs/site-lisp/")) (append (reverse (mapcar (lambda (x) (concat x "/share/emacs/site-lisp/"))
(split-string (or (getenv "NIX_PROFILES") "")))) (split-string (or (getenv "NIX_PROFILES") ""))))
@ -11,7 +11,25 @@
(split-string (or (getenv "NIX_PROFILES") "")))) (split-string (or (getenv "NIX_PROFILES") ""))))
woman-manpath))) woman-manpath)))
;; Make tramp work for remote NixOS machines ;;; Make tramp work for remote NixOS machines
;;; NOTE: You might want to add
(eval-after-load 'tramp (eval-after-load 'tramp
'(add-to-list 'tramp-remote-path "/run/current-system/sw/bin")) '(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)))

View File

@ -85,13 +85,14 @@ stdenv.mkDerivation {
done done
siteStart="$out/share/emacs/site-lisp/site-start.el" siteStart="$out/share/emacs/site-lisp/site-start.el"
siteStartByteCompiled="$siteStart"c
# A dependency may have brought the original siteStart, delete it and # A dependency may have brought the original siteStart, delete it and
# create our own # create our own
# Begin the new site-start.el by loading the original, which sets some # Begin the new site-start.el by loading the original, which sets some
# NixOS-specific paths. Paths are searched in the reverse of the order # NixOS-specific paths. Paths are searched in the reverse of the order
# they are specified in, so user and system profile paths are searched last. # they are specified in, so user and system profile paths are searched last.
rm -f $siteStart rm -f $siteStart $siteStartByteCompiled
cat >"$siteStart" <<EOF cat >"$siteStart" <<EOF
(load-file "$emacs/share/emacs/site-lisp/site-start.el") (load-file "$emacs/share/emacs/site-lisp/site-start.el")
(add-to-list 'load-path "$out/share/emacs/site-lisp") (add-to-list 'load-path "$out/share/emacs/site-lisp")

View File

@ -189,30 +189,6 @@ let
}; };
}; };
emacs-source-directory = stdenv.mkDerivation {
name = "emacs-source-directory-1.0.0";
src = emacs.src;
# We don't want accidentally start bulding emacs one more time
phases = "unpackPhase buildPhase";
buildPhase = ''
mkdir -p $out/share/emacs/site-lisp/elpa/emacs-source-directory
cp -a src $out/src
(cd $out/src && ${emacs}/bin/etags *.c *.h)
cat <<EOF > $out/share/emacs/site-lisp/elpa/emacs-source-directory/emacs-source-directory-autoloads.el
(setq source-directory "$out")
(setq find-function-C-source-directory (expand-file-name "src" source-directory))
EOF
cat <<EOF > $out/share/emacs/site-lisp/elpa/emacs-source-directory/emacs-source-directory-pkg.el
(define-package "emacs-source-directory" "1.0.0" "Make emacs C source code available inside emacs. To use with emacsWithPackages in NixOS" '())
EOF
'';
meta = {
description = "Make emacs C source code available inside emacs. To use with emacsWithPackages in NixOS";
};
};
evil-jumper = melpaBuild rec { evil-jumper = melpaBuild rec {
pname = "evil-jumper"; pname = "evil-jumper";
version = "20151017"; version = "20151017";