mirror of
https://github.com/nix-community/nix-doom-emacs
synced 2025-08-09 12:57:26 -05:00
support gccEmacs
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
This commit is contained in:
@ -7,6 +7,12 @@
|
|||||||
;;; have a properly configured user home and environment.
|
;;; have a properly configured user home and environment.
|
||||||
(setq package-check-signature nil)
|
(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)
|
(defun nix-straight-inhibit-kill-emacs (arg)
|
||||||
(message "[nix-doom-emacs] Inhibiting (kill-emacs)"))
|
(message "[nix-doom-emacs] Inhibiting (kill-emacs)"))
|
||||||
|
|
||||||
|
17
default.nix
17
default.nix
@ -94,6 +94,7 @@ let
|
|||||||
fmt = {
|
fmt = {
|
||||||
reset=''\\033[0m'';
|
reset=''\\033[0m'';
|
||||||
bold=''\\033[1m'';
|
bold=''\\033[1m'';
|
||||||
|
red=''\\033[31m'';
|
||||||
green=''\\033[32m'';
|
green=''\\033[32m'';
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -146,6 +147,22 @@ let
|
|||||||
preInstall = ''
|
preInstall = ''
|
||||||
export DOOMDIR=${doomPrivateDir}
|
export DOOMDIR=${doomPrivateDir}
|
||||||
export DOOMLOCALDIR=$out/
|
export DOOMLOCALDIR=$out/
|
||||||
|
|
||||||
|
# Create a bogus $HOME directory because gccEmacs is known to require
|
||||||
|
# an existing home directory because the async worker process don't
|
||||||
|
# fully respect the value of 'comp-eln-load-path'.
|
||||||
|
export HOME=$(mktemp -d)
|
||||||
|
'';
|
||||||
|
postInstall = ''
|
||||||
|
# If gccEmacs or anything would write in $HOME, fail the build.
|
||||||
|
if [[ -z "$(find $HOME -maxdepth 0 -empty)" ]]; then
|
||||||
|
printf "${fmt.red}${fmt.bold}ERROR:${fmt.reset} "
|
||||||
|
printf "${fmt.red}doom-emacs build resulted in files being written in "'$HOME'" of the build sandbox.\n"
|
||||||
|
printf "Contents of "'$HOME'":\n"
|
||||||
|
find $HOME
|
||||||
|
printf ${fmt.reset}
|
||||||
|
exit 33
|
||||||
|
fi
|
||||||
'';
|
'';
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -26,3 +26,12 @@ index c8cfb0495..d8ed107bd 100644
|
|||||||
"Directory for volatile local storage.
|
"Directory for volatile local storage.
|
||||||
|
|
||||||
Use this for files that change often, like cache files. Must end with a slash.")
|
Use this for files that change often, like cache files. Must end with a slash.")
|
||||||
|
@@ -276,7 +276,7 @@ config.el instead."
|
||||||
|
;; Don't store eln files in ~/.emacs.d/eln-cache (they are likely to be purged
|
||||||
|
;; when upgrading Doom).
|
||||||
|
(when (boundp 'comp-eln-load-path)
|
||||||
|
- (add-to-list 'comp-eln-load-path (concat doom-cache-dir "eln/")))
|
||||||
|
+ (add-to-list 'comp-eln-load-path (concat doom-local-dir "cache/eln/")))
|
||||||
|
|
||||||
|
(after! comp
|
||||||
|
;; HACK `comp-eln-load-path' isn't fully respected yet, because native
|
||||||
|
Reference in New Issue
Block a user