mirror of
https://github.com/nix-community/nix-doom-emacs
synced 2025-08-09 12:57:26 -05:00
If built with gccEmacs, in `straight--native-compile-package` step tries to access $HOME because `comp-eln-load-path` contains "~/.emacs.d/eln-cache/". It errors on this as it is set to a readonly canary value of `/homeless-shellter` in the nix build sandbox. The workaround is twofold: * Ignore `kill-emacs` from optimization. It would result in eln file being written before doom sets up the load path outside of HOME. * The above solution doesn't help in the actual build phase because the worker processes compiling packages does not inherit this value but it is set in them at a later time. This causes the build to fail before `comp-eln-load-path` would be successfully overridden. Having a writable $HOME does not seem to produce any build output there hence the override and the check in `postInstall` to verify that the directory is indeed empty. The runtime value of `comp-eln-load-path` also had to be changed because it is by default is located under the volatile `doom-cache-dir` which is not a part of the derivation so the build time generated `.eln` files couldn't be loaded from that. References: #57
45 lines
2.0 KiB
EmacsLisp
45 lines
2.0 KiB
EmacsLisp
;;; -*- lexical-binding: t; -*-
|
|
|
|
;;; Skip Emacs's own package verification and let Nix do it for us.
|
|
;;;
|
|
;;; Having gnupg around the build triggers Emacs to use it for package signature
|
|
;;; verification. This would not work anyway because the build sandbox does not
|
|
;;; have a properly configured user home and environment.
|
|
(setq package-check-signature nil)
|
|
|
|
;;; For gccEmacs compatibility
|
|
(with-eval-after-load "comp"
|
|
;; The advice for 'kill-emacs would result in eln files being written before
|
|
;; doom would set up proper load paths
|
|
(add-to-list 'comp-never-optimize-functions 'kill-emacs))
|
|
|
|
(defun nix-straight-inhibit-kill-emacs (arg)
|
|
(message "[nix-doom-emacs] Inhibiting (kill-emacs)"))
|
|
|
|
(advice-add 'nix-straight-get-used-packages
|
|
:around (lambda (orig-fn &rest r)
|
|
(message "[nix-doom-emacs] Advising doom installer to gather packages to install...")
|
|
(advice-add 'doom-autoloads-reload
|
|
:override (lambda (&optional file force-p)
|
|
(message "[nix-doom-emacs] Skipping generating autoloads...")))
|
|
(advice-add 'doom--print
|
|
:override (lambda (output)
|
|
(message output)))
|
|
(advice-add 'kill-emacs
|
|
:override #'nix-straight-inhibit-kill-emacs)
|
|
(apply orig-fn r)
|
|
(advice-remove 'kill-emacs 'nix-straight-inhibit-kill-emacs)))
|
|
|
|
(advice-add 'y-or-n-p
|
|
:override (lambda (q)
|
|
(message "%s \n[nix-doom-emacs] --> answering NO" q)
|
|
nil))
|
|
|
|
;;; org is not installed from git, so no fixup is needed
|
|
(advice-add '+org-fix-package-h
|
|
:override (lambda (&rest r)))
|
|
|
|
;; just use straight provided by nix
|
|
(advice-add 'doom-initialize-core-packages
|
|
:override (lambda (&rest r) (require 'straight)))
|