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.

212 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 shell
  81. emms mu4e elfeed eshell vterm gpg pass
  82. x11 exwm roam agenda spelling grammar
  83. reveal hugo capture projects docker
  84. lsp dap cc go uml conf python fonts
  85. ivy themes modeline dashboard))
  86. ;; All of the enabled modules.
  87. (defvar dotfiles/modules dotfiles/modules-p)
  88. ;; The default system language.
  89. (defvar dotfiles/language (getenv "LANG"))
  90. ;; Configure a unified system font.
  91. (defvar dotfiles/font "Fira Code")
  92. ;; Default system font size.
  93. (defvar dotfiles/font-size 96)
  94. ;; Delay time before offering suggestions and completions.
  95. (defvar dotfiles/idle 0.0)
  96. ;; The all powerful leader key.
  97. (defvar dotfiles/leader-key "SPC")
  98. ;; Global prefix for the leader key under X11 windows.
  99. (defvar dotfiles/leader-key-global
  100. (concat "C-" dotfiles/leader-key))
  101. ;; The location on disk of source code projects.
  102. (defvar dotfiles/projects
  103. (or (getenv "DOTFILES_PROJECTS")
  104. (expand-file-name "~/.local/source")))
  105. ;; The location on disk of the local copy of the password store.
  106. (defvar dotfiles/passwords
  107. (or (getenv "DOTFILES_PASSWORDS")
  108. (expand-file-name "~/.password-store")))
  109. ;; The public GPG key to encrpyt files, and emails for / to / with.
  110. (defvar dotfiles/public-key "37AB1CB72B741E478CA026D43025DCBD46F81C0F")
  111. #+end_src
  112. ** Methods
  113. 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.
  114. #+begin_src emacs-lisp
  115. ;; Load a host configuration.
  116. (defun dotfiles/load-host (host-name)
  117. "Load the host configuration file for the system `host-name'."
  118. (interactive)
  119. (let ((host-file (concat dotfiles/home "/hosts/" host-name ".org")))
  120. (when (file-exists-p host-file)
  121. (org-babel-load-file host-file))))
  122. ;; Load a module definition.
  123. (defun dotfiles/load-modules (modules)
  124. "Load the `modules' in sequential order."
  125. (interactive)
  126. (dolist (m modules)
  127. (let ((mod-file (concat dotfiles/home "/modules/" (symbol-name m) ".org")))
  128. (when (file-exists-p mod-file)
  129. (org-babel-load-file mod-file)))))
  130. #+end_src
  131. * Config
  132. :PROPERTIES:
  133. :header-args: :tangle init.el
  134. :END:
  135. Once the early-init phase as completed, there are only two remaining tasks to complete before the system is fully initialized.
  136. #+begin_src emacs-lisp
  137. ;; This file is controlled by README.org
  138. ;; Please make any modifications there.
  139. #+end_src
  140. ** Hosts
  141. 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~.
  142. #+begin_src emacs-lisp
  143. ;; Load the host configuration.
  144. (dotfiles/load-host system-name)
  145. #+end_src
  146. ** Modules
  147. 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.
  148. #+begin_src emacs-lisp
  149. ;; Load the enabled modules.
  150. (dotfiles/load-modules dotfiles/modules)
  151. #+end_src
  152. * Footnotes
  153. [fn:1] https://gnu.org/software/emacs/
  154. [fn:2] https://gnu.org/distros/free-distros.html
  155. [fn:3] https://chrishayward.xyz/notes/literate-programming/
  156. [fn:4] https://chrishayward.xyz/posts/immutable-emacs/
  157. [fn:5] https://github.com/raxod502/straight.el