about | blog | config | notes | github

1. Purely Functional Package Manager for the Emacs Hacker!

straight.el is a replacement for package.el which is shipped by default with GNU/Emacs. We also integrate it with use-package and system-packages.

2. Configuration

2.1. Bootstrap Code

Since 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)
         'silent 'inhibit-cookies)
      (goto-char (point-max))
  (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)

2.3. Use-Package Integration

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.el instead.

(straight-use-package 'use-package)
(setq straight-use-package-by-default t)

2.4. System Packages

(use-package 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))))

2.5. Footer

(provide 'init-straight)

Created: 2021-11-13

Emacs 26.1 (Org mode 9.5)