Switch to managing packages via nix

Remove all instances of adding to package-selected-packages

Remove package config and custom ensure function

Remove Makefile and install.el
This commit is contained in:
Evie Litherland-Smith 2024-12-02 16:38:43 +00:00
parent 13c5f7b9f7
commit 064a358239
3 changed files with 44 additions and 128 deletions

View file

@ -1,9 +0,0 @@
.PHONY: default install clean
default: install
install:
emacs --script install.el --kill
clean:
-rm -rf ./elpa/ ./eln-cache/

View file

@ -12,28 +12,10 @@ Customise =use-package= before first time it's used.
(setopt use-package-check-before-init t
use-package-enable-imenu-support t)
#+end_src
Configure package archives and initialise.
#+begin_src emacs-lisp
(use-package package
:config
(add-to-list 'package-archives '("melpa-stable" . "https://stable.melpa.org/packages/"))
(package-initialize))
(defun my/package-ensure-installed ()
"Ensure packages in `package-selected-packages' are installed."
(interactive)
(require 'package)
(package-autoremove)
(package-upgrade-all nil)
(package-install-selected-packages t))
#+end_src
** Delight for minor-modes
Install =delight= to hide certain minor-modes from modeline
#+begin_src emacs-lisp
(add-to-list 'package-selected-packages 'delight)
(use-package delight
:demand t
:if (package-installed-p 'delight))
@ -105,24 +87,21 @@ Configure the look and feel of Emacs
#+end_src
*** Nerd Icons
#+begin_src emacs-lisp
(add-to-list 'package-selected-packages 'nerd-icons)
(use-package nerd-icons
:if (package-installed-p 'nerd-icons))
(use-package nerd-icons-dired
:if (package-installed-p 'nerd-icons-ibuffer)
:after (nerd-icons dired)
:load-path "external-packages/nerd-icons-dired/"
:commands nerd-icons-dired-mode
:hook (dired-mode . (lambda () (nerd-icons-dired-mode +1))))
(add-to-list 'package-selected-packages 'nerd-icons-ibuffer)
(use-package nerd-icons-ibuffer
:if (package-installed-p 'nerd-icons-ibuffer)
:after nerd-icons
:commands nerd-icons-ibuffer-mode
:hook (ibuffer-mode . (lambda () (nerd-icons-ibuffer-mode +1))))
(add-to-list 'package-selected-packages 'nerd-icons-corfu)
(use-package nerd-icons-corfu
:if (package-installed-p 'nerd-icons-corfu)
:after nerd-icons)
@ -137,7 +116,6 @@ Configure the look and feel of Emacs
#+end_src
*** Visual fill column
#+begin_src emacs-lisp
(add-to-list 'package-selected-packages 'visual-fill-column)
(use-package visual-fill-column
:if (package-installed-p 'visual-fill-column)
:functions (visual-fill-column-mode)
@ -349,8 +327,6 @@ Rules and packages for buffer management and window navigation.
#+end_src
*** Khalel
#+begin_src emacs-lisp
(if (executable-find "khal" nil)
(add-to-list 'package-selected-packages 'khalel))
(use-package khalel
:if (package-installed-p 'khalel)
:after (org-agenda)
@ -753,7 +729,6 @@ Configure email with iCalendar event support, to integrate with
(add-hook 'prog-mode-hook #'(lambda () (display-line-numbers-mode +1)))
(add-to-list 'package-selected-packages 'which-key)
(use-package which-key
:if (package-installed-p 'which-key)
:functions which-key-mode
@ -790,7 +765,6 @@ Configure email with iCalendar event support, to integrate with
space-before-tab
tab-mark)))
(add-to-list 'package-selected-packages 'diff-hl)
(use-package diff-hl
:if (package-installed-p 'diff-hl)
:functions (diff-hl-magit-pre-refresh
@ -924,39 +898,36 @@ Configure email with iCalendar event support, to integrate with
(with-eval-after-load 'khalel
(khalel-add-capture-template))))
(when (or (package-installed-p 'emacsql-sqlite)
(package-installed-p 'emacsql-sqlite-builtin))
(add-to-list 'package-selected-packages 'org-roam)
(use-package org-roam
:if (package-installed-p 'org-roam)
:after org
:defines org-roam-directory
:functions org-roam-db-autosync-mode
:bind-keymap ("C-c n d" . org-roam-dailies-map)
:bind (("C-c n r" . org-roam-capture)
("C-c n f" . org-roam-node-find)
:map org-mode-map
("C-c n i" . org-roam-node-insert)
("C-c n l" . org-roam-buffer-toggle))
:custom
(org-roam-directory (expand-file-name "roam" org-directory))
(org-roam-completion-everywhere nil)
(org-roam-node-display-template (concat
"${title:*} "
(propertize "${tags:24}" 'face 'org-tag)))
(org-roam-capture-templates '(("d" "default" plain "%?"
:target (file+head "${slug}.org" "#+title: ${title}\n")
:unnarrowed t)))
:config
(mkdir org-roam-directory t)
(add-to-list 'display-buffer-alist
'("\\*org-roam\\*"
(display-buffer-in-side-window)
(side . right)
(slot . 0)
(window-width . 0.33)
(window-parameters . ((no-delete-other-windows . t)))))
(org-roam-db-autosync-mode +1)))
(use-package org-roam
:if (package-installed-p 'org-roam)
:after org
:defines org-roam-directory
:functions org-roam-db-autosync-mode
:bind-keymap ("C-c n d" . org-roam-dailies-map)
:bind (("C-c n r" . org-roam-capture)
("C-c n f" . org-roam-node-find)
:map org-mode-map
("C-c n i" . org-roam-node-insert)
("C-c n l" . org-roam-buffer-toggle))
:custom
(org-roam-directory (expand-file-name "roam" org-directory))
(org-roam-completion-everywhere nil)
(org-roam-node-display-template (concat
"${title:*} "
(propertize "${tags:24}" 'face 'org-tag)))
(org-roam-capture-templates '(("d" "default" plain "%?"
:target (file+head "${slug}.org" "#+title: ${title}\n")
:unnarrowed t)))
:config
(mkdir org-roam-directory t)
(add-to-list 'display-buffer-alist
'("\\*org-roam\\*"
(display-buffer-in-side-window)
(side . right)
(slot . 0)
(window-width . 0.33)
(window-parameters . ((no-delete-other-windows . t)))))
(org-roam-db-autosync-mode +1))
(use-package org-roam-dailies
:after org-roam
@ -1028,7 +999,6 @@ Configure email with iCalendar event support, to integrate with
(org-icalendar-combined-name "org-mode")
(org-icalendar-combined-description "Emacs org-mode combined export"))
(add-to-list 'package-selected-packages 'org-noter)
(use-package org-noter
:if (package-installed-p 'org-noter)
:disabled t
@ -1045,7 +1015,6 @@ Configure email with iCalendar event support, to integrate with
(car citar-notes-paths)))
(org-noter-prefer-root-as-file-level nil))
(add-to-list 'package-selected-packages 'citar)
(use-package citar
:if (package-installed-p 'citar)
:defines (citar-bibliography
@ -1119,7 +1088,6 @@ Configure email with iCalendar event support, to integrate with
(setq org-latex-compiler "lualatex")
(setq org-preview-latex-default-process 'dvisvgm)
(add-to-list 'package-selected-packages 'vertico)
(use-package vertico
:if (package-installed-p 'vertico)
:functions vertico-mode
@ -1130,7 +1098,6 @@ Configure email with iCalendar event support, to integrate with
:config
(require 'vertico-directory))
(add-to-list 'package-selected-packages 'marginalia)
(use-package marginalia
:if (package-installed-p 'marginalia)
:functions marginalia-mode
@ -1142,7 +1109,6 @@ Configure email with iCalendar event support, to integrate with
(marginalia-mode +1)
:config (marginalia-mode +1))
(add-to-list 'package-selected-packages 'orderless)
(use-package orderless
:if (package-installed-p 'orderless)
:custom
@ -1152,9 +1118,6 @@ Configure email with iCalendar event support, to integrate with
(eglot (styles orderless))
(eglot-capf (styles orderless)))))
(add-to-list 'package-selected-packages 'corfu)
(add-to-list 'package-selected-packages 'corfu-terminal)
(use-package corfu
:if (package-installed-p 'corfu)
:defines (corfu-map
@ -1212,7 +1175,6 @@ Configure email with iCalendar event support, to integrate with
:after corfu
:functions corfu-terminal-mode)
(add-to-list 'package-selected-packages 'cape)
(use-package cape
:if (package-installed-p 'cape)
:after corfu
@ -1227,9 +1189,6 @@ Configure email with iCalendar event support, to integrate with
:custom
(cape-dabbrev-min-length (+ corfu-auto-prefix 1)))
(add-to-list 'package-selected-packages 'consult)
(add-to-list 'package-selected-packages 'consult-eglot)
(use-package consult
:if (package-installed-p 'consult)
:functions (consult-org-heading
@ -1253,7 +1212,6 @@ Configure email with iCalendar event support, to integrate with
:after (consult eglot)
:bind (("C-c c s" . consult-eglot-symbols)))
(add-to-list 'package-selected-packages 'tempel)
(use-package tempel
:if (package-installed-p 'tempel)
:defines tempel-path
@ -1285,12 +1243,10 @@ Configure email with iCalendar event support, to integrate with
;; :html-head "<link rel=\"stylesheet\" type=\"text/css\" href=\"css/style.css\"/>"
)))
(add-to-list 'package-selected-packages 'rainbow-delimiters)
(use-package rainbow-delimiters
:if (package-installed-p 'rainbow-delimiters)
:hook (prog-mode))
(add-to-list 'package-selected-packages 'envrc)
(use-package envrc
:if (package-installed-p 'envrc)
:hook (after-init . envrc-global-mode)
@ -1307,7 +1263,6 @@ Configure email with iCalendar event support, to integrate with
:custom
(treesit-font-lock-level 3))
(add-to-list 'package-selected-packages 'treesit-auto)
(use-package treesit-auto
:if (package-installed-p 'treesit-auto)
:after treesit
@ -1372,7 +1327,6 @@ Configure email with iCalendar event support, to integrate with
:yapf (:enabled nil)))))
)
(add-to-list 'package-selected-packages 'apheleia)
(use-package apheleia
:if (package-installed-p 'apheleia)
:delight apheleia-mode
@ -1393,9 +1347,6 @@ Configure email with iCalendar event support, to integrate with
(flymake-no-changes-timeout 0.5)
(flymake-show-diagnostics-at-end-of-line 'short))
(add-to-list 'package-selected-packages 'flymake-yamllint)
(add-to-list 'package-selected-packages 'flymake-eslint)
(use-package flymake-shellcheck
:if (package-installed-p 'flymake-shellcheck)
:disabled t
@ -1450,7 +1401,6 @@ Configure email with iCalendar event support, to integrate with
(project-remember-projects-under "~/Projects/" t)
))
(add-to-list 'package-selected-packages 'magit)
(use-package magit
:if (package-installed-p 'magit)
:bind (("C-c g" . magit-status)
@ -1472,27 +1422,21 @@ Configure email with iCalendar event support, to integrate with
("\\`\\(?:sourcehut:\\|sh:\\)\\([^:]+\\)\\'" "git.sr.ht" "sourcehut.user")
("\\`\\(?:gitea:\\|gt:\\)\\([^:]+\\)\\'" "git.xenia.me.uk" "gitea.user"))))
;; (when (or (package-installed-p 'emacsql-sqlite)
;; (package-installed-p 'emacsql-sqlite-builtin))
;; (add-to-list 'package-selected-packages 'forge)
;; (use-package forge
;; :if (package-installed-p 'forge)
;; :after magit))
(use-package forge
:if (package-installed-p 'forge)
:after magit)
(when (executable-find "nix")
(add-to-list 'package-selected-packages 'nix-mode)
(use-package nix-mode
:if (package-installed-p 'nix-mode)
:mode "\\.nix\\'"
:functions nix-prettify-global-mode
:config
(require 'nix)
(require 'nix-flake)
(require 'nix-repl)
(require 'nix-store)
(nix-prettify-global-mode +1)))
(use-package nix-mode
:if (package-installed-p 'nix-mode)
:mode "\\.nix\\'"
:functions nix-prettify-global-mode
:config
(require 'nix)
(require 'nix-flake)
(require 'nix-repl)
(require 'nix-store)
(nix-prettify-global-mode +1))
(add-to-list 'package-selected-packages 'lua-mode)
(use-package lua-mode
:if (package-installed-p 'lua-mode)
:mode "\\.lua\\'")
@ -1546,12 +1490,10 @@ Configure email with iCalendar event support, to integrate with
(doc-view-imenu-enabled t)
(doc-view-scale-internally nil))
(add-to-list 'package-selected-packages 'auctex)
(use-package auctex
:if (package-installed-p 'auctex)
:defer t)
(add-to-list 'package-selected-packages 'markdown-mode)
(use-package markdown-mode
:if (package-installed-p 'markdown-mode)
:hook
@ -1566,7 +1508,6 @@ Configure email with iCalendar event support, to integrate with
(set-face-attribute 'markdown-blockquote-face nil :inherit 'variable-pitch)
(set-face-attribute 'markdown-comment-face nil :inherit 'variable-pitch))
(add-to-list 'package-selected-packages 'pandoc-mode)
(use-package pandoc-mode
:if (package-installed-p 'pandoc-mode)
:after (markdown-mode)
@ -1582,7 +1523,6 @@ Configure email with iCalendar event support, to integrate with
(eww-auto-rename-buffer 'title)
(eww-browse-url-new-window-is-tab nil))
(add-to-list 'package-selected-packages 'scad-mode)
(use-package scad-mode
:if (package-installed-p 'scad-mode)
:defer t)
@ -1590,13 +1530,6 @@ Configure email with iCalendar event support, to integrate with
;; Scratch buffer shortcut
(keymap-global-set "C-c w x" #'scratch-buffer)
;; Shortcut to call `sync-git'
(when (executable-find "sync-git" nil)
(defun my/sync-git ()
"Call `sync-git' shell script"
(interactive)
(shell-command "sync-git")))
;; Config file shortcut
(defun my/open-config-file ()
"Open Emacs config file."

View file

@ -1,8 +0,0 @@
;;; install.el -- Handle installing selected packages -*- lexical-binding: t -*-
;;; Commentary:
;;; Code:
;; Configure packages archives with priority
(load-file (locate-user-emacs-file "init.el"))
(my/package-ensure-installed)
(provide 'install)
;;; install.el ends here