straight.el is a replacement for
package.el which is shipped by default with GNU/Emacs. We also integrate it with
2.1. Bootstrap Code
straight.el is not built into GNU/Emacs, we must install it. This can be achieved with this short snippet.
(defvar bootstrap-version) (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))
2.2. Early Init
This ensures that
package.el isn't used at all.
(setq package-enable-at-startup nil)
use-package is a very nice wrapper over
package.el, but it doesn't work with
straight.el by default. The snippet below will install
use-package but also force it use to use
(straight-use-package 'use-package) (setq straight-use-package-by-default t)
2.4. System Packages
(use-package use-package-ensure-system-package :requires (system-packages))
We'll also write our own function to ensure system packages since the in-built one doesn't work so well.
;; TODO: Must remove calls to this function (defun zamlz/system-packages-ensure (pack &optional binfile args) "Ensure PACK is installed on systemi if BINFILE not found Search for BINFILE with `system-packages-package-installed-p', and install the package if not found. Use ARGS to pass options to the package manager." (interactive "Package to ensure is present: ") (message "This function is depcreated, install %s by other means..." pack)) ;; (if binfile ;; (if (system-packages-package-installed-p binfile) ;; t ;; (system-packages-install pack args)) ;; (if (system-packages-package-installed-p pack) ;; t ;; (system-packages-install pack args))))