···1-;;; NixOS specific load-path
2-(setq load-path
3- (append (reverse (mapcar (lambda (x) (concat x "/share/emacs/site-lisp/"))
4- (split-string (or (getenv "NIX_PROFILES") ""))))
5- load-path))
00000000000000000067;;; Make `woman' find the man pages
8(eval-after-load 'woman
9 '(setq woman-manpath
10- (append (reverse (mapcar (lambda (x) (concat x "/share/man/"))
11- (split-string (or (getenv "NIX_PROFILES") ""))))
12 woman-manpath)))
1314;;; Make tramp work for remote NixOS machines
15(eval-after-load 'tramp
00016 '(add-to-list 'tramp-remote-path "/run/current-system/sw/bin"))
1718;;; C source directory
···22;;; from: /nix/store/<hash>-emacs-<version>/share/emacs/site-lisp/site-start.el
23;;; to: /nix/store/<hash>-emacs-<version>/share/emacs/<version>/src/
24(let ((emacs
25- (file-name-directory ;; .../emacs/
26- (directory-file-name ;; .../emacs/site-lisp
27- (file-name-directory load-file-name)))) ;; .../emacs/site-lisp/
28 (version
29 (file-name-as-directory
30 (concat
···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") ""))))
6+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
10+;;; like `mu4e'.'
11+(require 'seq)
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)))
23+2425;;; Make `woman' find the man pages
26(eval-after-load 'woman
27 '(setq woman-manpath
28+ (append (mapcar (lambda (x) (concat x "/share/man/"))
29+ (nix--profile-paths))
30 woman-manpath)))
3132;;; Make tramp work for remote NixOS machines
33(eval-after-load 'tramp
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'
37 '(add-to-list 'tramp-remote-path "/run/current-system/sw/bin"))
3839;;; C source directory
···43;;; from: /nix/store/<hash>-emacs-<version>/share/emacs/site-lisp/site-start.el
44;;; to: /nix/store/<hash>-emacs-<version>/share/emacs/<version>/src/
45(let ((emacs
46+ (file-name-directory ; .../emacs/
47+ (directory-file-name ; .../emacs/site-lisp
48+ (file-name-directory load-file-name)))) ; .../emacs/site-lisp/
49 (version
50 (file-name-as-directory
51 (concat