Write packages.el

This commit is contained in:
Marien Zwart 2024-03-24 14:09:50 +11:00
parent 672c49d8ac
commit 023d4185de
No known key found for this signature in database

24
cli.el
View file

@ -7,13 +7,13 @@
((output-directory ("-o" dir) "Directory to dump into.")
(&flag full? ("--full")))
"Dump intermediates for nix-doom-emacs-unstraightened."
(let* ((packages (doom-package-list full?))
(let* ((all-packages (doom-package-list full?))
;; For built-in packages, the :ignore property is the location of the
;; built-in library, which is a Nix store path. We do not want that
;; path to escape: avoid it by just filtering ignored packages here.
(packages (seq-remove (lambda (p) (or (plist-get (cdr p) :ignore)
(plist-get (cdr p) :disable)))
packages))
all-packages))
;; For recipes with :files, print it to a string before json-encode.
;; Otherwise it is serialized as a plist if it starts with :defaults.
;; We either ignore this or pass it to melpa2nix in a recipe.
@ -31,4 +31,22 @@
packages))
(json (json-encode packages))
(json-path (expand-file-name "packages.json" output-directory)))
(write-region json nil json-path)))
(write-region json nil json-path)
(with-temp-buffer
(insert ";;; packages.el -*- no-byte-compile: t; -*-
;; Package list generated by nix-doom-emacs-unstraightened.
;; Disabled packages:
")
(dolist (kp packages)
(when (plist-get (cdr kp) :disable)
(insert "(package! " (symbol-name (car kp)) " :disable t)\n")))
(insert "
;; Packages installed by nix-doom-emacs-unstraightened or ignored by you:
")
(dolist (kp packages)
(let ((p (cdr kp)))
(when (not (plist-get p :disable))
(insert "(package! " (symbol-name (car kp)) " :ignore t)\n"))))
(write-region nil nil (expand-file-name "packages.el" output-directory)))))