Refactor initialization and bootstrap regarding straight

Thinking of migrating to elpaca, and thought I would make it more approachable.
This commit is contained in:
Howard Abrams 2023-02-23 09:28:00 -08:00
parent ca2288a73f
commit 3e1c6b3fe7
2 changed files with 44 additions and 45 deletions

View file

@ -25,36 +25,9 @@ A literate programming file for bootstraping my Emacs Configuration.
#+end_src
* Introduction
This file contains all the variable definitions and library loading for the other files in my project.
** Straight Package Installer
I'm going to be installing everything using the [[https://github.com/raxod502/straight.el#getting-started][straight.el]] for package installation and management. Before I can /tangle/ these files, I need =straight= to grab the latest =org=, so the following initialization code is actually in [[file:initialize][initialize]], but if you are reading this online, configuring =straight= amounts to the following:
#+begin_src emacs-lisp :tangle no
(defvar bootstrap-version)
I'm installing everything using the [[https://github.com/raxod502/straight.el#getting-started][straight.el]] for package installation and management. This is initialization code configured in [[file:initialize][initialize]], and calls to =use-package= now accepts a =:straight= parameter that allows me to retrieve special versions of some packages.
(let ((bootstrap-file
(expand-file-name "straight/repos/straight.el/bootstrap.el" user-emacs-directory))
(bootstrap-version 5))
(unless (file-exists-p bootstrap-file)
(with-current-buffer
(url-retrieve-synchronously
"https://raw.githubusercontent.com/raxod502/straight.el/develop/install.el"
'silent 'inhibit-cookies)
(goto-char (point-max))
(eval-print-last-sexp)))
(load bootstrap-file nil 'nomessage))
#+end_src
To get the Straight project working with =use-package=:
#+begin_src emacs-lisp :tangle no
(straight-use-package 'use-package)
#+end_src
While the above code enables the =:straight t= extension to =use-package=, let's have that as the default:
#+begin_src emacs-lisp :tangle no
(use-package straight
:custom (straight-use-package-by-default t
straight-default-vc 'git))
#+end_src
See the details in [[https://dev.to/jkreeftmeijer/emacs-package-management-with-straight-el-and-use-package-3oc8][this essay]].
** OS Path and Native Compilation

View file

@ -14,6 +14,49 @@ do
ln -s --force $HAMACS_DIR/$LINK $HAMACS_DEST
done
cat > $HAMACS_DEST/early-init.el <<EOF
;;; early-init.el --- Hamacs Early Init -*- lexical-binding: t; -*-
;;
;;; Commentary:
;;
;; This is my early Emacs configuration file. See init.el for the real
;; boot process. Since we are using straight or elpaca, we just need to
;; stop the normal package process.
;;
;;; Code:
;; We'll be using straight. So, we don't want duplicated package loading:
(setq package-enable-at-startup nil)
;; While I would rather program my configurations, sometimes the Emacs
;; menu system is _good enough_, but I want it in its own file:
(setq custom-file (expand-file-name "custom.el" user-emacs-directory))
(when (file-exists-p custom-file)
(load custom-file))
;; Let's build the \`exec-path' from the _real_ shell path:
EOF
IFS=":" read -r -a PATH_ARRAY <<< "${PATH}"
for P in "${PATH_ARRAY[@]}"
do
echo "(add-to-list 'exec-path \"${P}\")" >> $HAMACS_DEST/early-init.el
done
cat >> $HAMACS_DEST/early-init.el <<EOF
;; Local Variables:
;; no-byte-compile: t
;; no-native-compile: t
;; no-update-autoloads: t
;; End:
;;; early-init.el ends here
EOF
echo Created $HAMACS_DEST/early-init.el
cat > $HAMACS_DEST/init.el <<EOF
;;; init.el --- Hamacs Init -*- lexical-binding: t; -*-
;;
@ -25,23 +68,6 @@ cat > $HAMACS_DEST/init.el <<EOF
;;
;;; Code:
;; We'll be using straight. So, we don't want duplicated package loading:
(setq package-enable-at-startup nil)
;; While I would rather program my configurations, sometimes the Emacs
;; menu system is “good enough”, but I want it in its own file:
(setq custom-file (expand-file-name "custom.el" user-emacs-directory))
(when (file-exists-p custom-file)
(load custom-file))
;; While this path should come from the shell, there seems to be a
;; condition where I need to set this so that Emacs can pull our my
;; compiled files.
(add-to-list 'exec-path "/usr/local/bin")
(setenv "PATH" (concat "/usr/local/bin:" (getenv "PATH")))
(defvar hamacs-source-dir "$HAMACS_DIR" "Where we be.")
;; Configure straight https://github.com/raxod502/straight.el#getting-started