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
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
)
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
)))
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
)
35 (let ((flag (getenv "turnCompilationWarningToError")))
37 ;; we do not use `string-empty-p' because it requires subr-x in Emacs <= 26
38 (not (string= flag
"")))
39 (setq byte-compile-error-on-warn t
)))
41 (let ((flag (getenv "ignoreCompilationError")))
42 (when (string= flag
"")
43 (setq byte-compile-debug t
)))