#+TITLE: Dotfiles #+AUTHOR: Christopher James Hayward #+EMAIL: chris@chrishayward.xyz #+PROPERTY: header-args:emacs-lisp :tangle init.el :comments org #+PROPERTY: header-args :results silent :eval no-export #+OPTIONS: num:nil toc:nil todo:nil tasks:nil tags:nil #+OPTIONS: skip:nil author:nil email:nil creator:nil timestamp:nil #+ATTR_ORG: :width 420px #+ATTR_HTML: :width 420px #+ATTR_LATEX: :width 420px [[./docs/images/desktop-alt.png]] Portable *GNU Emacs*[fn:1] dotfiles. Built for Life, Liberty, and the Open Road. + 100% Literate + 100% Immutable + 100% Reproducible * What is it? From the documentation[fn:1]: #+begin_quote *An extensible, customizable, free/libre text editor -- and more* At its core is an interpreter for *Emacs Lisp*[fn:2], a dialect of the Lisp programming language with extensions to support text editing. #+end_quote To highlight some of the features available out of the box: + Content aware editing modes + Complete built-in documentation + Full unicode support for all human languages + Packaging sysystem for third party extensions + Wide range of functionality beyond text editing * How does it work? 1. *Emacs* reads the configuration at ~$HOME/.emacs.d/init.el~ at startup 2. *This file* outputs some startup code to that location 1. Defines all of the options for hosts 2. Runs some required startup code 3. Loads the host definition file at ~$HOME/.emacs.d/host/$HOSTNAME~ 4. Lodas the enabled modules in ~dotfiles/modules~ ** Options Here's a complete list of all of the options configurable for each host, and their default values. All variables prefixed with ~dotfiles/~. If you need to make configurations to another variable, consider creating a new option. #+begin_src emacs-lisp (defvar dotfiles/font "Fira Code" "Unified system font family.") (defvar dotfiles/font-size 96 "Unified system font size.") (defvar dotfiles/browser (getenv "BROWSER") "Default system web browser.") (defvar dotfiles/language (getenv "LANG") "Default system dictionary language.") (defconst dotfiles/modules-p '(core editor email encryption desktop writing website capture projects interface) "All of the available modules.") (defvar dotfiles/modules dotfiles/modules-p "All of the enabled modules.") (defvar dotfiles/home user-emacs-directory "Original value of `user-emacs-directory'.") (defvar dotfiles/cache (expand-file-name "~/.cache/emacs") "Redirection target of `user-emacs-directory'.") (defvar dotfiles/idle 0.0 "Delay time before offering suggestions and completions.") (defvar dotfiles/leader-key "SPC" "All powerful leader key.") (defvar dotfiles/leader-key-global (concat "C-" dotfiles/leader-key) "Global prefix for the leader key.") (defvar dotfiles/projects (expand-file-name "~/.local/source/") "Location of source code projects.") (defvar dotfiles/passwords (expand-file-name "~/.password-store/") "Location of local password store.") (defvar dotfiles/public-key "37AB1CB72B741E478CA026D43025DCBD46F81C0F" "GPG key to encrypt org files for.") #+end_src ** Startup This project makes heavy use of modern features and libraries. Since *Babel's* used in initialization, *Org* must load prior to importing any of custom modules. This introduces a unique *chicken before the egg* problem. My solution included some initialization code in *Emacs Lisp* called before using any *Babel* APIs. #+begin_src emacs-lisp (load-file "~/.emacs.d/bin/cleanup.el") (load-file "~/.emacs.d/bin/packages.el") #+end_src * Getting started *How to install* 1. Clone ~git clone git@github.com:chayward1/dotfiles.git ~/.emacs.d~ 2. Run ~~emacs --mm --debug-init~ ** Hosts Each host machines configuration loaded immediately after declaring the options, before applying any configuration. This allows system to system control while remaining immutable. Override any of the available options configurations in a host file. Here's some examples to get started: + [[file:hosts/localhost.org][Termux]] + [[link:hosts/gamingpc.org][GamingPC]] + [[file:hosts/raspberry.org][Raspberry]] + [[file:hosts/acernitro.org][Acernitro]] + [[file:hosts/virtualbox.org][VirtualBox]] Begin the process by loading any host specific overrides. The host configuration tangles, and loads (if it exist) using the systems name. #+begin_src emacs-lisp (let ((host-file (concat dotfiles/home "/hosts/" system-name ".org"))) (when (file-exists-p host-file) (org-babel-load-file host-file))) #+end_src ** Modules Breaking down the project into logical units or chapters to keep the code more maintainable and organized. This is also a fundamental requirement to achieve the goal of modularity. Here are all of the available modules, also listed in the variable ~dotfiles/modules-p~. + [[file:modules/core.org][Core]] + [[file:modules/editor.org][Editor]] + [[file:modules/email.org][Email]] + [[file:modules/encryption.org][Encryption]] + [[file:modules/desktop.org][Desktop]] + [[file:modules/writing.org][Writing]] + [[file:modules/website.org][Website]] + [[file:modules/capture.org][Capture]] + [[file:modules/projects.org][Projects]] + [[file:modules/interface.org][Interface]] By default all of the modules will load, override the variable ~dotfiles/modules~ in a host configuration to override this. #+begin_src emacs-lisp (dolist (m dotfiles/modules) (let ((mod-file (concat dotfiles/home "/modules/" (symbol-name m) ".org"))) (when (file-exists-p mod-file) (org-babel-load-file mod-file)))) #+end_src * Resources [fn:1] https://gnu.org/software/emacs [fn:2] https://gnu.org/software/emacs/manual/html_node/elisp/index.html