forked from vlaci/nix-straight.el
-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathsetup.el
46 lines (40 loc) · 2.06 KB
/
setup.el
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
;;; -*- lexical-binding: t; -*-
(require 'json)
(defun nix-straight-get-used-packages (init-file output-file)
(let ((nix-straight--packages nil))
(advice-add 'straight-use-package
:override (lambda (recipe &rest r)
(let ((pkg (if (listp recipe)
(car recipe)
recipe)))
(message "[nix-straight.el] Collecting package '%s' from recipe '%s'" pkg recipe)
(add-to-list 'nix-straight--packages pkg))))
(load init-file nil nil t)
(let ((json-pkgs (if (null nix-straight--packages)
"[]"
(json-encode nix-straight--packages))))
(write-region json-pkgs nil output-file))
nix-straight--packages))
(defun nix-straight-build-packages (init-file)
(setq straight-default-files-directive '("*" (:exclude "*.elc")))
(advice-add 'straight-use-package
:around (lambda (orig-fn &rest r)
(message " [nix-straight.el] Overriding recipe for '%s'" (car r))
(let* ((pkg (car r))
(pkg-name (symbol-name pkg))
(recipe (if (file-exists-p (straight--repos-dir pkg-name))
(list pkg :local-repo pkg-name :repo pkg-name :type 'git)
(list pkg :type 'built-in))))
(message " --> [nix-straight.el] Recipe generated: %s" recipe)
(straight-override-recipe recipe))
(apply orig-fn r)))
(load init-file nil nil t))
;; straight breaks for some reason when
;; it tries to build packages in a nativeComp emacs
(with-eval-after-load "comp"
(advice-add 'straight--native-compile-file-p
:before (lambda (&rest r)
(if (not (boundp 'comp-deferred-compilation-deny-list))
(defvar comp-deferred-compilation-deny-list '())))))
(provide 'setup)
;;; setup.el ends here