mirror of
https://github.com/doomemacs/doomemacs
synced 2025-09-24 16:30:58 -05:00
fix(lib): package!: add :env property
Allows the association of arbitrary envvars or variables with the build artifacts of a package. If they change, the package is rebuilt on the next 'doom sync'. This is a temporary measure, which is why this is not touted as a new feature. It will be replaced in v3.
This commit is contained in:
@@ -965,8 +965,14 @@ Must be run from a magit diff buffer."
|
||||
(if-let* ((built
|
||||
(doom-packages--with-recipes recipes (package local-repo recipe)
|
||||
(let ((repo-dir (straight--repos-dir (or local-repo package)))
|
||||
(build-dir (straight--build-dir package)))
|
||||
(build-dir (straight--build-dir package))
|
||||
(build-file ".doompackage"))
|
||||
(unless force-p
|
||||
;; Ensure packages w/ a changed :env are rebuilt
|
||||
(when-let* ((plist (alist-get (intern package) doom-packages)))
|
||||
(unless (equal (plist-get plist :env)
|
||||
(doom-file-read (doom-path build-dir build-file) :by 'read :noerror t))
|
||||
(puthash package t straight--packages-to-rebuild)))
|
||||
;; Ensure packages w/ outdated files/bytecode are rebuilt
|
||||
(let* ((build (if (plist-member recipe :build)
|
||||
(plist-get recipe :build)
|
||||
@@ -1005,7 +1011,25 @@ Must be run from a magit diff buffer."
|
||||
(print! (item "%s: pinned to %s") package pin)
|
||||
(when commit
|
||||
(print! (item "%s: checked out %s") package commit)))))
|
||||
straight-vc-git-post-clone-hook)))
|
||||
straight-vc-git-post-clone-hook))
|
||||
(straight-use-package-prepare-functions
|
||||
(cons (lambda (package &rest _)
|
||||
(when-let* ((plist (alist-get (intern package) doom-packages))
|
||||
(env (plist-get plist :env)))
|
||||
(cl-loop for (var . val) in env
|
||||
if (and (symbolp var)
|
||||
(string-prefix-p "_" (symbol-name var)))
|
||||
do (set-default var val)
|
||||
else if (and (stringp var) val)
|
||||
do (setenv var val))))
|
||||
straight-use-package-prepare-functions))
|
||||
(straight-use-package-post-build-functions
|
||||
(cons (lambda (package &rest _)
|
||||
(when-let* ((plist (alist-get (intern package) doom-packages))
|
||||
(env (plist-get plist :env)))
|
||||
(with-temp-file (straight--build-file package build-file)
|
||||
(prin1 env (current-buffer)))))
|
||||
straight-use-package-post-build-functions)))
|
||||
(straight-use-package (intern package)))
|
||||
(error
|
||||
(signal 'doom-package-error (list package e))))))))
|
||||
|
@@ -61,6 +61,7 @@ Can be changed externally by setting $DOOMPROFILELOADFILE.")
|
||||
;;; Profile storage variables
|
||||
(defvar doom-profile-generators
|
||||
'(("05-vars.auto.el" doom-profile--generate-vars doom--startup-vars)
|
||||
("20-package-envs.auto.el" doom-profile--generate-package-envs)
|
||||
("80-loaddefs.auto.el" doom-profile--generate-loaddefs-doom doom--startup-loaddefs-doom)
|
||||
("90-loaddefs-packages.auto.el" doom-profile--generate-loaddefs-packages doom--startup-loaddefs-packages)
|
||||
("95-modules.auto.el" doom-profile--generate-load-modules doom--startup-modules))
|
||||
@@ -422,6 +423,16 @@ caches them in `doom--profiles'. If RELOAD? is non-nil, refresh the cache."
|
||||
(mapcan #'doom-glob doom-autoloads-files))
|
||||
nil)))))
|
||||
|
||||
(defun doom-profile--generate-package-envs ()
|
||||
(cl-loop for (_ . plist) in doom-packages
|
||||
if (plist-get plist :env)
|
||||
append (cl-loop for (var . val) in it
|
||||
if (and (stringp var) val)
|
||||
collect `(setenv ,var ,val)
|
||||
else if (and (symbolp var)
|
||||
(string-prefix-p "_" (symbol-name var)))
|
||||
collect `(setq-default ,var ,val))))
|
||||
|
||||
(defun doom-profile--generate-loaddefs-packages ()
|
||||
`((defun doom--startup-loaddefs-packages ()
|
||||
(let ((load-in-progress t))
|
||||
|
Reference in New Issue
Block a user