fix(profiles): no bootstrap file for non-bootloaders

If Doom doesn't live in ~/.emacs.d or ~/.config/emacs, then it cannot
play the role of bootloader, so opt out of generating the profile
bootstrappper in this case.

That said, don't disable the profile system entirely; it can still be
useful for internal, noninteractive, and sandbox use.
This commit is contained in:
Henrik Lissner 2022-09-17 14:50:23 +02:00
parent 753b479ea6
commit 36a9637e79
No known key found for this signature in database
GPG key ID: B60957CA074D39A3
3 changed files with 12 additions and 6 deletions

View file

@ -6,7 +6,9 @@
;;; Variables ;;; Variables
(defvar doom-cli-known-profiles-file (defvar doom-cli-known-profiles-file
(file-name-concat doom-cache-dir "known-profiles.el") (file-name-concat doom-cache-dir (format "profiles.%s.el" (or (car doom-profile) "@")))
;; REVIEW: Use `doom-profile-data-dir' in v3
;; (file-name-concat doom-profile-data-dir "known-profiles.el")
"TODO") "TODO")
@ -68,8 +70,6 @@
(dolist (p removed) (print! (item "Removed %S") (car p))) (dolist (p removed) (print! (item "Removed %S") (car p)))
(dolist (p changed) (print! (item "Changed %S") (car p))) (dolist (p changed) (print! (item "Changed %S") (car p)))
(doom-file-write doom-cli-known-profiles-file (list new-profiles) :mode #o600) (doom-file-write doom-cli-known-profiles-file (list new-profiles) :mode #o600)
(print! (success "Regenerated profile manifest: %s")
(path doom-cli-known-profiles-file))
(doom-profiles-save new-profiles doom-profiles-bootstrap-file) (doom-profiles-save new-profiles doom-profiles-bootstrap-file)
(print! (success "Regenerated profile init file: %s") (print! (success "Regenerated profile init file: %s")
(path doom-profiles-bootstrap-file))))))))) (path doom-profiles-bootstrap-file)))))))))

View file

@ -45,7 +45,8 @@ OPTIONS:
Defaults to the maximum number of threads (or 1, if your CPU's threadcount Defaults to the maximum number of threads (or 1, if your CPU's threadcount
can't be determined)." can't be determined)."
:benchmark t :benchmark t
(call! '(profiles sync "--reload")) (when (doom-profiles-bootloadable-p)
(call! '(profiles sync "--reload")))
(run-hooks 'doom-before-sync-hook) (run-hooks 'doom-before-sync-hook)
(add-hook 'kill-emacs-hook #'doom-sync--abort-warning-h) (add-hook 'kill-emacs-hook #'doom-sync--abort-warning-h)
(when jobs (when jobs

View file

@ -74,6 +74,12 @@ run.")
;; ;;
;;; Helpers ;;; Helpers
(defun doom-profiles-bootloadable-p ()
"Return non-nil if `doom-emacs-dir' can be a bootloader."
(with-memoization (get 'doom 'bootloader)
(or (file-equal-p doom-emacs-dir "~/.config/emacs")
(file-equal-p doom-emacs-dir "~/.emacs.d"))))
(defun doom-profiles-read (&rest paths) (defun doom-profiles-read (&rest paths)
"TODO" "TODO"
(let (profiles) (let (profiles)
@ -218,8 +224,7 @@ is non-nil, refresh the cache."
(--defer-vars--)))))))) (--defer-vars--))))))))
(lambda () (lambda ()
(if (or noninteractive (if (or noninteractive
(file-equal-p user-emacs-directory "~/.config/emacs") (,(symbol-function #'doom-profiles-bootloadable-p)))
(file-equal-p user-emacs-directory "~/.emacs.d"))
(user-error "Failed to find profile: %s" (getenv "DOOMPROFILE")) (user-error "Failed to find profile: %s" (getenv "DOOMPROFILE"))
(user-error "To be a bootloader, Doom must be installed in ~/.config/emacs or ~/.emacs.d")))))) (user-error "To be a bootloader, Doom must be installed in ~/.config/emacs or ~/.emacs.d"))))))
:mode #o600 :mode #o600