Browse Source

Cleanup host pattern

main
parent
commit
066f3d2074
  1. 124
      README.org
  2. 21
      hosts/ubuntu.el
  3. 40
      init.el

124
README.org

@ -40,77 +40,129 @@ Assuming you have completed all of the following tasks prior to proceeding furth
Launch emacs: ~emacs -mm --debug-init~ Launch emacs: ~emacs -mm --debug-init~
#+begin_src emacs-lisp
;; Load the host configuration.
(let ((host-file (concat user-emacs-directory "/hosts/" system-name ".el")))
(when (file-exists-p host-file)
(load-file host-file)))
** Options
;; Load the enabled modules.
(dolist (m dotfiles/modules)
(let ((mod-file (concat dotfiles/home "/modules/" (symbol-name m) ".el")))
(when (file-exists-p mod-file)
(load-file mod-file))))
Here's a complete list of all of the options configurable for each host, and their default values. If a host configuration does not exist, these values will be used in place.
#+begin_src emacs-lisp
(defvar dotfiles/browser
(getenv "BROWSER")
"The default browser used by the system.")
#+end_src #+end_src
* Hosts
All of the available modules are defined in the ~dotfiles/modules-available~ constant.
Each host system that runs Emacs has a file defined in the =hosts/= sub directory, following the pattern of ~$HOSTNAME.el~. All of the configurations are defined within this file, the values of which are read from by the other modules during startup and installation. This does *not* cover hosts that are controlled via =TRAMP=, as that will be covered in another section.
#+begin_src emacs-lisp
(defconst dotfiles/modules-available
'(core desktop writing projects interface)
"All of the available modules for hosts to load.")
#+end_src
** Example (Ubuntu)
:PROPERTIES:
:header-args: :tangle ~/.local/source/dotfiles/hosts/ubuntu.el
:END:
Add the modules you want to initialize to the ~dotfiles/modules~ variable.
#+begin_src emacs-lisp
(defvar dotfiles/modules
dotfiles/modules-available
"Enabled modules, modify this in your host configuration.")
#+end_src
The first configuration, which was built using the Ubuntu 20.04 LTS server edition. I decided to incorporate =flatpaks= into this build. Setting the ~$BROWSER~ variable is required in the desktop module. Set the browser to the flatpak borwser currently installed, this could change to chromium, firefox, or any other browser by changing this environment variable.
Specify the emacs home, and the cache directory.
#+begin_src emacs-lisp #+begin_src emacs-lisp
(setenv "BROWSER" "flatpak run org.mozilla.firefox")
(defvar dotfiles/home
user-emacs-directory
"Original value of `user-emacs-directory'.")
#+end_src #+end_src
Add the modules you want to initialize to the ~dotfiles/modules~ variable.
Used to seperate the immutable configuration from the stateful package files.
#+begin_src emacs-lisp #+begin_src emacs-lisp
(defvar dotfiles/modules '(core
desktop
writing
projects
interface))
(defvar dotfiles/cache
(expand-file-name "~/.cache/emacs")
"Where `user-emacs-directory' will be redirected.")
#+end_src #+end_src
Specify the ~home~ and ~cache~ directories.
Functionality like =completion= and =hints= can be delayed to avoid popups for common manuevers.
#+begin_src emacs-lisp #+begin_src emacs-lisp
(defvar dotfiles/cache "~/.cache/emacs")
(defvar dotfiles/home user-emacs-directory)
(defvar dotfiles/idle
0.0
"Length of time to wait before offering completions.")
#+end_src #+end_src
Functionality like =completion= and =hints= can be delayed to avoid popups for common manuevers. Adjust this value to your personal taste.
Required for the all powerful leader key.
#+begin_src emacs-lisp #+begin_src emacs-lisp
(defvar dotfiles/idle 0.0)
(defvar dotfiles/leader-key
"SPC"
"Custom leader key for custom actions.")
#+end_src #+end_src
Avoid the infamous *Emacs pinky* by binding =SPC= as a leader key, utilizing the thumb instead of the weaker pinky finger. You may change this value if you want to use something else.
The desktop module requires the global leader key to be set.
#+begin_src emacs-lisp #+begin_src emacs-lisp
(defvar dotfiles/leader-key "SPC")
(defvar dotfiles/leader-key-global "C-SPC")
(defvar dotfiles/leader-key-global
(concat "C-" dotfiles/leader-key)
"Global leader key available everywhere.")
#+end_src #+end_src
Define where the source repositories are stored, for integration with the *Projects* module. Define where the source repositories are stored, for integration with the *Projects* module.
#+begin_src emacs-lisp #+begin_src emacs-lisp
(defvar dotfiles/src "~/.local/source/")
(defvar dotfiles/projects
(expand-file-name "~/.local/source/")
"Location where source code projects are stored.")
#+end_src #+end_src
Secret keys and passwords are stored in a seperate repository.
Where the password store is located.
#+begin_src emacs-lisp #+begin_src emacs-lisp
(defvar dotfiles/secrets (concat dotfiles/src "secrets/"))
(defvar dotfiles/passwords (concat dotfiles/src "passwords/"))
(defvar dotfiles/passwords
(expand-file-name "~/.password-store/")
"Directory containing the password store.")
#+end_src #+end_src
** Startup
The host configuration is loaded (if it exist) using the systems name.
#+begin_src emacs-lisp
;; Load the host configuration.
(let ((host-file (concat user-emacs-directory "/hosts/" system-name ".el")))
(when (file-exists-p host-file)
(load-file host-file)))
#+end_src
Load all of the enabled modules:
#+begin_src emacs-lisp
;; Load the enabled modules.
(dolist (m dotfiles/modules)
(let ((mod-file (concat dotfiles/home "/modules/" (symbol-name m) ".el")))
(when (file-exists-p mod-file)
(load-file mod-file))))
#+end_src
* Hosts
Each host system that runs Emacs has a file defined in the =hosts/= sub directory, following the pattern of ~$HOSTNAME.el~. All of the configurations are defined within this file, the values of which are read from by the other modules during startup and installation. This does *not* cover hosts that are controlled via =TRAMP=, as that will be covered in another section.
** Example (Ubuntu)
:PROPERTIES:
:header-args: :tangle ~/.local/source/dotfiles/hosts/ubuntu.el
:END:
The first configuration, which was built using the Ubuntu 20.04 LTS server edition. I decided to incorporate =flatpaks= into this build, which required overriding the ~$BROWSER~ environment variable.
#+begin_src emacs-lisp
(setq dotfiles/browser "flatpak run org.mozilla.firefox")
#+end_src
+ Set the browser to the flatpak browser currently installed
- firefox
- chromium
- any other browser
* Modules * Modules
Breaking down the project into logical units or chapters to keep the code more maintainable and organized. This is also a fundemental requirement to achieve the goal of modularity. Incorporating just the =core= module on a build server to build literate programming projects is just one example of what can be achieved. Breaking down the project into logical units or chapters to keep the code more maintainable and organized. This is also a fundemental requirement to achieve the goal of modularity. Incorporating just the =core= module on a build server to build literate programming projects is just one example of what can be achieved.

