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.

219 lines
7.3 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
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. #+begin_quote
  12. *DISCLAIMER*
  13. These dotfiles are undergoing a major re-write, use at your own caution!
  14. #+end_quote
  15. Portable *GNU/Emacs*[fn:1] dotfiles. Built for Life, Liberty, and the Open Road.
  16. + 100% Reproducible
  17. + 100% Immutable
  18. + 100% Literate
  19. * Setup
  20. :PROPERTIES:
  21. :header-args: :tangle early-init.el
  22. :END:
  23. 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].
  24. #+begin_src emacs-lisp
  25. ;; This file is controlled by README.org
  26. ;; Please make any modifications there.
  27. #+end_src
  28. ** Cleanup
  29. 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]
  30. #+begin_src emacs-lisp
  31. ;; The original value of `user-emacs-directory' prior to redirection.
  32. (defconst dotfiles/home
  33. (or (getenv "DOTFILES_HOME")
  34. (expand-file-name user-emacs-directory)))
  35. ;; The redirection target of `user-emacs-directory' during initialization.
  36. (defconst dotfiles/cache
  37. (or (getenv "DOTFILES_CACHE")
  38. (expand-file-name "~/.cache/emacs")))
  39. ;; Make sure `dotfiles/cache' is a valid directory.
  40. (unless (file-exists-p dotfiles/cache)
  41. (make-directory dotfiles/cache t))
  42. ;; Redirect the value of `user-emacs-directory'.
  43. (setq user-emacs-directory 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. #+end_src
  58. 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.
  59. #+begin_src emacs-lisp
  60. ;; Bootstrap the package manager.
  61. (defvar bootstrap-version)
  62. (let ((bootstrap-file
  63. (expand-file-name "straight/repos/straight.el/bootstrap.el" user-emacs-directory))
  64. (bootstrap-version 5))
  65. (unless (file-exists-p bootstrap-file)
  66. (with-current-buffer
  67. (url-retrieve-synchronously
  68. "https://raw.githubusercontent.com/raxod502/straight.el/develop/install.el"
  69. 'silent 'inhibit-cookies)
  70. (goto-char (point-max))
  71. (eval-print-last-sexp)))
  72. (load bootstrap-file nil 'nomessage))
  73. ;; Integrate with `use-package' by installing it via `straight'.
  74. (straight-use-package 'use-package)
  75. ;; Specify core package sources.
  76. (straight-use-package 'no-littering)
  77. (straight-use-package '(org :local-repo nil)
  78. #+end_src
  79. ** Options
  80. 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.
  81. #+begin_src emacs-lisp
  82. ;; All of the modules available sorted in their default load order.
  83. (defconst dotfiles/modules-p
  84. '(org trash keys evil dired magit
  85. shell mu4e elfeed eshell vterm
  86. gpg pass x11 exwm roam agenda
  87. spelling grammar reveal hugo
  88. capture projects docker lsp dap
  89. cc go uml conf python fonts ivy
  90. themes modeline dashboard))
  91. ;; All of the enabled modules.
  92. (defvar dotfiles/modules dotfiles/modules-p)
  93. ;; The default system language.
  94. (defvar dotfiles/language (getenv "LANG"))
  95. ;; Configure a unified system font.
  96. (defvar dotfiles/font "Fira Code")
  97. ;; Default system font size.
  98. (defvar dotfiles/font-size 96)
  99. ;; Delay time before offering suggestions and completions.
  100. (defvar dotfiles/idle 0.0)
  101. ;; The all powerful leader key.
  102. (defvar dotfiles/leader-key "SPC")
  103. ;; Global prefix for the leader key under X11 windows.
  104. (defvar dotfiles/leader-key-global
  105. (concat "C-" dotfiles/leader-key))
  106. ;; The location on disk of source code projects.
  107. (defvar dotfiles/projects
  108. (or (getenv "DOTFILES_PROJECTS")
  109. (expand-file-name "~/.local/source")))
  110. ;; The location on disk of the local copy of the password store.
  111. (defvar dotfiles/passwords
  112. (or (getenv "DOTFILES_PASSWORDS")
  113. (expand-file-name "~/.password-store")))
  114. ;; The public GPG key to encrpyt files, and emails for / to / with.
  115. (defvar dotfiles/public-key "37AB1CB72B741E478CA026D43025DCBD46F81C0F"
  116. #+end_src
  117. ** Methods
  118. 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.
  119. #+begin_src emacs-lisp
  120. ;; Load a host configuration.
  121. (defun dotfiles/load-host (host-name)
  122. "Load the host configuration file for the system `host-name'."
  123. (interactive)
  124. (let ((host-file (concat dotfiles/home "/hosts/" host-name ".org")))
  125. (when (file-exists-p host-file)
  126. (org-babel-load-file host-file))))
  127. ;; Load a module definition.
  128. (defun dotfiles/load-modules (modules)
  129. "Load the `modules' in sequential order."
  130. (interactive)
  131. (dolist (m modules)
  132. (let ((mod-file (concat dotfiles/home "/modules/" (symbol-name m) ".org")))
  133. (when (file-exists-p mod-file)
  134. (org-babel-load-file mod-file)))))
  135. #+end_src
  136. * Config
  137. :PROPERTIES:
  138. :header-args: :tangle init.el
  139. :END:
  140. Once the early-init phase as completed, there are only two remaining tasks to complete before the system is fully initialized.
  141. #+begin_src emacs-lisp
  142. ;; This file is controlled by README.org
  143. ;; Please make any modifications there.
  144. #+end_src
  145. ** Hosts
  146. 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~.
  147. #+begin_src emacs-lisp
  148. ;; Load the host configuration.
  149. (dotfiles/load-host system-name)
  150. #+end_src
  151. ** Modules
  152. 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.
  153. #+begin_src emacs-lisp
  154. ;; Load the enabled modules.
  155. (dotfiles/load-modules dotfiles/modules)
  156. #+end_src
  157. * Footnotes
  158. [fn:1] https://gnu.org/software/emacs/
  159. [fn:2] https://gnu.org/distros/free-distros.html
  160. [fn:3] https://chrishayward.xyz/notes/literate-programming/
  161. [fn:4] https://chrishayward.xyz/posts/immutable-emacs/
  162. [fn:5] https://github.com/raxod502/straight.el