diff options
author | Eric Seidel <gridaphobe@gmail.com> | 2015-02-17 15:06:27 -0800 |
---|---|---|
committer | Eric Seidel <gridaphobe@gmail.com> | 2015-02-17 15:08:55 -0800 |
commit | 76a501acdb6b38689aa24e0c331d83149499aabc (patch) | |
tree | c5a664928f0a65bc98ca4e6ca6f008a43e5d0b7f /pkgs/build-support | |
parent | 07ebc363c829f5ccc2ff829e9ca28f7a3cc008c3 (diff) | |
download | nixlib-76a501acdb6b38689aa24e0c331d83149499aabc.tar nixlib-76a501acdb6b38689aa24e0c331d83149499aabc.tar.gz nixlib-76a501acdb6b38689aa24e0c331d83149499aabc.tar.bz2 nixlib-76a501acdb6b38689aa24e0c331d83149499aabc.tar.lz nixlib-76a501acdb6b38689aa24e0c331d83149499aabc.tar.xz nixlib-76a501acdb6b38689aa24e0c331d83149499aabc.tar.zst nixlib-76a501acdb6b38689aa24e0c331d83149499aabc.zip |
reorganize emacs packages and add some meta info
Diffstat (limited to 'pkgs/build-support')
-rw-r--r-- | pkgs/build-support/melpa/default.nix | 104 | ||||
-rw-r--r-- | pkgs/build-support/melpa/melpa2nix.el | 36 | ||||
-rw-r--r-- | pkgs/build-support/melpa/setup-hook.sh | 7 |
3 files changed, 147 insertions, 0 deletions
diff --git a/pkgs/build-support/melpa/default.nix b/pkgs/build-support/melpa/default.nix new file mode 100644 index 000000000000..11cb14f93db4 --- /dev/null +++ b/pkgs/build-support/melpa/default.nix @@ -0,0 +1,104 @@ +# generic builder for Emacs packages + +{ stdenv, fetchurl, emacs, texinfo +, extension ? (self : super : {}) +}: + +{ pname +, version +, src +, packageRequires ? [] +, extraBuildInputs ? [] + +, files ? null +, fileSpecs ? [ "*.el" "*.el.in" "dir" + "*.info" "*.texi" "*.texinfo" + "doc/dir" "doc/*.info" "doc/*.texi" "doc/*.texinfo" + ] + +, meta ? {} + +, preUnpack ? "", postUnpack ? "" +, patches ? [], patchPhase ? "", prePatch ? "", postPatch ? "" +, configureFlags ? [], preConfigure ? "", postConfigure ? "" +, buildPhase ? "", preBuild ? "", postBuild ? "" +, preInstall ? "", postInstall ? "" +, doCheck ? false, checkPhase ? "", preCheck ? "", postCheck ? "" +, preFixup ? "", postFixup ? "" +}: + +let + inherit (stdenv.lib) concatStringsSep optionalAttrs; + + packageBuild = fetchurl { + url = https://raw.githubusercontent.com/milkypostman/melpa/12a862e5c5c62ce627dab83d7cf2cca6e8b56c47/package-build.el; + sha256 = "1nviyyprypz7nmam9rwli4yv3kxh170glfbznryrp4czxkrjjdhk"; + }; + + fname = "${pname}-${version}"; + + targets = concatStringsSep " " (if files == null then fileSpecs else files); + + defaultMeta = { + broken = false; + homepage = "http://melpa.org/#/${pname}"; + platforms = emacs.meta.platforms; + }; + +in + +stdenv.mkDerivation ({ + name = "emacs-${fname}"; + + inherit src packageBuild; + + buildInputs = [emacs texinfo] ++ packageRequires ++ extraBuildInputs; + propagatedBuildInputs = packageRequires; + propagatedUserEnvPkgs = packageRequires; + + setupHook = ./setup-hook.sh; + + buildPhase = '' + runHook preBuild + + emacs --batch -Q -l $packageBuild -l ${./melpa2nix.el} \ + -f melpa2nix-build-package \ + ${pname} ${version} ${targets} + + runHook postBuild + ''; + + installPhase = '' + runHook preInstall + + emacs --batch -Q -l $packageBuild -l ${./melpa2nix.el} \ + -f melpa2nix-install-package \ + ${fname}.* $out/share/emacs/site-lisp/elpa + + runHook postInstall + ''; + + meta = defaultMeta // meta; +} + +// optionalAttrs (preUnpack != "") { inherit preUnpack; } +// optionalAttrs (postUnpack != "") { inherit postUnpack; } +// optionalAttrs (configureFlags != []) { inherit configureFlags; } +// optionalAttrs (patches != []) { inherit patches; } +// optionalAttrs (patchPhase != "") { inherit patchPhase; } +// optionalAttrs (prePatch != "") { inherit prePatch; } +// optionalAttrs (postPatch != "") { inherit postPatch; } +// optionalAttrs (preConfigure != "") { inherit preConfigure; } +// optionalAttrs (postConfigure != "") { inherit postConfigure; } +// optionalAttrs (buildPhase != "") { inherit buildPhase; } +// optionalAttrs (preBuild != "") { inherit preBuild; } +// optionalAttrs (postBuild != "") { inherit postBuild; } +// optionalAttrs (doCheck) { inherit doCheck; } +// optionalAttrs (checkPhase != "") { inherit checkPhase; } +// optionalAttrs (preCheck != "") { inherit preCheck; } +// optionalAttrs (postCheck != "") { inherit postCheck; } +// optionalAttrs (preInstall != "") { inherit preInstall; } +// optionalAttrs (postInstall != "") { inherit postInstall; } +// optionalAttrs (preFixup != "") { inherit preFixup; } +// optionalAttrs (postFixup != "") { inherit postFixup; } +) diff --git a/pkgs/build-support/melpa/melpa2nix.el b/pkgs/build-support/melpa/melpa2nix.el new file mode 100644 index 000000000000..d54e9d21e25e --- /dev/null +++ b/pkgs/build-support/melpa/melpa2nix.el @@ -0,0 +1,36 @@ +(require 'package) +(package-initialize) + +(require 'package-build) + +(setq package-build-working-dir (expand-file-name ".") + package-build-archive-dir (expand-file-name ".")) + +(defun melpa2nix-install-package () + (if (not noninteractive) + (error "`melpa2nix-install-package' is to be used only with -batch")) + (pcase command-line-args-left + (`(,archive ,elpa) + (progn (setq package-user-dir elpa) + (package-install-file archive))))) + +(defun melpa2nix-build-package () + (if (not noninteractive) + (error "`melpa2nix-build-package' is to be used only with -batch")) + (pcase command-line-args-left + (`(,package ,version . ,files) + (melpa2nix-package-build-archive package version files)))) + +(defun melpa2nix-package-build-archive (name version files) + "Build a package archive for package NAME." + (pb/message "\n;;; %s\n" name) + (let* ((start-time (current-time)) + (archive-entry (package-build-package name + version + files + package-build-working-dir + package-build-archive-dir))) + + (pb/message "Built in %.3fs, finished at %s" + (time-to-seconds (time-since start-time)) + (current-time-string)))) diff --git a/pkgs/build-support/melpa/setup-hook.sh b/pkgs/build-support/melpa/setup-hook.sh new file mode 100644 index 000000000000..defef45b55f5 --- /dev/null +++ b/pkgs/build-support/melpa/setup-hook.sh @@ -0,0 +1,7 @@ +addEmacsVars () { + if test -d $1/share/emacs/site-lisp; then + export EMACSLOADPATH="$1/share/emacs/site-lisp:$EMACSLOADPATH" + fi +} + +envHooks+=(addEmacsVars) |