···
1
-
;;; NixOS specific load-path
3
-
(append (reverse (mapcar (lambda (x) (concat x "/share/emacs/site-lisp/"))
4
-
(split-string (or (getenv "NIX_PROFILES") ""))))
1
+
(defun nix--profile-paths ()
2
+
"Returns a list of all paths in the NIX_PROFILES environment
3
+
variable, ordered from more-specific (the user profile) to the
4
+
least specific (the system profile)"
5
+
(reverse (split-string (or (getenv "NIX_PROFILES") ""))))
7
+
;;; Extend `load-path' to search for elisp files in subdirectories of
8
+
;;; all folders in `NIX_PROFILES'. Also search for one level of
9
+
;;; subdirectories in these directories to handle multi-file libraries
12
+
(let* ((subdirectory-sites (lambda (site-lisp)
13
+
(when (file-exists-p site-lisp)
14
+
(seq-filter (lambda (f) (file-directory-p (file-truename f)))
15
+
;; Returns all files in `site-lisp', excluding `.' and `..'
16
+
(directory-files site-lisp 'full "^\\([^.]\\|\\.[^.]\\|\\.\\..\\)")))))
17
+
(paths (apply #'append
18
+
(mapcar (lambda (profile-dir)
19
+
(let ((site-lisp (concat profile-dir "/share/emacs/site-lisp/")))
20
+
(cons site-lisp (funcall subdirectory-sites site-lisp))))
21
+
(nix--profile-paths)))))
22
+
(setq load-path (append paths load-path)))
;;; Make `woman' find the man pages
10
-
(append (reverse (mapcar (lambda (x) (concat x "/share/man/"))
11
-
(split-string (or (getenv "NIX_PROFILES") ""))))
28
+
(append (mapcar (lambda (x) (concat x "/share/man/"))
29
+
(nix--profile-paths))
;;; Make tramp work for remote NixOS machines
34
+
;; TODO: We should also add the other `NIX_PROFILES' to this path.
35
+
;; However, these are user-specific, so we would need to discover
36
+
;; them dynamically after connecting via `tramp'
'(add-to-list 'tramp-remote-path "/run/current-system/sw/bin"))
···
;;; from: /nix/store/<hash>-emacs-<version>/share/emacs/site-lisp/site-start.el
;;; to: /nix/store/<hash>-emacs-<version>/share/emacs/<version>/src/
25
-
(file-name-directory ;; .../emacs/
26
-
(directory-file-name ;; .../emacs/site-lisp
27
-
(file-name-directory load-file-name)))) ;; .../emacs/site-lisp/
46
+
(file-name-directory ; .../emacs/
47
+
(directory-file-name ; .../emacs/site-lisp
48
+
(file-name-directory load-file-name)))) ; .../emacs/site-lisp/