21
hosts/ubuntu.el

@ -1,20 +1 @@
(setenv "BROWSER" "flatpak run org.mozilla.firefox")
(defvar dotfiles/modules '(core
desktop
writing
projects
interface))
(defvar dotfiles/cache "~/.cache/emacs")
(defvar dotfiles/home user-emacs-directory)
(defvar dotfiles/idle 0.0)
(defvar dotfiles/leader-key "SPC")
(defvar dotfiles/leader-key-global "C-SPC")
(defvar dotfiles/src "~/.local/source/")
(defvar dotfiles/secrets (concat dotfiles/src "secrets/"))
(defvar dotfiles/passwords (concat dotfiles/src "passwords/"))
(setq dotfiles/browser "flatpak run org.mozilla.firefox")

40
init.el

@ -1,3 +1,43 @@
(defvar dotfiles/browser
(getenv "BROWSER")
"The default browser used by the system.")
(defconst dotfiles/modules-available
'(core desktop writing projects interface)
"All of the available modules for hosts to load.")
(defvar dotfiles/modules
dotfiles/modules-available
"Enabled modules, modify this in your host configuration.")
(defvar dotfiles/home
user-emacs-directory
"Original value of `user-emacs-directory'.")
(defvar dotfiles/cache
(expand-file-name "~/.cache/emacs")
"Where `user-emacs-directory' will be redirected.")
(defvar dotfiles/idle
0.0
"Length of time to wait before offering completions.")
(defvar dotfiles/leader-key
"SPC"
"Custom leader key for custom actions.")
(defvar dotfiles/leader-key-global
(concat "C-" dotfiles/leader-key)
"Global leader key available everywhere.")
(defvar dotfiles/projects
(expand-file-name "~/.local/source/")
"Location where source code projects are stored.")
(defvar dotfiles/passwords
(expand-file-name "~/.password-store/")
"Directory containing the password store.")
;; Load the host configuration. ;; Load the host configuration.
(let ((host-file (concat user-emacs-directory "/hosts/" system-name ".el"))) (let ((host-file (concat user-emacs-directory "/hosts/" system-name ".el")))
(when (file-exists-p host-file) (when (file-exists-p host-file)

Loading…
Cancel
Save