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.

213 lines
7.2 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. ;; Disable error messages for packages that don't support native-comp.
  41. (setq comp-async-report-warnings-errors nil)
  42. ;; Disable unwanted features.
  43. (setq make-backup-files nil
  44. create-lockfiles nil)
  45. #+end_src
  46. ** Packages
  47. 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.
  48. #+begin_src emacs-lisp
  49. ;; Apply the configurations prior to bootstrapping the package manager.
  50. (setq straight-repository-branch "master"
  51. straight-use-package-by-default t
  52. package-enable-at-startup nil)
  53. #+end_src
  54. 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.
  55. #+begin_src emacs-lisp
  56. ;; Bootstrap the package manager.
  57. (defvar bootstrap-version)
  58. (let ((bootstrap-file
  59. (expand-file-name "straight/repos/straight.el/bootstrap.el" user-emacs-directory))
  60. (bootstrap-version 5))
  61. (unless (file-exists-p bootstrap-file)
  62. (with-current-buffer
  63. (url-retrieve-synchronously
  64. "https://raw.githubusercontent.com/raxod502/straight.el/develop/install.el"
  65. 'silent 'inhibit-cookies)
  66. (goto-char (point-max))
  67. (eval-print-last-sexp)))
  68. (load bootstrap-file nil 'nomessage))
  69. ;; Integrate with `use-package' by installing it via `straight'.
  70. (straight-use-package 'use-package)
  71. ;; Specify core package sources.
  72. (straight-use-package 'no-littering)
  73. (straight-use-package '(org :local-repo nil))
  74. #+end_src
  75. ** Options
  76. 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.
  77. #+begin_src emacs-lisp
  78. ;; All of the modules available sorted in their default load order.
  79. (defconst dotfiles/modules-p
  80. '(trash keys org evil dired magit
  81. shell mu4e elfeed eshell vterm
  82. gpg pass x11 exwm roam agenda
  83. spelling grammar reveal hugo
  84. capture projects docker lsp dap
  85. cc go uml conf python fonts ivy
  86. themes modeline dashboard))
  87. ;; All of the enabled modules.
  88. (defvar dotfiles/modules dotfiles/modules-p)
  89. ;; The default system language.
  90. (defvar dotfiles/language (getenv "LANG"))
  91. ;; Configure a unified system font.
  92. (defvar dotfiles/font "Fira Code")
  93. ;; Default system font size.
  94. (defvar dotfiles/font-size 96)
  95. ;; Delay time before offering suggestions and completions.
  96. (defvar dotfiles/idle 0.0)
  97. ;; The all powerful leader key.
  98. (defvar dotfiles/leader-key "SPC")
  99. ;; Global prefix for the leader key under X11 windows.
  100. (defvar dotfiles/leader-key-global
  101. (concat "C-" dotfiles/leader-key))
  102. ;; The location on disk of source code projects.
  103. (defvar dotfiles/projects
  104. (or (getenv "DOTFILES_PROJECTS")
  105. (expand-file-name "~/.local/source")))
  106. ;; The location on disk of the local copy of the password store.
  107. (defvar dotfiles/passwords
  108. (or (getenv "DOTFILES_PASSWORDS")
  109. (expand-file-name "~/.password-store")))
  110. ;; The public GPG key to encrpyt files, and emails for / to / with.
  111. (defvar dotfiles/public-key "37AB1CB72B741E478CA026D43025DCBD46F81C0F")
  112. #+end_src
  113. ** Methods
  114. 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.
  115. #+begin_src emacs-lisp
  116. ;; Load a host configuration.
  117. (defun dotfiles/load-host (host-name)
  118. "Load the host configuration file for the system `host-name'."
  119. (interactive)
  120. (let ((host-file (concat dotfiles/home "/hosts/" host-name ".org")))
  121. (when (file-exists-p host-file)
  122. (org-babel-load-file host-file))))
  123. ;; Load a module definition.
  124. (defun dotfiles/load-modules (modules)
  125. "Load the `modules' in sequential order."
  126. (interactive)
  127. (dolist (m modules)
  128. (let ((mod-file (concat dotfiles/home "/modules/" (symbol-name m) ".org")))
  129. (when (file-exists-p mod-file)
  130. (org-babel-load-file mod-file)))))
  131. #+end_src
  132. * Config
  133. :PROPERTIES:
  134. :header-args: :tangle init.el
  135. :END:
  136. Once the early-init phase as completed, there are only two remaining tasks to complete before the system is fully initialized.
  137. #+begin_src emacs-lisp
  138. ;; This file is controlled by README.org
  139. ;; Please make any modifications there.
  140. #+end_src
  141. ** Hosts
  142. 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~.
  143. #+begin_src emacs-lisp
  144. ;; Load the host configuration.
  145. (dotfiles/load-host system-name)
  146. #+end_src
  147. ** Modules
  148. 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.
  149. #+begin_src emacs-lisp
  150. ;; Load the enabled modules.
  151. (dotfiles/load-modules dotfiles/modules)
  152. #+end_src
  153. * Footnotes
  154. [fn:1] https://gnu.org/software/emacs/
  155. [fn:2] https://gnu.org/distros/free-distros.html
  156. [fn:3] https://chrishayward.xyz/notes/literate-programming/
  157. [fn:4] https://chrishayward.xyz/posts/immutable-emacs/
  158. [fn:5] https://github.com/raxod502/straight.el