nix-doom-emacs-unstraightened/build-helpers/dump
Marien Zwart 313b9ef400
Remove "full" build flag
No longer used.
2024-05-27 20:10:59 +10:00

69 lines
3 KiB
Text
Executable file

#!/usr/bin/env doomscript
;; -*- lexical-binding: t; -*-
;; Copyright 2024 Google LLC
;;
;; Licensed under the Apache License, Version 2.0 (the "License");
;; you may not use this file except in compliance with the License.
;; You may obtain a copy of the License at
;;
;; http://www.apache.org/licenses/LICENSE-2.0
;;
;; Unless required by applicable law or agreed to in writing, software
;; distributed under the License is distributed on an "AS IS" BASIS,
;; WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
;; See the License for the specific language governing permissions and
;; limitations under the License.
(require 'json)
(defcli! dump
((output-directory ("-o" dir) "Directory to dump into."))
"Dump intermediates for nix-doom-emacs-unstraightened."
;; Load the user's init.el, or we'll dump only core packages.
(load! doom-module-init-file doom-user-dir t)
(let* ((all-packages (doom-package-list))
;; 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)))
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.
(packages
(mapcar (lambda (p)
(let* ((plist (cdr p))
(recipe (plist-get plist :recipe))
(files (plist-get recipe :files)))
(when files
(setcdr p
(plist-put plist :recipe
(plist-put recipe :files
(prin1-to-string files)))))
p))
packages))
(json (json-encode packages))
(json-path (expand-file-name "packages.json" output-directory)))
(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 all-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 all-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)))))
(run! "dump" (cdr (member "--" argv)))