typioca: 2.7.0 -> 2.8.0
[NixPkgs.git] / pkgs / build-support / emacs / elpa2nix.el
blob64587c0fad1a725fc5ef50681a40a20d92c81af5
1 (require 'package)
2 (package-initialize)
4 (defun elpa2nix-install-package ()
5 (if (not noninteractive)
6 (error "`elpa2nix-install-package' is to be used only with -batch"))
7 (pcase command-line-args-left
8 (`(,archive ,elpa)
9 (progn (setq package-user-dir elpa)
10 (elpa2nix-install-file archive)))))
12 (defun elpa2nix-install-from-buffer ()
13 "Install a package from the current buffer."
14 (let ((pkg-desc (if (derived-mode-p 'tar-mode)
15 (package-tar-file-info)
16 (package-buffer-info))))
17 ;; Install the package itself.
18 (package-unpack pkg-desc)
19 pkg-desc))
21 (defun elpa2nix-install-file (file)
22 "Install a package from a file.
23 The file can either be a tar file or an Emacs Lisp file."
24 (let ((is-tar (string-match "\\.tar\\'" file)))
25 (with-temp-buffer
26 (if is-tar
27 (insert-file-contents-literally file)
28 (insert-file-contents file))
29 (when is-tar (tar-mode))
30 (elpa2nix-install-from-buffer))))
32 ;; Allow installing package tarfiles larger than 10MB
33 (setq large-file-warning-threshold nil)