From 47b62f5785fef1c72e1116e9b62d8383a2f24470 Mon Sep 17 00:00:00 2001 From: Lin Jian Date: Fri, 20 Sep 2024 18:27:45 +0800 Subject: [PATCH] emacs: fix elisp native compilation errors caused by load-path If $pname-$version/foo.el requires $pname-$version/bar-dir/bar.el, previously there were native compilation errors like the below one because $pname-$version/bar-dir was not added to load-path (only $pname-$version is added). Error: file-missing ("/nix/store/hash-emacs-sly-20240809.2119/share/emacs/site-lisp/elpa/sly-20240809.2119/contrib/sly-mrepl.el" "Cannot open load file" "No such file or directory" "sly-autodoc") Currently, these packages are affected: haskell-tng-mode[^1], psgml[3], sly[4], ess[5], el-get[6], proof-general[7], hyperbole[8] and edts[9]. At run time, we recursively[1] add[2] $pname-$version and its subdirs to load-path. Let's also do that at build time to fix this kind of errors. [1]: https://github.com/NixOS/nixpkgs/blob/9625766c32942d4fdeef6cfee0d4337f75697b5f/pkgs/applications/editors/emacs/site-start.el#L18 [2]: https://github.com/NixOS/nixpkgs/blob/9625766c32942d4fdeef6cfee0d4337f75697b5f/pkgs/applications/editors/emacs/build-support/wrapper.nix#L170-L175 [3]: https://hydra.nixos.org/build/271291118/nixlog/1 [4]: https://hydra.nixos.org/build/271372072/nixlog/1 [5]: https://hydra.nixos.org/build/271284390/nixlog/1 [6]: https://hydra.nixos.org/build/271385904/nixlog/1 [7]: https://hydra.nixos.org/build/271277707/nixlog/1 [8]: https://hydra.nixos.org/build/271345526/nixlog/1 [9]: https://hydra.nixos.org/build/271290054/nixlog/1 [^1]: Errors of this kind are shadowed by other errors. --- pkgs/applications/editors/emacs/build-support/generic.nix | 1 + 1 file changed, 1 insertion(+) diff --git a/pkgs/applications/editors/emacs/build-support/generic.nix b/pkgs/applications/editors/emacs/build-support/generic.nix index 9f1b2308cc43..595abfae7e02 100644 --- a/pkgs/applications/editors/emacs/build-support/generic.nix +++ b/pkgs/applications/editors/emacs/build-support/generic.nix @@ -91,6 +91,7 @@ libBuildHelper.extendMkDerivation' stdenv.mkDerivation (finalAttrs: "emacs \ --batch \ --eval '(setq native-comp-eln-load-path (cdr native-comp-eln-load-path))' \ + --eval '(let ((default-directory \"$out/share/emacs/site-lisp\")) (normal-top-level-add-subdirs-to-load-path))' \ --eval '(setq large-file-warning-threshold nil)' \ --eval '(setq byte-compile-error-on-warn ${if finalAttrs.turnCompilationWarningToError then "t" else "nil"})' \ -f batch-native-compile {} \