I showed you my source code, pls respond
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

221 lines
7.6 KiB

4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
  1. #+TITLE: Dotfiles
  2. #+AUTHOR: Christopher James Hayward
  3. #+EMAIL: chris@chrishayward.xyz
  4. #+PROPERTY: header-args :results silent :eval no-export
  5. #+OPTIONS: num:nil toc:nil todo:nil tasks:nil tags:nil
  6. #+OPTIONS: skip:nil author:nil email:nil creator:nil timestamp:nil
  7. #+ATTR_ORG: :width 420px
  8. #+ATTR_HTML: :width 420px
  9. #+ATTR_LATEX: :width 420px
  10. [[./docs/images/desktop-example.png]]
  11. Portable *GNU/Emacs*[fn:1] dotfiles. Built for Life, Liberty, and the Open Road.
  12. + 100% Reproducible
  13. + 100% Immutable
  14. + 100% Literate
  15. * Setup
  16. :PROPERTIES:
  17. :header-args: :tangle early-init.el
  18. :END:
  19. These is my personal configuration(s) for *GNU/Linux*[fn:2], and *GNU/Emacs*[fn:1] software. It enables a consistent experience and computing environment across all of my machines. The entire experience is controlled with *GNU/Emacs*[fn:1], leveraging it's capabilities for *Literate Programming*[fn:3].
  20. #+begin_src emacs-lisp
  21. ;; This file is controlled by README.org
  22. ;; Please make any modifications there.
  23. #+end_src
  24. ** Cleanup
  25. Emacs creates a lot of files relative to ~user-emacs-directory~. These files are not part of this immutable configuration and do not belong in the Emacs directory. To solve this issue, before most of the packages have loaded, I change the value, a method I detail in this post[fn:4].
  26. #+begin_src emacs-lisp
  27. ;; The original value of `user-emacs-directory' prior to redirection.
  28. (defconst dotfiles/home
  29. (or (getenv "DOTFILES_HOME")
  30. (expand-file-name user-emacs-directory)))
  31. ;; The redirection target of `user-emacs-directory' during initialization.
  32. (defconst dotfiles/cache
  33. (or (getenv "DOTFILES_CACHE")
  34. (expand-file-name "~/.cache/emacs")))
  35. ;; Make sure `dotfiles/cache' is a valid directory.
  36. (unless (file-exists-p dotfiles/cache)
  37. (make-directory dotfiles/cache t))
  38. ;; Redirect the value of `user-emacs-directory'.
  39. (setq user-emacs-directory dotfiles/cache)
  40. ;; Remove the eln-cache subdirectory.
  41. (delete (expand-file-name "eln-cache" dotfiles/home) comp-eln-load-path)
  42. ;; Add a new eln-cache folder.
  43. (add-to-list 'comp-eln-load-path (expand-file-name "eln-cache" dotfiles/cache))
  44. ;; Disable error messages for packages that don't support native-comp.
  45. (setq comp-async-report-warnings-errors nil)
  46. ;; Disable unwanted features.
  47. (setq make-backup-files nil
  48. create-lockfiles nil)
  49. #+end_src
  50. ** Packages
  51. Download and install packages using ~straight.el~[fn:5], a fully functional package manager for Emacs that integrates with ~use-package~, a popular way of installing packages for Emacs.
  52. #+begin_src emacs-lisp
  53. ;; Apply the configurations prior to bootstrapping the package manager.
  54. (setq straight-repository-branch "master"
  55. straight-use-package-by-default t
  56. package-enable-at-startup nil)
  57. ;; BUGFIX https://github.com/raxod502/straight.el/issues/757
  58. (defvar native-comp-deferred-compilation-deny-list ())
  59. #+end_src
  60. Bootstrap the package manager by loading the bootstrap-file, downloading it when it doesn't exist on a new system. This operation may take some time on a new system.
  61. #+begin_src emacs-lisp
  62. ;; Bootstrap the package manager.
  63. (defvar bootstrap-version)
  64. (let ((bootstrap-file
  65. (expand-file-name "straight/repos/straight.el/bootstrap.el" user-emacs-directory))
  66. (bootstrap-version 5))
  67. (unless (file-exists-p bootstrap-file)
  68. (with-current-buffer
  69. (url-retrieve-synchronously
  70. "https://raw.githubusercontent.com/raxod502/straight.el/develop/install.el"
  71. 'silent 'inhibit-cookies)
  72. (goto-char (point-max))
  73. (eval-print-last-sexp)))
  74. (load bootstrap-file nil 'nomessage))
  75. ;; Integrate with `use-package' by installing it via `straight'.
  76. (straight-use-package 'use-package)
  77. ;; Specify core package sources.
  78. (straight-use-package 'no-littering)
  79. (straight-use-package '(org :local-repo nil))
  80. #+end_src
  81. ** Options
  82. All of the options are defined early in the config, this is for two reasons: The first being to allow the possibility of sharing between modules, the values which are set early in the configuration. The second reason, related to the first, is to allow machine specific overrides depending on the context where Emacs is running.
  83. #+begin_src emacs-lisp
  84. ;; All of the modules available sorted in their default load order.
  85. (defconst dotfiles/modules-p
  86. '(trash keys org evil dired magit shell
  87. emms mu4e elfeed eshell vterm gpg pass
  88. x11 exwm roam agenda spelling grammar
  89. reveal hugo capture projects docker
  90. lsp dap cc go uml conf python fonts
  91. ivy themes modeline dashboard))
  92. ;; All of the enabled modules.
  93. (defvar dotfiles/modules dotfiles/modules-p)
  94. ;; The default system language.
  95. (defvar dotfiles/language (getenv "LANG"))
  96. ;; Configure a unified system font.
  97. (defvar dotfiles/font "Fira Code")
  98. ;; Default system font size.
  99. (defvar dotfiles/font-size 96)
  100. ;; Delay time before offering suggestions and completions.
  101. (defvar dotfiles/idle 0.0)
  102. ;; The all powerful leader key.
  103. (defvar dotfiles/leader-key "SPC")
  104. ;; Global prefix for the leader key under X11 windows.
  105. (defvar dotfiles/leader-key-global
  106. (concat "C-" dotfiles/leader-key))
  107. ;; The location on disk of source code projects.
  108. (defvar dotfiles/projects
  109. (or (getenv "DOTFILES_PROJECTS")
  110. (expand-file-name "~/.local/source")))
  111. ;; The location on disk of the local copy of the password store.
  112. (defvar dotfiles/passwords
  113. (or (getenv "DOTFILES_PASSWORDS")
  114. (expand-file-name "~/.password-store")))
  115. ;; The public GPG key to encrpyt files, and emails for / to / with.
  116. (defvar dotfiles/public-key "37AB1CB72B741E478CA026D43025DCBD46F81C0F")
  117. #+end_src
  118. ** Methods
  119. Define two methods that will be used in the next phase of startup: The first method will load a machine-specific (host) configuration file, and the second method will load a custom module definition.
  120. #+begin_src emacs-lisp
  121. ;; Load a host configuration.
  122. (defun dotfiles/load-host (host-name)
  123. "Load the host configuration file for the system `host-name'."
  124. (interactive)
  125. (let ((host-file (concat dotfiles/home "/hosts/" host-name ".org")))
  126. (when (file-exists-p host-file)
  127. (org-babel-load-file host-file))))
  128. ;; Load a module definition.
  129. (defun dotfiles/load-modules (modules)
  130. "Load the `modules' in sequential order."
  131. (interactive)
  132. (dolist (m modules)
  133. (let ((mod-file (concat dotfiles/home "/modules/" (symbol-name m) ".org")))
  134. (when (file-exists-p mod-file)
  135. (org-babel-load-file mod-file)))))
  136. #+end_src
  137. * Config
  138. :PROPERTIES:
  139. :header-args: :tangle init.el
  140. :END:
  141. Once the early-init phase as completed, there are only two remaining tasks to complete before the system is fully initialized.
  142. #+begin_src emacs-lisp
  143. ;; This file is controlled by README.org
  144. ;; Please make any modifications there.
  145. #+end_src
  146. ** Hosts
  147. The first task involves loading a machine-specific (host) configuration file. This gives the oppertunity for a host to intervene in the module loading process, adding or removing modules before the next stage has begun. This is accomplished by modifying the list of modules in ~dotfiles/modules~.
  148. #+begin_src emacs-lisp
  149. ;; Load the host configuration.
  150. (dotfiles/load-host system-name)
  151. #+end_src
  152. ** Modules
  153. After the host configuration file has loaded, the value of ~dotfiles/modules~ is used to load all of the enabled modules. They're loaded in sequential order, and an error in any module will end this process.
  154. #+begin_src emacs-lisp
  155. ;; Load the enabled modules.
  156. (dotfiles/load-modules dotfiles/modules)
  157. #+end_src
  158. * Footnotes
  159. [fn:1] https://gnu.org/software/emacs/
  160. [fn:2] https://gnu.org/distros/free-distros.html
  161. [fn:3] https://chrishayward.xyz/notes/literate-programming/
  162. [fn:4] https://chrishayward.xyz/posts/immutable-emacs/
  163. [fn:5] https://github.com/raxod502/straight.el