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.

2855 lines
92 KiB

3 years ago
4 years ago
3 years ago
3 years ago
3 years ago
4 years ago
3 years ago
4 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
4 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
  1. :PROPERTIES:
  2. :ID: e4ad3dd5-0996-45bc-92ab-6bdbf16e4310
  3. :ROAM_REFS: https://chrishayward.xyz/dotfiles/
  4. :END:
  5. #+TITLE: Dotfiles
  6. #+AUTHOR: Christopher James Hayward
  7. #+EMAIL: chris@chrishayward.xyz
  8. #+STARTUP: overview
  9. #+STARTUP: hideblocks
  10. #+EXPORT_FILE_NAME: dotfiles
  11. #+HUGO_BASE_DIR: docs
  12. #+HUGO_AUTO_SET_LASTMOD: t
  13. #+HUGO_SECTION:
  14. #+HUGO_DRAFT: false
  15. #+HTML: <a href="https://nixos.org"><img src="https://img.shields.io/badge/NixOS-unstable-blue.svg?style=flat-square&logo=NixOS&logoColor=white"></a>
  16. #+HTML: <a href="https://www.gnu.org/software/emacs/"><img src="https://img.shields.io/badge/Emacs-28.1-blueviolet.svg?style=flat-square&logo=GNU%20Emacs&logoColor=white"></a>
  17. #+HTML: <a href="https://orgmode.org"><img src="https://img.shields.io/badge/Org-9.5.2-%2377aa99?style=flat-square&logo=org&logoColor=white"></a>
  18. #+NAME: description
  19. #+BEGIN_SRC text
  20. Immutable NixOS dotfiles.
  21. #+END_SRC
  22. #+ATTR_ORG: :width 800px
  23. #+ATTR_HTML: :width 800px
  24. #+ATTR_LATEX: :width 800px
  25. [[./docs/images/desktop.png]]
  26. Built for Life, Liberty, and the Open Road.
  27. + 100% Immutable
  28. + 100% Declarative
  29. + 100% Reproducible
  30. * Introduction
  31. This is my personal configuration for [[https://linux.org][GNU/Linux]] systems. It enables a consistent experience and computing environment across all of my machines. This project is written with [[https://gnu.org/software/emacs/][GNU/Emacs]], leveraging its capabilities for [[https://doi.org/10.1093/comjnl/27.2.97][Literate Programming]], a technique where programs are written in a natural language, such as English, interspersed with snippets of code to describe a software project.
  32. #+NAME: file-warning
  33. #+BEGIN_SRC text
  34. This file is controlled by /etc/dotfiles/README.org
  35. #+END_SRC
  36. ** Getting Started
  37. 1) [[https://nixos.org/download.html][Download the latest version of NixOS]]
  38. 2) [[https://nixos.org/manual/nixos/stable/#sec-installation-partitioning][Partition your drives and mount the file system]]
  39. 3) Clone the project ~git clone git@git.chrishayward.xyz:chris/dotfiles /mnt/etc/dotfiles~
  40. 4) Load the default shell ~nix-shell /mnt/etc/dotfiles~
  41. 5) Install the system ~sudo nixos-install --impure --flake /mnt/etc/dotfiles#nixos~
  42. 6) Reboot, login and start a graphical system ~startx~
  43. ** Making Changes
  44. The ~nixos-rebuild~ command updates the system so that it corresponds to the configuration specified in the module. It builds the new system in =/nix/store/=, runs the activation scripts, and restarts and system services (if needed). The command has one required argument, which specifies the desired operation:
  45. #+NAME: rebuild-command-table
  46. | Command | Description |
  47. |----------+---------------------------------------------------------------------------------|
  48. | boot | Build the new configuration and make it the boot default, without activation |
  49. | test | Build and activate the new configuration, without adding it to the boot menu |
  50. | switch | Build and activate the new configuration, making it the new boot default |
  51. | build | Build the new configuration, without activation, nor adding it to the boot menu |
  52. | build-vm | Build a script that starts a virtual machine with the desired configuration |
  53. After making changes to the configuration the ~switch~ command will build and activate a new configuration.
  54. #+BEGIN_SRC shell
  55. # Build and activate a new configuration.
  56. sudo nixos-rebuild switch --flake $FLAKE#$HOSTNAME
  57. #+END_SRC
  58. Instead of building a new configuration, it's possible to rollback to a previous generation using the ~nixos-rebuild~ command, by supplying the ~--rollback~ argument.
  59. #+BEGIN_SRC shell
  60. # Rollback to the previous generation.
  61. sudo nixos-rebuild switch --rollback
  62. #+END_SRC
  63. ** Docker Container
  64. It's possible to use parts of this configuration using a [[https://docker.org][Docker]] container. By default, sandboxing is turned /off/ inside of the container, even though it's enabled in new installations. This can lead to differences between derivations built inside containers, versus those built without any containerization. This is especially true if a derivation relies on sandboxing to block sideloading of dependencies.
  65. Install from the command line: ~docker pull ghcr.io/chayward1/dotfiles:main~
  66. #+BEGIN_SRC dockerfile :tangle Dockerfile :noweb yes
  67. # <<file-warning>>
  68. # Derive from the official image.
  69. FROM nixos/nix
  70. # Setup the default environment.
  71. WORKDIR /etc/dotfiles
  72. COPY . .
  73. # Load the default system shell.
  74. RUN nix-shell /etc/dotfiles/shell.nix
  75. #+END_SRC
  76. * Operating System
  77. #+ATTR_ORG: :width 200px
  78. #+ATTR_HTML: :width 200px
  79. #+ATTR_LATEX: :width 200px
  80. [[./docs/images/nixos.png]]
  81. [[https://nixos.org][NixOS]] is a purely functional Linux distribution built on top of the [[https://nixos.org/manual/nix/stable/Nix][Nix Package Manager]]. It uses a declarative configuration language to define entire computer systems, and allows reliable system upgrades and rollbacks. [[https://nixos.org][NixOS]] also has tool dedicated to DevOps and deployment tasks, and makes it trivial to share development environments.
  82. #+BEGIN_SRC nix :noweb yes :tangle flake.nix
  83. # <<file-warning>>
  84. {
  85. description = "<<description>>";
  86. inputs = {
  87. <<os-nixpkgs>>
  88. <<os-home-manager>>
  89. <<os-emacs-overlay>>
  90. <<os-nixos-hardware>>
  91. };
  92. outputs = inputs @ { self, nixpkgs, nixpkgs-unstable, ... }: {
  93. nixosConfigurations = {
  94. <<host-default>>
  95. };
  96. };
  97. }
  98. #+END_SRC
  99. ** Nixpkgs
  100. [[https://nixos.org/manual/nixpkgs/stable][Nixpkgs]] is a collection of over 60,000 software packages that can be installed with the [[https://nixos.org/manual/nix/stable/Nix][Nix Package Manager]]. Two main branches are offered:
  101. 1) The current stable release
  102. 2) The Unstable branch following the latest development
  103. #+NAME: os-nixpkgs
  104. #+BEGIN_SRC nix
  105. nixpkgs.url = "nixpkgs/nixos-unstable";
  106. nixpkgs-unstable.url = "nixpkgs/master";
  107. #+END_SRC
  108. ** Home Manager
  109. [[https://nixos.wiki/wiki/Home_Manager][Home Manager]] provides a basic system for managing user environments using the [[https://nixos.org/manual/nix/stable/Nix][Nix Package Manager]] together with the Nix libraries found in [[https://nixos.org/manual/nixpkgs/stable][Nixpkgs]]. It allows declarative configuration of user specific (non-global) packages and files.
  110. #+NAME: os-home-manager
  111. #+BEGIN_SRC nix
  112. home-manager.url = "github:nix-community/home-manager";
  113. home-manager.inputs.nixpkgs.follows = "nixpkgs";
  114. #+END_SRC
  115. ** Emacs Overlay
  116. Adding the [[https://github.com/nix-community/emacs-overlay][Emacs Overlay]] extends the [[https://gnu.org/software/emacs/][GNU/Emacs]] package set to contain the latest versions, and daily generations from popular package sources, including the needed dependencies to run Emacs as a Window Manager.
  117. #+NAME: os-emacs-overlay
  118. #+BEGIN_SRC nix
  119. emacs-overlay.url = "github:nix-community/emacs-overlay";
  120. #+END_SRC
  121. ** NixOS Hardware
  122. [[https://github.com/nixos/nixos-hardware][NixOS Hardware]] is a collection of [[https://nixos.org][NixOS]] modules covering specific hardware quirks. Unlike the channel, this will update the git repository on a rebuild. However, it's easy to pin particular revisions for more stability.
  123. #+NAME: os-nixos-hardware
  124. #+BEGIN_SRC nix
  125. nixos-hardware.url = "github:nixos/nixos-hardware";
  126. #+END_SRC
  127. * Development Shells
  128. The command ~nix-shell~ will build the dependencies of the specified derivation, but not the derivation itself. It will then start an interactive shell in which all environment variables defined by the derivation /path/ have been set to their corresponding values.
  129. Import this shell with ~nix-shell /etc/dotfiles/shell.nix~.
  130. #+BEGIN_SRC nix :noweb yes :tangle shell.nix
  131. # <<file-warning>>
  132. { pkgs ? import <nixpkgs> { } }:
  133. with pkgs;
  134. let
  135. myNix = writeShellScriptBin "nix" ''
  136. exec ${nixFlakes}/bin/nix --option experimental-features "nix-command flakes" "$@"
  137. '';
  138. in mkShell {
  139. buildInputs = [
  140. git
  141. myNix
  142. ];
  143. shellHook = ''
  144. export DOTFILES="$(pwd)"
  145. '';
  146. }
  147. #+END_SRC
  148. ** Go
  149. #+ATTR_ORG: :width 400px
  150. #+ATTR_HTML: :width 400px
  151. #+ATTR_LATEX: :width 400px
  152. [[./docs/images/golang.png]]
  153. [[https://golang.org][Go]] is an open-source programming language that makes it easy to build simple, reliable, and efficient software. It's statically typed and compiled programming language. It's syntactically similar to C, but with memory safety, garbage collection, structural typing, and CSP-style concurrency.
  154. Import this shell with ~nix-shell /etc/dotfiles/shells/go.nix~
  155. #+BEGIN_SRC nix :noweb yes :tangle shells/go.nix
  156. # <<file-warning>>
  157. { pkgs ? import <nixpkgs> { } }:
  158. with pkgs;
  159. mkShell {
  160. buildInputs = [
  161. go
  162. gopls
  163. protoc-gen-go
  164. protoc-gen-go-grpc
  165. ];
  166. shellHook = ''
  167. export GO111MODULE=on
  168. export GOPATH=$XDG_DATA_HOME/go
  169. export PATH=$GOPATH/bin:$PATH
  170. '';
  171. }
  172. #+END_SRC
  173. ** Rust
  174. #+ATTR_ORG: :width 400px
  175. #+ATTR_HTML: :width 400px
  176. #+ATTR_LATEX: :width 400px
  177. [[./docs/images/rust.png]]
  178. [[https://rust-lang.org/][Rust]] is a multi-paradigm programming language designed for performance and safety, especially safe concurrency. It is syntactically similar to C++, but can garantee memory safety by using a borrow checker to validate references. Rust achieves memory safety /without/ garbage collection, and reference counting is optional.
  179. Import this shell with ~nix-shell /etc/dotfiles/shells/rust.nix~.
  180. #+BEGIN_SRC nix :noweb yes :tangle shells/rust.nix
  181. # <<file-warning>>
  182. { pkgs ? import <nixpkgs> { } }:
  183. with pkgs;
  184. mkShell {
  185. buildInputs = [
  186. rustup
  187. ];
  188. shellHook = ''
  189. export RUSTUP_HOME="$XDG_DATA_HOME/rustup"
  190. export CARGO_HOME="$XDG_DATA_HOME/cargo"
  191. export PATH="$CARGO_HOME/bin:$PATH"
  192. '';
  193. }
  194. #+END_SRC
  195. ** Node
  196. #+ATTR_ORG: :width 400px
  197. #+ATTR_HTML: :width 400px
  198. #+ATTR_LATEX: :width 400px
  199. [[./docs/images/node.png]]
  200. [[https://nodejs.org][NodeJS]] is an open-source, cross-platform, back-end JavaScript runtime environment that runs on the V8 engine, and executes JavaScript code outside of a web browser. NodeJS lets developers user JavaScript to write command line tools, and for server-side scripting to produce dynamic web page content.
  201. Import this shell with ~nix-shell /etc/dotfiles/shells/node.nix~.
  202. #+BEGIN_SRC nix :noweb yes :tangle shells/node.nix
  203. # <<file-warning>>
  204. { pkgs ? import <nixpkgs> { } }:
  205. with pkgs;
  206. mkShell {
  207. buildInputs = [
  208. nodejs
  209. yarn
  210. ];
  211. shellHook = ''
  212. export NPM_CONFIG_TMP="$XDG_RUNTIME_DIR/npm"
  213. export NPM_CONFIG_CACHE="$XDG_CACHE_HOME/npm"
  214. export NPM_CACHE_PREFIX="$XDG_CACHE_HOME/npm"
  215. export PATH="$(yarn global bin):$PATH"
  216. '';
  217. }
  218. #+END_SRC
  219. ** Java
  220. #+ATTR_ORG: :width 400px
  221. #+ATTR_HTML: :width 400px
  222. #+ATTR_LATEX: :width 400px
  223. [[./docs/images/java.png]]
  224. [[https://openjdk.java.net][OpenJDK]] is a free and open-source implementation of the [[https://en.wikipedia.org/wiki/Java_(software_platform)][Java]] Platform, Standard Edition. It is the result of an effort Sun Microsystems began in 2006. The implementation is licensed under the GNU General Public License Version 2 with a linking exception.
  225. Import this shell with ~nix-shell /etc/dotfiles/shells/java.nix~.
  226. #+BEGIN_SRC nix :noweb yes :tangle shells/java.nix
  227. # <<file-warning>>
  228. { pkgs ? import <nixpkgs> { } }:
  229. with pkgs;
  230. mkShell {
  231. buildInputs = [
  232. # openjdk8 # Legacy Java 8 VM.
  233. # openjdk11 # Current LTS version of OpenJDK.
  234. openjdk14 # Current version of OpenJDK.
  235. ];
  236. shellHook = ''
  237. '';
  238. }
  239. #+END_SRC
  240. ** gRPC
  241. #+ATTR_ORG: :width 400px
  242. #+ATTR_HTML: :width 400px
  243. #+ATTR_LATEX: :width 400px
  244. [[./docs/images/grpc.png]]
  245. [[https://grpc.io][gRPC]] is a modern open-source, high-performance Remote Procedure Call (RPC) framework that can run in any environment. It can efficiently connect services in and across data centres with pluggable support for load balancing, tracing, health checking, and authentication.
  246. Import this shell with ~nix-shell /etc/dotfiles/shells/grpc.nix~.
  247. #+BEGIN_SRC nix :noweb yes :tangle shells/grpc.nix
  248. # <<file-warning>>
  249. { pkgs ? import <nixpkgs> { } }:
  250. with pkgs;
  251. mkShell {
  252. buildInputs = [
  253. grpc
  254. grpcui
  255. grpcurl
  256. grpc-tools
  257. ];
  258. shellHook = ''
  259. '';
  260. }
  261. #+END_SRC
  262. ** C/C++
  263. #+ATTR_ORG: :width 400px
  264. #+ATTR_HTML: :width 400px
  265. #+ATTR_LATEX: :width 400px
  266. [[./docs/images/cc.png]]
  267. [[https://iso.org/standard/74528.html][C]] is a general-purpose, procedural computer programming language support structured programming, lexical variable scope, and recursion. It has a static type system, and by design provides constructs that map efficiently to typical machine instructions. [[https://en.wikipedia.org/wiki/C++/][C++]] is a general-purpose programming language created as an extension of the C programming language.
  268. Import this shell with ~nix-shell /etc/dotfiles/shells/cc.nix~.
  269. #+BEGIN_SRC nix :noweb yes :tangle shells/cc.nix
  270. # <<file-warning>>
  271. { pkgs ? import <nixpkgs> { } }:
  272. with pkgs;
  273. mkShell {
  274. buildInputs = [
  275. gdb
  276. ccls
  277. cmake
  278. boost
  279. gnumake
  280. gcc-unwrapped
  281. ];
  282. shellHook = ''
  283. '';
  284. }
  285. #+END_SRC
  286. ** Python
  287. #+ATTR_ORG: :width 400px
  288. #+ATTR_HTML: :width 400px
  289. #+ATTR_LATEX: :width 400px
  290. [[./docs/images/python.png]]
  291. [[https://python.org][Python]] is an interpreted high-level, general-purpose programming language. Its design philosophy emphasizes code readability, with its notable use of significant indentation. Its language constructs, as well as its object-oriented approach aim to help programmers write clear, logical, code for small and large projects.
  292. Import this shell with ~nix-shell /etc/dotfiles/shells/python.nix~
  293. #+BEGIN_SRC nix :noweb yes :tangle shells/python.nix
  294. # <<file-warning>>
  295. { pkgs ? import <nixpkgs> { } }:
  296. with pkgs;
  297. mkShell {
  298. buildInputs = [
  299. python310Packages.pip
  300. python310Packages.pip-tools
  301. python310Packages.python-lsp-black
  302. python310Packages.python-lsp-server
  303. python310Packages.python-lsp-jsonrpc
  304. ];
  305. shellHook = ''
  306. '';
  307. }
  308. #+END_SRC
  309. ** Docker
  310. #+ATTR_ORG: :width 400px
  311. #+ATTR_HTML: :width 400px
  312. #+ATTR_LATEX: :width 400px
  313. [[./docs/images/docker.png]]
  314. [[https://docker.org][Docker]] is a set of platform as a service tools that use OS level virtualization to deliver software in packages called containers. Containers are isolated from one another and bundle their own software, libraries, and configuratuion files.
  315. [[https://docs.docker.com/compose/][Compose]] is a tool for defining and running multi-container Docker applications. With Compose, you use a YAML file to configure your application services. Then, with a single command, you create and start all of the services from your configuration.
  316. [[https://docs.docker.com/machine/][Machine]] is a tool that lets you install Docker Engine on virtual hosts, and manage the hosts with ~docker-machine~ commands. You can use Machine to create hosts on your local box, company network, data center, or on any cloud provider.
  317. Import this shell with ~nix-shell /etc/dotfiles/shells/docker.nix~
  318. #+BEGIN_SRC nix :noweb yes :tangle shells/docker.nix
  319. # <<file-warning>>
  320. { pkgs ? import <nixpkgs> { } }:
  321. with pkgs;
  322. mkShell {
  323. buildInputs = [
  324. docker-compose
  325. docker-machine
  326. ];
  327. shellHook = ''
  328. '';
  329. }
  330. #+END_SRC
  331. ** Heroku
  332. #+ATTR_ORG: :width 400px
  333. #+ATTR_HTML: :width 400px
  334. #+ATTR_LATEX: :width 400px
  335. [[./docs/images/heroku.png]]
  336. [[https://heroku.com][Heroku]] is a cloud platform as a service supporting several programming languages. One of the first cloud platforms, Heroku has been in development since June 2007, when it supported only the Ruby programming language. It now supports Java, Node.js, Scala, Clojure, Python, PHP, and Go.
  337. Import this shell with ~nix-shell /etc/dotfiles/shells/heroku.nix~
  338. #+BEGIN_SRC nix :noweb yes :tangle shells/heroku.nix
  339. # <<file-warning>>
  340. { pkgs ? import <nixpkgs> { } }:
  341. with pkgs;
  342. mkShell {
  343. buildInputs = [
  344. heroku
  345. ];
  346. shellHook = ''
  347. '';
  348. }
  349. #+END_SRC
  350. * Host Configurations
  351. [[https://nixos.org/][NixOS]] typically stores the current machine configuration in =/etc/nixos/configuration.nix=. In this project, this file is stored in =/etc/dotfiles/hosts/$HOSTNAME/...=, and imported, along with the generated hardware configurations. This ensures that multiple host machines can share the same modules, and generating new host definitions is trivial. It also makes it easier to share common configurations amongst all of the hosts, such as with pre-configured wireless networking:
  352. #+NAME: host-config-wifi
  353. #+BEGIN_SRC nix
  354. networking.wireless.networks = {
  355. MyWiFi_5C1870 = {
  356. priority = 2;
  357. pskRaw = "409b3c85fef1c5737f284d2f82f20dc6023e41804e862d4fa26265ef8193b326";
  358. };
  359. SM-G975W3034 = {
  360. priority = 1;
  361. pskRaw = "74835d96a98ca2c56ffe4eaf92223f8a555168b59ec2bb22b1e46b2a333adc80";
  362. };
  363. };
  364. #+END_SRC
  365. It's helpful to add the machine hostnames to the networking configuration, so I can refer to another host across the network by name. Some devices that can have more than one IP (WIFI / Ethernet) will have the wireless hostname suffixed:
  366. #+NAME: host-config-home
  367. #+BEGIN_SRC nix
  368. networking.hosts = {
  369. # "192.168.3.105" = [ "gamingpc" ];
  370. # "192.168.3.163" = [ "acernitro" ];
  371. # "192.168.3.182" = [ "raspberry" ];
  372. # "192.168.3.183" = [ "homecloud" ];
  373. };
  374. #+END_SRC
  375. Setting up new machines, especially headless ones like the Raspberry Pi Zero, can be difficult with NixOS. I find it easier to setup automatic network configuration, and wait for the machine to appear on the network. This is complimented with a pre-authorized SSH key, making it simple to connect and complete the installation headlessly.
  376. #+NAME: host-config-ssh
  377. #+BEGIN_SRC nix
  378. users.users.chris.openssh.authorizedKeys.keys = [
  379. "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIO4wka/LfG3pto15DIm9LIRbb6rWr7/ipCRiCdAKSlY4 chris@chrishayward.xyz"
  380. ];
  381. #+END_SRC
  382. ** Default
  383. The default host, built using [[https://qemu.org][QEMU]], a free and open-source emulator that can perform hardware virtualization. It features a lightweight system optimized for development, running [[https://gnu.org/software/emacs/][GNU/Emacs]] + [[https://github.com/ch11ng/exwm][EXWM]] as the graphical environment.
  384. #+NAME: host-default
  385. #+BEGIN_SRC nix :noweb yes
  386. nixos = nixpkgs.lib.nixosSystem {
  387. system = "x86_64-linux";
  388. specialArgs = { inherit inputs; };
  389. modules = [
  390. ./hosts/nixos
  391. <<module-x11>>
  392. <<module-ssh>>
  393. <<module-hugo>>
  394. <<module-godot>>
  395. <<module-flakes>>
  396. <<module-cachix>>
  397. <<module-firefox>>
  398. <<module-home-manager>>
  399. ];
  400. };
  401. #+END_SRC
  402. Deploy this configuration with ~nixos-rebuild switch --flake /etc/dotfiles/#nixos~.
  403. #+BEGIN_SRC nix :noweb yes :tangle hosts/nixos/default.nix
  404. # <<file-warning>>
  405. { ... }:
  406. {
  407. imports = [
  408. ./configuration.nix
  409. ./hardware.nix
  410. ];
  411. }
  412. #+END_SRC
  413. *** Configuration
  414. This is a basic default configuration that specified the indended default configuration of the system. Because [[https://nixos.org/][NixOS]] has a declarative configuration model, you can create or edit a description of the desired configuration, and update it from one file.
  415. #+BEGIN_SRC nix :noweb yes :tangle hosts/nixos/configuration.nix
  416. # <<file-warning>>
  417. { config, pkgs, inputs, ... }:
  418. {
  419. time.timeZone = "America/Toronto";
  420. networking.hostName = "nixos";
  421. networking.useDHCP = false;
  422. networking.firewall.enable = false;
  423. networking.interfaces.ens3.useDHCP = true;
  424. <<host-config-home>>
  425. <<host-config-ssh>>
  426. programs.mtr.enable = true;
  427. programs.fish.enable = true;
  428. programs.gnupg.agent.enable = true;
  429. users.users.chris = {
  430. shell = pkgs.fish;
  431. isNormalUser = true;
  432. extraGroups = [ "wheel" ];
  433. };
  434. }
  435. #+END_SRC
  436. *** Hardware
  437. The file system for this host is a single 24GB =QCOW= file, a format for disk images used by [[https://qemu.org][QEMU]]. The file can be recreated easily by following the steps listed in the [[https://nixos.org/][NixOS]] installation manual, specifically the section on disk formatting.
  438. #+BEGIN_SRC nix :noweb yes :tangle hosts/nixos/hardware.nix
  439. # <<file-warning>>
  440. { config, lib, pkgs, modulesPath, ... }:
  441. {
  442. imports =
  443. [ (modulesPath + "/profiles/qemu-guest.nix")
  444. ];
  445. boot.initrd.availableKernelModules = [ "ata_piix" "floppy" "sd_mod" "sr_mod" ];
  446. boot.initrd.kernelModules = [ ];
  447. boot.kernelModules = [ ];
  448. boot.extraModulePackages = [ ];
  449. boot.loader.grub.enable = true;
  450. boot.loader.grub.version = 2;
  451. boot.loader.grub.device = "/dev/sda";
  452. fileSystems."/" =
  453. { device = "/dev/disk/by-label/nixos";
  454. fsType = "ext4";
  455. };
  456. swapDevices =
  457. [ { device = "/dev/disk/by-label/swap"; }
  458. ];
  459. }
  460. #+END_SRC
  461. * Module Definitions
  462. Modules are files combined by [[https://nixos.org/][NixOS]] to produce the full system configuration. Modules wre introduced to allow extending NixOS without modifying its source code. They also allow splitting up =configuration.nix=, making the system configuration easier to maintain and use.
  463. ** X11
  464. #+NAME: module-x11
  465. #+BEGIN_SRC nix
  466. ./modules/x11.nix
  467. #+END_SRC
  468. [[https://x.org/wiki/][X11]], or X is the generic name for the X Window System Display Server. All graphical [[https://linux.org][GNU/Linux]] applications connect to an X-Window (or Wayland) to display graphical data on the monitor of a computer. Its a program that acts as the interface between graphical applications and the graphics subsystem of the computer.
  469. #+BEGIN_SRC nix :noweb yes :tangle modules/x11.nix
  470. # <<file-warning>>
  471. { config, pkgs, ... }:
  472. {
  473. services.xserver.enable = true;
  474. services.xserver.layout = "us";
  475. services.xserver.libinput.enable = true;
  476. services.xserver.displayManager.startx.enable = true;
  477. environment = {
  478. variables = {
  479. XDG_DESKTOP_DIR = "$HOME/";
  480. XDG_CACHE_HOME = "$HOME/.cache";
  481. XDG_CONFIG_HOME = "$HOME/.config";
  482. XDG_DATA_HOME = "$HOME/.local/share";
  483. XDG_BIN_HOME = "$HOME/.local/bin";
  484. };
  485. systemPackages = with pkgs; [
  486. pkgs.sqlite
  487. pkgs.pfetch
  488. pkgs.cmatrix
  489. pkgs.asciiquarium
  490. ];
  491. extraInit = ''
  492. export XAUTHORITY=/tmp/Xauthority
  493. export xserverauthfile=/tmp/xserverauth
  494. [ -e ~/.Xauthority ] && mv -f ~/.Xauthority "$XAUTHORITY"
  495. [ -e ~/.serverauth.* ] && mv -f ~/.serverauth.* "$xserverauthfile"
  496. '';
  497. };
  498. services.picom.enable = true;
  499. services.printing.enable = true;
  500. fonts.fonts = with pkgs; [
  501. iosevka-bin
  502. emacs-all-the-icons-fonts
  503. ];
  504. }
  505. #+END_SRC
  506. ** SSH
  507. #+NAME: module-ssh
  508. #+BEGIN_SRC nix
  509. ./modules/ssh.nix
  510. #+END_SRC
  511. [[https://openssh.com][OpenSSH]] is a suite of secure networking utilities based on the [[https://en.wikipedia.org/wiki/Secure_Shell][Secure Shell Protocol]], which provides a secure channel over an unsecured network in a client-server architecture. OpenSSH started as a fork of the free SSH program; later versions were proprietary software.
  512. Apply some configuration to the default settings:
  513. + Disable logging in as =root=
  514. + Disable password authentication
  515. #+BEGIN_SRC nix :noweb yes :tangle modules/ssh.nix
  516. # <<file-warning>>
  517. { config, pkgs, ... }:
  518. {
  519. services.openssh = {
  520. enable = true;
  521. permitRootLogin = "no";
  522. passwordAuthentication = false;
  523. };
  524. }
  525. #+END_SRC
  526. ** Hugo
  527. #+NAME: module-hugo
  528. #+BEGIN_SRC nix
  529. ./modules/hugo.nix
  530. #+END_SRC
  531. [[https://gohugo.io][Hugo]] is one of the most popular open-source static site generators. I use it to build https://chrishayward.xyz which is included in a later section of this configuration. This module adds a custom package to push the site to the server.
  532. #+BEGIN_SRC nix :noweb yes :tangle modules/hugo.nix
  533. # <<file-warning>>
  534. { config, pkgs, ... }:
  535. let
  536. mySiteDir = "/etc/dotfiles/docs/public/";
  537. mySiteTgt = "ubuntu@chrishayward.xyz:/var/www/chrishayward";
  538. mySiteBuild = pkgs.writeShellScriptBin "my-site-build" ''
  539. pushd ${mySiteDir}../ > /dev/null &&
  540. ${pkgs.hugo}/bin/hugo -v ;
  541. popd > /dev/null
  542. '';
  543. mySiteUpdate = pkgs.writeShellScriptBin "my-site-update" ''
  544. ${pkgs.rsync}/bin/rsync -aP ${mySiteDir} ${mySiteTgt}
  545. '';
  546. in {
  547. environment.systemPackages = [
  548. mySiteBuild
  549. mySiteUpdate
  550. ];
  551. }
  552. #+END_SRC
  553. ** Godot
  554. #+NAME: module-godot
  555. #+BEGIN_SRC nix
  556. ./modules/godot.nix
  557. #+END_SRC
  558. [[https://godotengine.org][Godot]] is a cross-platform, free and open-source game engine released under the MIT license. It provides a huge set of common tools, so you can focus on making your game without reinventing the wheel. It's completely free and open-source, no strings attached, no royalties. The game belongs to the creator down to each line of the engine code.
  559. #+BEGIN_SRC nix :noweb yes :tangle modules/godot.nix
  560. # <<file-warning>>
  561. { config, pkgs, ... }:
  562. {
  563. environment.systemPackages = [
  564. pkgs.tiled
  565. pkgs.godot
  566. pkgs.godot-server
  567. pkgs.godot-headless
  568. pkgs.python310Packages.gdtoolkit
  569. ];
  570. }
  571. #+END_SRC
  572. ** Flakes
  573. #+NAME: module-flakes
  574. #+BEGIN_SRC nix
  575. ./modules/flakes.nix
  576. #+END_SRC
  577. [[https://nixos.wiki/wiki/Flakes][Nix Flakes]] are an upcoming feature of the [[https://nixos.org/manual/nix/stable/][Nix Package Manager]]. They allow you to specify your codes dependencies in a declarative way, simply by listing them inside of a ~flake.nix~ file. Each dependency is then pinned to a specific git-hash. Flakes replace the =nix-channels= command and things like ~builtins.fetchGit~, keeping dependencies at the top of the tree, and channels always in sync. Currently, Flakes are not available unless explicitly enabled.
  578. #+BEGIN_SRC nix :noweb yes :tangle modules/flakes.nix
  579. # <<file-warning>>
  580. { config, pkgs, inputs, ... }:
  581. {
  582. nix = {
  583. package = pkgs.nixUnstable;
  584. extraOptions = ''
  585. experimental-features = nix-command flakes
  586. '';
  587. };
  588. nixpkgs = {
  589. config = { allowUnfree = true; };
  590. overlays = [ inputs.emacs-overlay.overlay ];
  591. };
  592. }
  593. #+END_SRC
  594. ** Cachix
  595. #+NAME: module-cachix
  596. #+BEGIN_SRC nix
  597. ./modules/cachix.nix
  598. #+END_SRC
  599. [[https://nix-community.cachix.org][Cachix]] is a Command line client for [[https://nixos.org/manual/nix/stable/][Nix]] binary cache hosting. This allows downloading and usage of pre-compiled binaries for applications on /nearly/ every available system architecture. This speeds up the time it takes to rebuild configurations.
  600. #+BEGIN_SRC nix :noweb yes :tangle modules/cachix.nix
  601. # <<file-warning>>
  602. { config, ... }:
  603. {
  604. nix = {
  605. settings = {
  606. substituters = [
  607. "https://nix-community.cachix.org"
  608. ];
  609. trusted-public-keys = [
  610. "nix-community.cachix.org-1:mB9FSh9qf2dCimDSUo8Zy7bkq5CX+/rkCWyvRCYg3Fs="
  611. ];
  612. };
  613. };
  614. }
  615. #+END_SRC
  616. ** Docker
  617. #+NAME: module-docker
  618. #+BEGIN_SRC nix
  619. ./modules/docker.nix
  620. #+END_SRC
  621. [[https://docker.org][Docker]] is a set of platform as a service tools that use OS level virtualization to deliver software in packages called containers. Containers are isolated from one another and bundle their own software, libraries, and configuration files; they can communicate with each other through well-defined channels.
  622. #+BEGIN_SRC nix :noweb yes :tangle modules/docker.nix
  623. { config, pkgs, ... }:
  624. {
  625. # Enable the docker virutalization platform.
  626. virtualisation.docker = {
  627. enable = true;
  628. enableOnBoot = true;
  629. autoPrune.enable = true;
  630. };
  631. # Required for the `docker' command.
  632. users.users.chris.extraGroups = [ "docker" ];
  633. }
  634. #+END_SRC
  635. ** Firefox
  636. #+NAME: module-firefox
  637. #+BEGIN_SRC nix
  638. ./modules/firefox.nix
  639. #+END_SRC
  640. [[https://firefox.com][Firefox Browser]], also known as Mozilla Firefox or simply Firefox, is a free and open-source web browser developed by the Mozilla Foundation and its subsidiary, the Mozilla Corporation. Firefox uses the Gecko layout engine to render web pages, which implements current and anticipated web standards. In 2017, Firefox began incorporating new technology under the code name Quantum to promote parallelism and a more intuitive user interface.
  641. #+BEGIN_SRC nix :noweb yes :tangle modules/firefox.nix
  642. # <<file-warning>>
  643. { config, pkgs, ... }:
  644. let
  645. myFirefox = pkgs.writeShellScriptBin "firefox" ''
  646. HOME=~/.local/share/mozilla ${pkgs.firefox-bin}/bin/firefox
  647. '';
  648. in {
  649. # NOTE: Use the binary until module is developed.
  650. environment.systemPackages = [
  651. myFirefox
  652. ];
  653. }
  654. #+END_SRC
  655. ** Home Manager
  656. [[https://nixos.wiki/wiki/Home_Manager][Home Manager]] includes a =flake.nix= file for compatibility with Nix Flakes, a feature utilized heavily in this project. When using flakes, switching to a new configuration is done /only/ for the entire system, using the command ~nixos-rebuild switch --flake <path>~, instead of ~nixos-rebuild~, and ~home-manager~ seperately.
  657. #+NAME: module-home-manager
  658. #+BEGIN_SRC nix :noweb yes
  659. inputs.home-manager.nixosModules.home-manager {
  660. home-manager.useGlobalPkgs = true;
  661. home-manager.useUserPackages = true;
  662. home-manager.users.chris = {
  663. imports = [
  664. <<module-git>>
  665. <<module-gpg>>
  666. <<module-vim>>
  667. <<module-gtk>>
  668. <<module-emacs>>
  669. ];
  670. };
  671. }
  672. #+END_SRC
  673. Certain modules have to be included within home manager or they will not function correctly.
  674. #+NAME: home-manager-warning
  675. #+BEGIN_SRC text
  676. This module MUST be included within home manager
  677. #+END_SRC
  678. *** Git
  679. #+NAME: module-git
  680. #+BEGIN_SRC nix
  681. ./modules/git.nix
  682. #+END_SRC
  683. [[https://git.scm.com][Git]] is a free and open source distributed version control system designed to handle everything from small to very large projects with speed and efficiency. Git is easy to learn, has a tiny footprint, and lighting fast performance. It outclasses every other version control tool such as: SCM, Subversion, CVS, ClearCase, with features like cheap local branching, convinient staging areas, and multiple workflows.
  684. #+BEGIN_SRC nix :noweb yes :tangle modules/git.nix
  685. # <<file-warning>>
  686. # <<home-manager-warning>>
  687. { pkgs, ... }:
  688. let
  689. # Fix any corruptions in the local copy.
  690. myGitFix = pkgs.writeShellScriptBin "git-fix" ''
  691. if [ -d .git/objects/ ]; then
  692. find .git/objects/ -type f -empty | xargs rm -f
  693. git fetch -p
  694. git fsck --full
  695. fi
  696. exit 1
  697. '';
  698. in {
  699. home.packages = [ myGitFix ];
  700. programs.git = {
  701. enable = true;
  702. userName = "Christopher James Hayward";
  703. userEmail = "chris@chrishayward.xyz";
  704. signing = {
  705. key = "37AB1CB72B741E478CA026D43025DCBD46F81C0F";
  706. signByDefault = true;
  707. };
  708. };
  709. }
  710. #+END_SRC
  711. *** Gpg
  712. #+NAME: module-gpg
  713. #+BEGIN_SRC nix
  714. ./modules/gpg.nix
  715. #+END_SRC
  716. [[https://gnupg.org][GNU Privacy Guard]] is a free-software replacement for Symantec's PGP cryptographic software suite. It is compliant with RFC 4880, the IETF standards-track specification of OpenPGP. Modern versions of PGP are interoperable with GnuPG and other OpenPGP-compliant systems.
  717. #+BEGIN_SRC nix :noweb yes :tangle modules/gpg.nix
  718. # <<file-warning>>
  719. # <<home-manager-warning>>
  720. { pkgs, ... }:
  721. {
  722. services.gpg-agent = {
  723. enable = true;
  724. defaultCacheTtl = 1800;
  725. enableSshSupport = true;
  726. pinentryFlavor = "gtk2";
  727. };
  728. }
  729. #+END_SRC
  730. *** Vim
  731. #+NAME: module-vim
  732. #+BEGIN_SRC nix
  733. ./modules/vim.nix
  734. #+END_SRC
  735. [[https://neovim.io][Neovim]] is a project that seeks to aggressively refactor Vim in order to:
  736. + Simplify maintenance and encourage contributions
  737. + Split the work between multiple developers
  738. + Enable advanced UIs without core modification
  739. + Maximize extensibility
  740. #+BEGIN_SRC nix :noweb yes :tangle modules/vim.nix
  741. # <<file-warning>>
  742. # <<home-manager-warning>>
  743. { pkgs, ... }:
  744. {
  745. programs.neovim = {
  746. enable = true;
  747. viAlias = true;
  748. vimAlias = true;
  749. vimdiffAlias = true;
  750. extraConfig = ''
  751. set number relativenumber
  752. set nobackup
  753. '';
  754. extraPackages = [
  755. pkgs.nixfmt
  756. ];
  757. plugins = with pkgs.vimPlugins; [
  758. vim-nix
  759. vim-airline
  760. vim-polyglot
  761. ];
  762. };
  763. }
  764. #+END_SRC
  765. *** GTK
  766. #+NAME: module-gtk
  767. #+BEGIN_SRC nix
  768. ./modules/gtk.nix
  769. #+END_SRC
  770. [[https://gtk.org][GTK]] is a free and open-source, cross-platform widget toolkit for graphical user interfaces. It's one of the most popular toolkits for the [[https://wayland.freedesktop.org][Wayland]] and [[https://x.org/wiki/][X11]] windowing systems.
  771. #+BEGIN_SRC nix :noweb yes :tangle modules/gtk.nix
  772. # <<file-warning>>
  773. # <<home-manager-warning>>
  774. { pkgs, ... }:
  775. {
  776. home.packages = [
  777. pkgs.nordic
  778. pkgs.arc-icon-theme
  779. pkgs.lxappearance
  780. ];
  781. home.file.".gtkrc-2.0" = {
  782. text = ''
  783. gtk-theme-name="Nordic-darker"
  784. gtk-icon-theme-name="Arc"
  785. gtk-font-name="Iosevka 11"
  786. gtk-cursor-theme-size=0
  787. gtk-toolbar-style=GTK_TOOLBAR_BOTH_HORIZ
  788. gtk-toolbar-icon-size=GTK_ICON_SIZE_LARGE_TOOLBAR
  789. gtk-button-images=0
  790. gtk-menu-images=0
  791. gtk-enable-event-sounds=1
  792. gtk-enable-input-feedback-sounds=1
  793. gtk-xft-antialias=1
  794. gtk-xft-hinting=1
  795. gtk-xft-hintstyle="hintmedium"
  796. '';
  797. };
  798. home.file.".config/gtk-2.0/gtkfilechooser.ini" = {
  799. text = ''
  800. [Filechooser Settings]
  801. LocationMode=path-bar
  802. ShowHidden=false
  803. ShowSizeColumn=true
  804. GeometryX=442
  805. GeometryY=212
  806. GeometryWidth=1036
  807. GeometryHeight=609
  808. SortColumn=name
  809. SortOrder=ascending
  810. StartupMode=recent
  811. '';
  812. };
  813. home.file.".config/gtk-3.0/settings.ini" = {
  814. text = ''
  815. [Settings]
  816. gtk-theme-name=Nordic-darker
  817. gtk-icon-theme-name=Arc
  818. gtk-font-name=Iosevka 11
  819. gtk-cursor-theme-size=0
  820. gtk-toolbar-style=GTK_TOOLBAR_BOTH_HORIZ
  821. gtk-toolbar-icon-size=GTK_ICON_SIZE_LARGE_TOOLBAR
  822. gtk-button-images=0
  823. gtk-menu-images=0
  824. gtk-enable-event-sounds=1
  825. gtk-enable-input-feedback-sounds=1
  826. gtk-xft-antialias=1
  827. gtk-xft-hinting=1
  828. gtk-xft-hintstyle=hintmedium
  829. '';
  830. };
  831. }
  832. #+END_SRC
  833. ** Emacs Configuration
  834. #+ATTR_ORG: :width 300px
  835. #+ATTR_HTML: :width 300px
  836. #+ATTR_LATEX: :width 300px
  837. [[./docs/images/emacs.png]]
  838. #+NAME: module-emacs
  839. #+BEGIN_SRC nix
  840. ./modules/emacs.nix
  841. #+END_SRC
  842. [[https://gnu.org/software/emacs/][GNU/Emacs]] is an extensible, customizable, free/libre text editor -- and more. At its core is an interpreter for [[https://www.gnu.org/software/emacs/manual/html_node/elisp/index.html][Emacs Lisp]], a dialect of the Lisp programming language with extensions to support text editing. Other features include:
  843. + Highly customizable
  844. + Full Unicopde support
  845. + Content-aware editing modes
  846. + Complete built-in documentation
  847. + Wide range of functionality beyond text editing
  848. #+BEGIN_SRC nix :noweb yes :tangle modules/emacs.nix
  849. # <<file-warning>>
  850. # <<home-manager-warning>>
  851. { pkgs, ... }:
  852. let
  853. myEmacs = pkgs.emacsWithPackagesFromUsePackage {
  854. config = ../README.org;
  855. package = <<emacs-native-comp-package>>
  856. alwaysEnsure = true;
  857. alwaysTangle = true;
  858. extraEmacsPackages = epkgs: [
  859. # Required packages...
  860. <<emacs-exwm-package>>
  861. <<emacs-evil-package>>
  862. <<emacs-general-package>>
  863. <<emacs-which-key-package>>
  864. # Optional packages.
  865. <<emacs-org-package>>
  866. <<emacs-org-roam-package>>
  867. <<emacs-org-roam-ui-package>>
  868. <<emacs-org-drill-package>>
  869. <<emacs-pomodoro-package>>
  870. <<emacs-writegood-package>>
  871. <<emacs-http-package>>
  872. <<emacs-hugo-package>>
  873. <<emacs-pass-package>>
  874. <<emacs-docker-package>>
  875. <<emacs-mu4e-package>>
  876. <<emacs-dired-package>>
  877. <<emacs-icons-package>>
  878. <<emacs-emoji-package>>
  879. <<emacs-eshell-package>>
  880. <<emacs-vterm-package>>
  881. <<emacs-magit-package>>
  882. <<emacs-hydra-package>>
  883. <<emacs-elfeed-package>>
  884. <<emacs-nix-mode-package>>
  885. <<emacs-projectile-package>>
  886. <<emacs-lsp-package>>
  887. <<emacs-company-package>>
  888. <<emacs-gdscript-package>>
  889. <<emacs-ccls-package>>
  890. <<emacs-golang-package>>
  891. <<emacs-python-package>>
  892. <<emacs-rustic-package>>
  893. <<emacs-protobuf-package>>
  894. <<emacs-typescript-package>>
  895. <<emacs-plantuml-package>>
  896. # User interface packages.
  897. <<emacs-swiper-package>>
  898. <<emacs-desktop-package>>
  899. <<emacs-doom-themes-package>>
  900. <<emacs-doom-modeline-package>>
  901. ];
  902. };
  903. in {
  904. home.packages = [
  905. <<emacs-exwm-extras>>
  906. <<emacs-pass-extras>>
  907. <<emacs-mu4e-extras>>
  908. <<emacs-aspell-extras>>
  909. <<emacs-texlive-extras>>
  910. <<emacs-desktop-extras>>
  911. <<emacs-plantuml-extras>>
  912. <<emacs-nix-mode-extras>>
  913. <<emacs-doom-themes-extras>>
  914. ];
  915. programs.emacs = {
  916. enable = true;
  917. package = myEmacs;
  918. };
  919. <<emacs-exwm-config>>
  920. <<emacs-exwm-xinitrc>>
  921. <<emacs-mu4e-config>>
  922. }
  923. #+END_SRC
  924. When Emacs is started, it normally tries to load a Lisp program from an ititialization file, or /init/ file. This file, if it exists, specifies how to initialize and configure Emacs.
  925. #+BEGIN_SRC emacs-lisp :noweb yes :tangle ~/.config/emacs/init.el
  926. ;; <<file-warning>>
  927. ;; Required inputs.
  928. <<emacs-exwm-elisp>>
  929. <<emacs-evil-elisp>>
  930. <<emacs-general-elisp>>
  931. <<emacs-which-key-elisp>>
  932. ;; Optional inputs.
  933. <<emacs-org-elisp>>
  934. <<emacs-org-roam-elisp>>
  935. <<emacs-org-roam-ui-elisp>>
  936. <<emacs-org-drill-elisp>>
  937. <<emacs-org-agenda-elisp>>
  938. <<emacs-pomodoro-elisp>>
  939. <<emacs-writegood-elisp>>
  940. <<emacs-aspell-elisp>>
  941. <<emacs-eww-elisp>>
  942. <<emacs-http-elisp>>
  943. <<emacs-hugo-elisp>>
  944. <<emacs-pass-elisp>>
  945. <<emacs-docker-elisp>>
  946. <<emacs-erc-elisp>>
  947. <<emacs-mu4e-elisp>>
  948. <<emacs-dired-elisp>>
  949. <<emacs-icons-elisp>>
  950. <<emacs-emoji-elisp>>
  951. <<emacs-eshell-elisp>>
  952. <<emacs-vterm-elisp>>
  953. <<emacs-magit-elisp>>
  954. <<emacs-fonts-elisp>>
  955. <<emacs-frames-elisp>>
  956. <<emacs-elfeed-elisp>>
  957. <<emacs-projectile-elisp>>
  958. <<emacs-lsp-elisp>>
  959. <<emacs-company-elisp>>
  960. <<emacs-gdscript-elisp>>
  961. <<emacs-golang-elisp>>
  962. <<emacs-python-elisp>>
  963. <<emacs-rustic-elisp>>
  964. <<emacs-plantuml-elisp>>
  965. <<emacs-desktop-elisp>>
  966. ;; User interface.
  967. <<emacs-swiper-elisp>>
  968. <<emacs-transparency-elisp>>
  969. <<emacs-doom-themes-elisp>>
  970. <<emacs-doom-modeline-elisp>>
  971. #+END_SRC
  972. It's somtimes desirable to have customization that takes effect during Emacs startup earlier than the normal init file. Place these configurations in =~/.emacs.d/early-init.el=. Most customizations should be put in the normal init file =~/.emacs.d/init.el=.
  973. #+BEGIN_SRC emacs-lisp :noweb yes :tangle ~/.config/emacs/early-init.el
  974. ;; <<file-warning>>
  975. <<emacs-disable-ui-elisp>>
  976. <<emacs-native-comp-elisp>>
  977. <<emacs-backup-files-elisp>>
  978. <<emacs-shell-commands-elisp>>
  979. <<emacs-improved-prompts>>
  980. #+END_SRC
  981. *** Native Comp
  982. #+NAME: emacs-native-comp-package
  983. #+BEGIN_SRC nix
  984. pkgs.emacsNativeComp;
  985. #+END_SRC
  986. Native Comp, also known as GccEmacs, refers to the ~--with-native-compilation~ configuration option when building [[https://gnu.org/software/emacs/][GNU/Emacs]]. It adds support for compiling [[https://www.gnu.org/software/emacs/manual/html_node/elisp/index.html][Emacs Lisp]] to native code using ~libgccjit~. All of the Emacs Lisp packages shipped with Emacs are native-compiled, providing a noticable performance iomprovement out-of-the-box.
  987. #+NAME: emacs-native-comp-elisp
  988. #+BEGIN_SRC emacs-lisp
  989. ;; Silence warnings from packages that don't support `native-comp'.
  990. (setq comp-async-report-warnings-errors nil ;; Emacs 27.2 ...
  991. native-comp-async-report-warnings-errors nil) ;; Emacs 28+ ...
  992. #+END_SRC
  993. *** Disable UI
  994. [[https://gnu.org/software/emacs/][Emacs]] has been around since the 1980s, and it's painfully obvious when you're greeted with the default user interface. Disable some unwanted features to clean it up, and bring the appearance to something closer to a modern editor.
  995. #+NAME: emacs-disable-ui-elisp
  996. #+BEGIN_SRC emacs-lisp
  997. ;; Disable unwanted UI elements.
  998. (tooltip-mode -1)
  999. (menu-bar-mode -1)
  1000. (tool-bar-mode -1)
  1001. (scroll-bar-mode -1)
  1002. ;; Fix the scrolling behaviour.
  1003. (setq scroll-conservatively 101)
  1004. ;; Fix mouse-wheel scrolling behaviour.
  1005. (setq mouse-wheel-follow-mouse t
  1006. mouse-wheel-progressive-speed t
  1007. mouse-wheel-scroll-amount '(3 ((shift) . 3)))
  1008. ;; Start in fullscreen/maximized.
  1009. (add-to-list 'default-frame-alist '(fullscreen . maximized))
  1010. #+END_SRC
  1011. *** Backup Files
  1012. [[https://gnu.org/software/emacs/][Emacs]] makes a backup for a file only the first time the file is saved from a buffer. No matter how many times the file is subsequently written to, the backup remains unchanged. For files managed by a version control system, backup files are redundant since the previous versions are already stored.
  1013. #+NAME: emacs-backup-files-elisp
  1014. #+BEGIN_SRC emacs-lisp
  1015. ;; Disable unwanted features.
  1016. (setq make-backup-files nil
  1017. create-lockfiles nil)
  1018. #+END_SRC
  1019. *** Shell Commands
  1020. Define some methods for interaction between [[https://gnu.org/software/emacs/][GNU/Emacs]], and the systems underyling shell:
  1021. 1) Method to run an external process, launching any application on a new process without interference
  1022. 2) Method to apply commands to the current call process, effecting the running instance
  1023. #+NAME: emacs-shell-commands-elisp
  1024. #+BEGIN_SRC emacs-lisp
  1025. ;; Define a method to run an external process.
  1026. (defun dotfiles/run (cmd)
  1027. "Run an external process."
  1028. (interactive (list (read-shell-command "λ ")))
  1029. (start-process-shell-command cmd nil cmd))
  1030. ;; Define a method to run a background process.
  1031. (defun dotfiles/run-in-background (cmd)
  1032. (let ((command-parts (split-string cmd "[ ]+")))
  1033. (apply #'call-process `(,(car command-parts) nil 0 nil ,@(cdr command-parts)))))
  1034. #+END_SRC
  1035. *** Improved prompts
  1036. By default Emacs will ask you to enter 'Yes' or 'No' instead of 'Y' or 'N'. This is a relatively conservative design decision, based on the fact that certain prompts may be important enough to warrant typing three characters.
  1037. #+NAME: emacs-improved-prompts
  1038. #+BEGIN_SRC emacs-lisp
  1039. ;; Use 'y' and 'n' instead of 'yes' and 'no'.
  1040. (defalias 'yes-or-no-p 'y-or-n-p)
  1041. #+END_SRC
  1042. *** Nix Mode
  1043. #+NAME: emacs-nix-mode-extras
  1044. #+BEGIN_SRC nix
  1045. pkgs.nixfmt
  1046. pkgs.rnix-lsp
  1047. #+END_SRC
  1048. [[https://github.com/nixos/nix-mode][Nix Mode]] is an [[https://gnu.org/software/emacs/][Emacs]] major mode for editing [[https://nixos.org/manual/nix/stable/][Nix]] expressions. This provides basic handling of =.nix= files. Syntax highlighting and indentation support using =SMIE= are provided. [[https:github.com/nix-community/rnix-lsp][rnix-lsp]] is a work-in-progress language server for Nix with syntax checking and basic completion.
  1049. #+NAME: emacs-nix-mode-package
  1050. #+BEGIN_SRC nix
  1051. epkgs.nix-mode
  1052. #+END_SRC
  1053. *** Evil Mode
  1054. [[https://evil.readthedocs.io/en/latest/overview.html][Evil Mode]] is an extensible VI layer for [[https://gnu.org/software/emacs/][GNU/Emacs]]. It emulates the main features of [[https://neovim.io][Vim]], transforming GNU/Emacs into a modal editor.
  1055. #+NAME: emacs-evil-package
  1056. #+BEGIN_SRC nix
  1057. epkgs.evil
  1058. epkgs.evil-collection
  1059. epkgs.evil-surround
  1060. epkgs.evil-nerd-commenter
  1061. #+END_SRC
  1062. The next time [[https://gnu.org/software/emacs/][Emacs]] is started, it will come up in /normal state/, denoted by =<N>= in the modeline. This is where the main ~vi~ bindings are defined. Like Emacs in general, [[https://evil.readthedocs.io/en/latest/overview.html][Evil Mode]] is extensible in [[https://www.gnu.org/software/emacs/manual/html_node/elisp/index.html][Emacs Lisp]].
  1063. #+NAME: emacs-evil-elisp
  1064. #+BEGIN_SRC emacs-lisp
  1065. ;; Enable the Extensible VI Layer for Emacs.
  1066. (setq evil-want-integration t ;; Required for `evil-collection.'
  1067. evil-want-keybinding nil ;; Same as above.
  1068. evil-want-C-i-jump nil) ;; Disable jumping in terminal.
  1069. (evil-mode +1)
  1070. ;; Configure `evil-collection'.
  1071. (evil-collection-init)
  1072. ;; Configure `evil-surround'.
  1073. (global-evil-surround-mode +1)
  1074. ;; Configure `evil-nerd-commenter'.
  1075. (global-set-key (kbd "M-;") 'evilnc-comment-or-uncomment-lines)
  1076. ;; Invoke `org-cycle' in normal mode inside of `org-mode' buffers.
  1077. (evil-define-key 'normal 'org-mode-map (kbd "<tab>") #'org-cycle)
  1078. #+END_SRC
  1079. *** EXWM
  1080. #+NAME: emacs-exwm-package
  1081. #+BEGIN_SRC nix
  1082. epkgs.exwm
  1083. #+END_SRC
  1084. [[https://github.com/ch11ng/exwm][EXWM]] (Emacs X Window Manager) is a full-featured tiling [[https://x.org/wiki/][X11]] window manager for [[https://gnu.org/software/emacs/][GNU/Emacs]] built on-top of XELB. It features:
  1085. + Fully keyboard-driven operations
  1086. + Hybrid layout modes (tiling & stacking)
  1087. + Dynamic workspace support
  1088. + ICCM/EWMH compliance
  1089. #+NAME: emacs-exwm-extras
  1090. #+BEGIN_SRC nix
  1091. pkgs.nitrogen
  1092. pkgs.autorandr
  1093. #+END_SRC
  1094. I wanted to leave ~(exwm-enable)~ out of my Emacs configuration (which does no harm anyways). This can be called when using the daemon to start [[https://github.com/ch11ng/exwm][EXWM]].
  1095. #+NAME: emacs-exwm-config
  1096. #+BEGIN_SRC nix
  1097. xsession = {
  1098. enable = true;
  1099. windowManager.command = ''
  1100. ${pkgs.nitrogen}/bin/nitrogen --restore
  1101. ${myEmacs}/bin/emacs --daemon -f exwm-enable
  1102. ${myEmacs}/bin/emacsclient -c
  1103. '';
  1104. };
  1105. #+END_SRC
  1106. [[https://github.com/ch11ng/exwm][EXWM]] cannot make an [[https://x.org/wiki/][X]] window manager by itself, this is by design; You must tell X to do it. Override the =~/.xinitrc= file to start the =xsession=.
  1107. #+NAME: emacs-exwm-xinitrc
  1108. #+BEGIN_SRC nix
  1109. home.file.".xinitrc" = {
  1110. text = ''
  1111. exec ./.xsession
  1112. '';
  1113. };
  1114. #+END_SRC
  1115. #+NAME: emacs-exwm-elisp
  1116. #+BEGIN_SRC emacs-lisp
  1117. ;; Configure `exwm'.
  1118. (setq exwm-workspace-number 5
  1119. exwm-layout-show-all-buffers t
  1120. exwm-worspace-show-all-buffers t)
  1121. ;; Configure input keys.
  1122. (setq exwm-input-prefix-keys
  1123. '(?\M-x
  1124. ?\C-g
  1125. ?\C-\ ))
  1126. (setq exwm-input-global-keys
  1127. `(([?\s-r] . exwm-reset)
  1128. ,@(mapcar (lambda (i)
  1129. `(,(kbd (format "s-%d" i)) .
  1130. (lambda ()
  1131. (interactive)
  1132. (exwm-workspace-switch-create ,i))))
  1133. (number-sequence 0 9))))
  1134. ;; Configure `exwm-randr'.
  1135. (require 'exwm-randr)
  1136. (exwm-randr-enable)
  1137. ;; Configure custom hooks.
  1138. (setq display-time-day-and-date t)
  1139. (add-hook 'exwm-init-hook
  1140. (lambda ()
  1141. (display-battery-mode +1) ;; Display battery info (if available).
  1142. (display-time-mode +1))) ;; Display the time in the modeline.
  1143. ;; Setup buffer display names.
  1144. (add-hook 'exwm-update-class-hook
  1145. (lambda ()
  1146. (exwm-workspace-rename-buffer exwm-class-name))) ;; Use the system class name.
  1147. ;; Configure monitor hot-swapping.
  1148. (add-hook 'exwm-randr-screen-change-hook
  1149. (lambda ()
  1150. (dotfiles/run-in-background "autorandr --change --force"))) ;; Swap to the next screen config.
  1151. #+END_SRC
  1152. *** General
  1153. #+NAME: emacs-general-package
  1154. #+BEGIN_SRC nix
  1155. epkgs.general
  1156. #+END_SRC
  1157. [[https://github.com/noctuid/general.el][General.el]] provides a more convenient method for binding keys in [[https://gnu.org/software/emacs/][Emacs]], providing a unified interface for key definitions. Its primary purpose is to build on /existing/ functionality to make key definitions more clear and concise.
  1158. #+NAME: emacs-general-elisp
  1159. #+BEGIN_SRC emacs-lisp
  1160. ;; Use <SPC> as a leader key via `general.el'.
  1161. (general-create-definer dotfiles/leader
  1162. :keymaps '(normal insert visual emacs)
  1163. :prefix "SPC"
  1164. :global-prefix "C-SPC")
  1165. ;; Setup general to work with `evil-mode'.
  1166. (setq general-evil-setup t)
  1167. ;; Find files with <SPC> <period> ...
  1168. ;; Switch buffers with <SPC> <comma> ...
  1169. (dotfiles/leader
  1170. "." '(find-file :which-key "File")
  1171. "," '(switch-to-buffer :which-key "Buffer")
  1172. "k" '(kill-buffer :which-key "Kill")
  1173. "c" '(kill-buffer-and-window :which-key "Close"))
  1174. ;; Add keybindings for executing shell commands.
  1175. (dotfiles/leader
  1176. "r" '(:ignore t :which-key "Run")
  1177. "rr" '(dotfiles/run :which-key "Run")
  1178. "ra" '(async-shell-command :which-key "Async"))
  1179. ;; Add keybindings for quitting Emacs.
  1180. (dotfiles/leader
  1181. "q" '(:ignore t :which-key "Quit")
  1182. "qq" '(save-buffers-kill-emacs :which-key "Save")
  1183. "qw" '(kill-emacs :which-key "Now")
  1184. "qf" '(delete-frame :which-key "Frame"))
  1185. ;; Add keybindings for toggles / tweaks.
  1186. (dotfiles/leader
  1187. "t" '(:ignore t :which-key "Toggle / Tweak"))
  1188. #+END_SRC
  1189. *** Which Key
  1190. [[https://github.com/justbur/emacs-which-key][Which Key]] is an [[https://gnu.org/software/emacs/][Emacs]] minor mode that displays the key bindings following your currently entered incomplete command (prefix) in a popup or mini-buffer.
  1191. #+NAME: emacs-which-key-package
  1192. #+BEGIN_SRC nix
  1193. epkgs.which-key
  1194. #+END_SRC
  1195. #+NAME: emacs-which-key-elisp
  1196. #+BEGIN_SRC emacs-lisp
  1197. ;; Configure `which-key' to see keyboard bindings in the
  1198. ;; mini-buffer and when using M-x.
  1199. (setq which-key-idle-delay 0.0)
  1200. (which-key-mode +1)
  1201. #+END_SRC
  1202. *** EWW
  1203. [[https://emacswiki.org/emacs/eww][Emacs Web Wowser (EWW)]] is a Web browser written in [[https://www.gnu.org/software/emacs/manual/html_node/elisp/index.html][Emacs Lisp]] based on the ~shr.el~ library. It's my primary browser when it comes to text-based browsing.
  1204. + Use ~eww~ as the default browser
  1205. + Don't use any special fonts or colours
  1206. #+NAME: emacs-eww-elisp
  1207. #+BEGIN_SRC emacs-lisp
  1208. ;; Set `eww' as the default browser.
  1209. (setq browse-url-browser-function 'eww-browse-url)
  1210. ;; Configure the `shr' rendering engine.
  1211. (setq shr-use-fonts nil
  1212. shr-use-colors nil)
  1213. #+END_SRC
  1214. *** ERC
  1215. [[https://gnu.org/software/emacs/erc.html][ERC]] is a powerful, modular, and extensible IRC client for [[https://gnu.org/software/emacs/][GNU/Emacs]]. It's part of the GNU project, and included in Emacs.
  1216. #+NAME: emacs-erc-elisp
  1217. #+BEGIN_SRC emacs-lisp
  1218. ;; Configure `erc'.
  1219. (setq erc-autojoin-channels-alist '(("irc.libera.chat" "#emacs" "#nixos" "#org-mode" "#systemcrafters"))
  1220. erc-track-exclude-types '("JOIN" "NICK" "QUIT" "MODE")
  1221. erc-lurker-hide-list '("JOIN" "PART" "QUIT"))
  1222. ;; Configure `erc-fill-column'.
  1223. (add-hook 'window-configuration-change-hook
  1224. '(lambda ()
  1225. (setq erc-fill-column (- (window-width) 12))))
  1226. ;; Connect to IRC via `erc'.
  1227. (defun dotfiles/erc-connect ()
  1228. "Connected to IRC via `erc'."
  1229. (interactive)
  1230. (erc-tls :server "irc.libera.chat"
  1231. :port 6697
  1232. :nick "megaphone"
  1233. :password (password-store-get "libera.chat/megaphone")
  1234. :full-name "Chris Hayward"))
  1235. ;; Configure keybindings.
  1236. (dotfiles/leader
  1237. "i" '(dotfiles/erc-connect :which-key "Chat"))
  1238. #+END_SRC
  1239. *** Dired
  1240. #+NAME: emacs-dired-package
  1241. #+BEGIN_SRC nix
  1242. epkgs.dired-single
  1243. #+END_SRC
  1244. [[https://emacswiki.org/emacs/DiredMode][Dired Mode]] shows a directory listing inside of an [[https://gnu.org/software/emacs/][Emacs]] buffer that can be used to perform various file operations on files and subdirectories. The operations you can perform are numerous, from creating subdirectories, byte-compiling files, searching, and editing files. [[https://emacswiki.org/emacs/DiredExtra#Dired_X][Dired Extra]] provides extra functionality.
  1245. #+NAME: emacs-dired-elisp
  1246. #+BEGIN_SRC emacs-lisp
  1247. ;; Include `dired-x' for the `jump' method.
  1248. (require 'dired-x)
  1249. ;; Configure `dired-single' to support `evil' keys.
  1250. (evil-collection-define-key 'normal 'dired-mode-map
  1251. "h" 'dired-single-up-directory
  1252. "l" 'dired-single-buffer)
  1253. ;; Configure keybindings for `dired'.
  1254. (dotfiles/leader
  1255. "d" '(dired-jump :which-key "Dired"))
  1256. #+END_SRC
  1257. *** Icons
  1258. #+NAME: emacs-icons-package
  1259. #+BEGIN_SRC nix
  1260. epkgs.all-the-icons
  1261. epkgs.all-the-icons-dired
  1262. epkgs.all-the-icons-ivy-rich
  1263. #+END_SRC
  1264. [[https://github.com/domtronn/all-the-icons.el][All The Icons]] is a utility package to collect various Icon Fonts and prioritize them within [[https://gnu.org/software/emacs/][GNU/Emacs]].
  1265. #+NAME: emacs-icons-elisp
  1266. #+BEGIN_SRC emacs-lisp
  1267. ;; Setup `all-the-icons-dired'.
  1268. (add-hook 'dired-mode-hook 'all-the-icons-dired-mode)
  1269. ;; Disable monochrome icons.
  1270. (setq all-the-icons-dired-monochrome nil)
  1271. ;; Display default font ligatures.
  1272. (global-prettify-symbols-mode +1)
  1273. #+END_SRC
  1274. *** Emojis
  1275. #+NAME: emacs-emoji-package
  1276. #+BEGIN_SRC nix
  1277. epkgs.emojify
  1278. #+END_SRC
  1279. [[https://github.com/iqbalansari/emacs-emojify][Emojify]] is an [[https://gnu.org/software/emacs/][Emacs]] extension to display Emojis. It can display GitHub style Emojis like :smile: or plain ascii ones such as :). It tries to be as efficient as possible, while also providing flexibility.
  1280. #+NAME: emacs-emoji-elisp
  1281. #+BEGIN_SRC emacs-lisp
  1282. ;; Setup `emojify'.
  1283. (add-hook 'after-init-hook 'global-emojify-mode)
  1284. #+END_SRC
  1285. *** EShell
  1286. #+NAME: emacs-eshell-package
  1287. #+BEGIN_SRC nix
  1288. epkgs.eshell-prompt-extras
  1289. #+END_SRC
  1290. [[https://gnu.org/software/emacs/manual/html_mono/eshell.html][EShell]] is a shell-like command interpreter for [[https://gnu.org/software/emacs/][GNU/Emacs]] implemented in [[https://www.gnu.org/software/emacs/manual/html_node/elisp/index.html][Emacs Lisp]]. It invokes no external processes except for those requested by the user. It's intended to be an alternative for IELM, and a full REPL envionment for Emacs.
  1291. #+NAME: emacs-eshell-elisp
  1292. #+BEGIN_SRC emacs-lisp
  1293. ;; Configure `eshell'.
  1294. (setq eshell-highlight-prompt nil
  1295. eshell-prefer-lisp-functions nil)
  1296. ;; Configure the lambda prompt.
  1297. (autoload 'epe-theme-lambda "eshell-prompt-extras")
  1298. (setq eshell-prompt-function 'epe-theme-lambda)
  1299. ;; Configure keybindings for `eshell'.
  1300. (dotfiles/leader
  1301. "e" '(eshell :which-key "EShell"))
  1302. #+END_SRC
  1303. *** VTerm
  1304. [[https://github.com/akermu/emacs-libvterm][Emacs Libvterm (VTerm)]] is a fully-fledged terminal emulator inside [[https://gnu.org/software/emacs/][GNU/Emacs]] based on [[https://github.com/neovim/libvterm][Libvterm]], a blazing fast C library used in [[https://neovim.io][Neovim]]. As a result of using compiled code (instead of [[https://www.gnu.org/software/emacs/manual/html_node/elisp/index.html][Emacs Lisp]]), VTerm is capable, fast, and it can seamlessly handle large outputs.
  1305. #+NAME: emacs-vterm-package
  1306. #+BEGIN_SRC nix
  1307. epkgs.vterm
  1308. #+END_SRC
  1309. #+NAME: emacs-vterm-elisp
  1310. #+BEGIN_SRC emacs-lisp
  1311. ;; Add keybindings for interacting with the shell(s).
  1312. (dotfiles/leader
  1313. "v" '(vterm :which-key "VTerm"))
  1314. #+END_SRC
  1315. *** Magit
  1316. [[https://magit.vc][Magit]] is an interface to the [[https://git-scm.com][Git]] version control system, implemented as a [[https://gnu.org/software/emacs/][GNU/Emacs]] package written in [[https://www.gnu.org/software/emacs/manual/html_node/elisp/index.html][Emacs Lisp]]. It fills the glaring gap between the Git command line interface and various GUIs, letting you perform trivial as well as elaborate version control tasks within a few mnemonic key presses.
  1317. #+NAME: emacs-magit-package
  1318. #+BEGIN_SRC nix
  1319. epkgs.magit
  1320. #+END_SRC
  1321. #+NAME: emacs-magit-elisp
  1322. #+BEGIN_SRC emacs-lisp
  1323. ;; Add keybindings for working with `magit'.
  1324. (dotfiles/leader
  1325. "g" '(:ignore t :which-key "Git")
  1326. "gg" '(magit-status :which-key "Status")
  1327. "gc" '(magit-clone :which-key "Clone")
  1328. "gf" '(magit-fetch :which-key "Fetch")
  1329. "gp" '(magit-pull :which-key "Pull"))
  1330. #+END_SRC
  1331. *** Hydra
  1332. #+NAME: emacs-hydra-package
  1333. #+BEGIN_SRC nix
  1334. epkgs.hydra
  1335. #+END_SRC
  1336. [[https://github.com/abo-abo/hydra][Hydra]] allows you to create keymaps for related commands, with the ability to easily repeat commands using a single keystroke.
  1337. *** Fonts
  1338. [[https://typeof.net/Iosevka][Iosevka]] is an open-source, sans-serif + slab-serif, monospace + quasi-proportional typeface family, designed for writing code, using in terminals, and preparing technical documents. Configure it as the default font face inside of [[https://gnu.org/software/emacs/][Emacs]] and define a [[https://github.com/abo-abo/hydra][Hydra]] command for quickly scaling text.
  1339. #+NAME: emacs-fonts-elisp
  1340. #+BEGIN_SRC emacs-lisp
  1341. ;; Configure the font when running as `emacs-server'.
  1342. (custom-set-faces
  1343. '(default ((t (:inherit nil :height 120 :family "Iosevka")))))
  1344. ;; Define a `hydra' function for scaling the text interactively.
  1345. (defhydra hydra-text-scale (:timeout 4)
  1346. "Scale the text in the current buffer."
  1347. ("k" text-scale-decrease "Decrease")
  1348. ("j" text-scale-increase "Increase")
  1349. ("f" nil "Finished" :exit t))
  1350. ;; Create keybinding for calling the function.
  1351. (dotfiles/leader
  1352. "tf" '(hydra-text-scale/body :which-key "Font"))
  1353. #+END_SRC
  1354. *** Frames
  1355. Sometimes it's useful to resize the current frame without using the mouse (always). The default behaviour when calling ~shrink-window~ and ~enlarge-window~ only changes the size by a small margin. I solved this problem with the same method used for scaling text:
  1356. #+NAME: emacs-frames-elisp
  1357. #+BEGIN_SRC emacs-lisp
  1358. ;; Define a `hydra' function for resizing the current frame.
  1359. (defhydra hydra-resize-frame (:timeout 4)
  1360. "Scale the current frame."
  1361. ("h" shrink-window-horizontally "Left")
  1362. ("j" enlarge-window "Down")
  1363. ("k" shrink-window "Up")
  1364. ("l" enlarge-window-horizontally "Right")
  1365. ("f" nil "Finished" :exit t))
  1366. ;; Add keybindings for working with frames to replace
  1367. ;; the C-x <num> <num> method of bindings, which is awful.
  1368. (dotfiles/leader
  1369. "w" '(:ignore t :which-key "Windows")
  1370. "ww" '(window-swap-states :which-key "Swap")
  1371. "wc" '(delete-window :which-key "Close")
  1372. "wh" '(windmove-left :which-key "Left")
  1373. "wj" '(windmove-down :which-key "Down")
  1374. "wk" '(windmove-up :which-key "Up")
  1375. "wl" '(windmove-right :which-key "Right")
  1376. "ws" '(:ignore t :which-key "Split")
  1377. "wsj" '(split-window-below :which-key "Below")
  1378. "wsl" '(split-window-right :which-key "Right")
  1379. "wr" '(hydra-resize-frame/body :which-key "Resize"))
  1380. #+END_SRC
  1381. *** Elfeed
  1382. #+NAME: emacs-elfeed-package
  1383. #+BEGIN_SRC nix
  1384. epkgs.elfeed
  1385. #+END_SRC
  1386. [[https://github.com/skeeto/elfeed][Elfeed]] is an extensible web feed reader for [[https://gnu.org/software/emacs/][GNU/Emacs]], support both =Atom= and =RSS=. It requires =Emacs 24.3+= and is available for download from the standard repositories.
  1387. #+NAME: emacs-elfeed-elisp
  1388. #+BEGIN_SRC emacs-lisp
  1389. ;; Configure `elfeed'.
  1390. (setq elfeed-db-directory (expand-file-name "~/.cache/elfeed"))
  1391. ;; Add custom feeds for `elfeed' to fetch.
  1392. (setq elfeed-feeds (quote
  1393. (("https://hexdsl.co.uk/rss.xml")
  1394. ("https://lukesmith.xyz/rss.xml")
  1395. ("https://friendo.monster/rss.xml")
  1396. ("https://chrishayward.xyz/index.xml")
  1397. ("https://protesilaos.com/master.xml"))))
  1398. ;; Add custom keybindings for `elfeed'.
  1399. (dotfiles/leader
  1400. "f" '(:ignore t :which-key "Elfeed")
  1401. "fl" '(elfeed :which-key "Open")
  1402. "fu" '(elfeed-update :which-key "Update"))
  1403. #+END_SRC
  1404. *** Org Mode
  1405. #+NAME: emacs-org-package
  1406. #+BEGIN_SRC nix
  1407. epkgs.org
  1408. #+END_SRC
  1409. [[https://orgmode.org][Org Mode]] is a document editing and organizing mode, designed for notes, planning, and authoring within the free software text editor [[https://gnu.org/software/emacs/][GNU/Emacs]]. The name is used to encompass plain text files (such as this one) that include simple marks to indicate levels of a hierarchy, and an editor with functions that can read the markup and manipulate the hierarchy elements.
  1410. #+NAME: emacs-org-elisp
  1411. #+BEGIN_SRC emacs-lisp
  1412. ;; Configure `org-mode' source blocks.
  1413. (setq org-src-fontify-natively t ;; Make source blocks prettier.
  1414. org-src-tab-acts-natively t ;; Use TAB indents within source blocks.
  1415. org-hide-emphasis-markers t ;; Don't show emphasis markup.
  1416. org-src-preserve-indentation t ;; Stop `org-mode' from formatting blocks.
  1417. org-confirm-babel-evaluate nil) ;; Don't ask for confirmation to evaluate blocks.
  1418. ;; Add an `org-mode-hook'.
  1419. (add-hook 'org-mode-hook
  1420. (lambda ()
  1421. (org-indent-mode)
  1422. (visual-line-mode)))
  1423. ;; Remove the `Validate XHTML 1.0' message from HTML export.
  1424. (setq org-export-html-validation-link nil
  1425. org-html-validation-link nil)
  1426. ;; Configure the keywords in the TODO -> DONE sequence.
  1427. (setq org-todo-keywords '((sequence "TODO" "START" "WAIT" "DONE")))
  1428. ;; Track ids globally.
  1429. (setq org-id-track-globally t)
  1430. ;; Configure `org-babel' languages.
  1431. (org-babel-do-load-languages
  1432. 'org-babel-load-languages
  1433. '((C . t)))
  1434. ;; Log / Clock into property drawers.
  1435. (setq org-log-into-drawer t
  1436. org-clock-into-drawer t)
  1437. ;; Encrypt files with the public key.
  1438. (setq epa-file-select-keys 2
  1439. epa-file-encrypt-to "37AB1CB72B741E478CA026D43025DCBD46F81C0F"
  1440. epa-cache-passphrase-for-symmetric-encryption t)
  1441. ;; TODO: Configure default structure templates.
  1442. ;; (require 'org-tempo)
  1443. ;; Don't use native image sizes in previews.
  1444. (setq org-image-actual-width nil)
  1445. ;; Apply custom keybindings.
  1446. (dotfiles/leader
  1447. "o" '(:ignore t :which-key "Org")
  1448. "oe" '(org-export-dispatch :which-key "Export")
  1449. "ot" '(org-babel-tangle :which-key "Tangle")
  1450. "oi" '(org-toggle-inline-images :which-key "Images")
  1451. "of" '(:ignore t :which-key "Footnotes")
  1452. "ofn" '(org-footnote-normalize :which-key "Normalize"))
  1453. #+END_SRC
  1454. *** Org Roam
  1455. #+NAME: emacs-org-roam-package
  1456. #+BEGIN_SRC nix
  1457. epkgs.org-roam
  1458. #+END_SRC
  1459. [[https://github.com/org-roam/org-roam][Org Roam]] is a plain-text knowledge management system. It borrows principles from the [[https://zettelkasten.de][Zettelkasten]] method, providing a solution for non-hierarchical note-taking. It should also work as a plug-and-play solution for anyone already using [[https://orgmode.org][Org Mode]] for their personal wiki.
  1460. #+NAME: emacs-org-roam-elisp
  1461. #+BEGIN_SRC emacs-lisp
  1462. ;; Setup `org-roam'.
  1463. (require 'org-roam)
  1464. ;; Silence the migration warnings.
  1465. (setq org-roam-v2-ack t)
  1466. ;; Enable `visual-line-mode' in `org-roam' buffer.
  1467. (add-hook 'org-roam-mode-hook
  1468. (lambda ()
  1469. (visual-line-mode +1)))
  1470. ;; Enable completion everywhere.
  1471. (setq org-roam-completion-everywhere t)
  1472. ;; Set the roam directories.
  1473. (setq org-roam-directory (expand-file-name "/etc/dotfiles")
  1474. org-roam-dailies-directory (concat org-roam-directory "/docs/daily"))
  1475. ;; Clear the deafult capture templates.
  1476. (setq org-roam-capture-templates '()
  1477. org-roam-dailies-capture-templates '())
  1478. ;; Override the default slug method.
  1479. (cl-defmethod org-roam-node-slug ((node org-roam-node))
  1480. (let ((title (org-roam-node-title node))
  1481. (slug-trim-chars '(768 ; U+0300 COMBINING GRAVE ACCENT
  1482. 769 ; U+0301 COMBINING ACUTE ACCENT
  1483. 770 ; U+0302 COMBINING CIRCUMFLEX ACCENT
  1484. 771 ; U+0303 COMBINING TILDE
  1485. 772 ; U+0304 COMBINING MACRON
  1486. 774 ; U+0306 COMBINING BREVE
  1487. 775 ; U+0307 COMBINING DOT ABOVE
  1488. 776 ; U+0308 COMBINING DIAERESIS
  1489. 777 ; U+0309 COMBINING HOOK ABOVE
  1490. 778 ; U+030A COMBINING RING ABOVE
  1491. 780 ; U+030C COMBINING CARON
  1492. 795 ; U+031B COMBINING HORN
  1493. 803 ; U+0323 COMBINING DOT BELOW
  1494. 804 ; U+0324 COMBINING DIAERESIS BELOW
  1495. 805 ; U+0325 COMBINING RING BELOW
  1496. 807 ; U+0327 COMBINING CEDILLA
  1497. 813 ; U+032D COMBINING CIRCUMFLEX ACCENT BELOW
  1498. 814 ; U+032E COMBINING BREVE BELOW
  1499. 816 ; U+0330 COMBINING TILDE BELOW
  1500. 817 ; U+0331 COMBINING MACRON BELOW
  1501. )))
  1502. (cl-flet* ((nonspacing-mark-p (char)
  1503. (memq char slug-trim-chars))
  1504. (strip-nonspacing-marks (s)
  1505. (ucs-normalize-NFC-string
  1506. (apply #'string (seq-remove #'nonspacing-mark-p
  1507. (ucs-normalize-NFD-string s)))))
  1508. (cl-replace (title pair)
  1509. (replace-regexp-in-string (car pair) (cdr pair) title)))
  1510. (let* ((pairs `(("[^[:alnum:][:digit:]]" . "-")
  1511. ("--*" . "-")
  1512. ("^-" . "")
  1513. ("-$" . "")))
  1514. (slug (-reduce-from #'cl-replace (strip-nonspacing-marks title) pairs)))
  1515. (downcase slug)))))
  1516. ;; Configure capture templates.
  1517. ;; Standard document.
  1518. (add-to-list 'org-roam-capture-templates
  1519. '("d" "Default" plain "%?"
  1520. :target (file+head "docs/%<%Y%m%d%H%M%S>-${slug}.org.gpg"
  1521. "
  1522. ,#+TITLE: ${title}
  1523. ,#+AUTHOR: Christopher James Hayward
  1524. ,#+EMAIL: chris@chrishayward.xyz
  1525. "
  1526. )
  1527. :unnarrowed t))
  1528. ;; Daily notes.
  1529. (add-to-list 'org-roam-dailies-capture-templates
  1530. '("d" "Default" entry "* %?"
  1531. :target (file+head "%<%Y-%m-%d>.org.gpg"
  1532. "
  1533. ,#+TITLE: %<%Y-%m-%d>
  1534. ,#+AUTHOR: Christopher James Hayward
  1535. ,#+EMAIL: chris@chrishayward.xyz
  1536. ")))
  1537. ;; Apply custom keybindings.
  1538. (dotfiles/leader
  1539. "or" '(:ignore t :which-key "Roam")
  1540. "ori" '(org-roam-node-insert :which-key "Insert")
  1541. "orf" '(org-roam-node-find :which-key "Find")
  1542. "orc" '(org-roam-capture :which-key "Capture")
  1543. "org" '(org-id-get-create :which-key "Get/Create")
  1544. "orb" '(org-roam-buffer-toggle :which-key "Buffer"))
  1545. ;; Apply custom keybindings for dailies.
  1546. (dotfiles/leader
  1547. "ord" '(:ignore t :which-key "Dailies")
  1548. "ordd" '(org-roam-dailies-goto-date :which-key "Date")
  1549. "ordt" '(org-roam-dailies-goto-today :which-key "Today")
  1550. "ordm" '(org-roam-dailies-goto-tomorrow :which-key "Tomorrow")
  1551. "ordy" '(org-roam-dailies-goto-yesterday :which-key "Yesterday"))
  1552. ;; Run the setup command.
  1553. (org-roam-setup)
  1554. #+END_SRC
  1555. *** Org Roam UI
  1556. #+NAME: emacs-org-roam-ui-package
  1557. #+BEGIN_SRC nix
  1558. epkgs.org-roam-ui
  1559. epkgs.websocket
  1560. epkgs.simple-httpd
  1561. #+END_SRC
  1562. [[https://github.com/org-roam/org-roam-ui][Org Roam UI]] is a graphical frontend for exploring your [[https://github.com/org-roam/org-roam][Org Roam]] [[https://zettelkasten.de][Zettelkasten]]. It's meant as a successor to [[https://github.com/org-roam/org-roam-server][Org Roam Server]] that extends functionality of Org Roam with a web application that runs side-by-side with [[https://gnu.org/software/emacs/][Emacs]].
  1563. #+NAME: emacs-org-roam-ui-elisp
  1564. #+BEGIN_SRC emacs-lisp
  1565. ;; HACK: Set up `org-roam-ui'.
  1566. ;; (add-to-list 'load-path "~/.local/source/org-roam-ui")
  1567. (load-library "org-roam-ui")
  1568. ;; Configure `org-roam-ui'.
  1569. (setq org-roam-ui-follow t
  1570. org-roam-ui-sync-theme t
  1571. org-roam-ui-open-on-start t
  1572. org-roam-ui-update-on-save t
  1573. org-roam-ui-browser-function #'browse-url-firefox)
  1574. ;; Configure keybindings.
  1575. (dotfiles/leader
  1576. "oru" '(:ignore t :which-key "UI")
  1577. "oruu" '(org-roam-ui-mode :which-key "Toggle UI")
  1578. "orut" '(org-roam-ui-sync-theme :which-key "Sync Theme"))
  1579. #+END_SRC
  1580. *** Org Drill
  1581. #+NAME: emacs-org-drill-package
  1582. #+BEGIN_SRC nix
  1583. epkgs.org-drill
  1584. #+END_SRC
  1585. [[https://orgmode.org/worg/org-contrib/org-drill.html][Org Drill]] is an extension for [[https://orgmode.org][Org Mode]] that uses a spaced repition algorithm to conduct interactive /Drill Sessions/ using Org files as sources of facts to be memorized.
  1586. #+NAME: emacs-org-drill-elisp
  1587. #+BEGIN_SRC emacs-lisp
  1588. ;; Exclude :drill: items from `org-roam'.
  1589. (setq org-roam-db-node-include-function
  1590. (defun dotfiles/org-roam-include ()
  1591. (not (member "drill" (org-get-tags)))))
  1592. ;; Configure keybindings for `org-drill'.
  1593. (dotfiles/leader
  1594. "od" '(:ignore t :which-key "Drill")
  1595. "odd" '(org-drill :which-key "Drill")
  1596. "odc" '(org-drill-cram :which-key "Cram")
  1597. "odr" '(org-drill-resume :which-key "Resume"))
  1598. #+END_SRC
  1599. *** Org Agenda
  1600. The way [[https://orgmode.org][Org Mode]] works, TODO items, time-stamped items, and tagged headlines can be scattered throughout a file, or even a number of files. To get an overview of open action items, or of events that are important for a particular date, this information must be collected, sorted, and displayed in an organized way.
  1601. #+NAME: emacs-org-agenda-elisp
  1602. #+BEGIN_SRC emacs-lisp
  1603. ;; Configure `org-agenda' to use the project files.
  1604. (setq org-agenda-files '("/etc/dotfiles/"
  1605. "/etc/dotfiles/docs/"
  1606. "/etc/dotfiles/docs/daily/"))
  1607. ;; Include files encrypted with `gpg'.
  1608. (require 'org)
  1609. (unless (string-match-p "\\.gpg" org-agenda-file-regexp)
  1610. (setq org-agenda-file-regexp
  1611. (replace-regexp-in-string "\\\\\\.org" "\\\\.org\\\\(\\\\.gpg\\\\)?"
  1612. org-agenda-file-regexp)))
  1613. ;; Open an agenda buffer with SPC o a.
  1614. (dotfiles/leader
  1615. "oa" '(org-agenda :which-key "Agenda"))
  1616. #+END_SRC
  1617. *** Org Pomodoro
  1618. #+NAME: emacs-pomodoro-package
  1619. #+BEGIN_SRC nix
  1620. epkgs.org-pomodoro
  1621. #+END_SRC
  1622. [[https://github.com/marcinkoziej/org-pomodoro][Org Pomodoro]] adds basic support for the [[https://en.wikipedia.org/wiki/Pomodoro_Technique][Pomodoro Technique]] in [[https://gnu.org/software/emacs/][GNU/Emacs]]. It can be started for the task at point, or the last task time was clocked for. Each session starts a timer of 25 minutes, finishing with a break of 5 minutes. After 4 sessions, ther will be a break of 20 minutes. All values are customizable.
  1623. #+NAME: emacs-pomodoro-elisp
  1624. #+BEGIN_SRC emacs-lisp
  1625. ;; Configure `org-pomodor' with the overtime workflow.
  1626. (setq org-pomodoro-manual-break t
  1627. org-pomodoro-keep-killed-time t)
  1628. ;; Configure keybindings.
  1629. (dotfiles/leader
  1630. "op" '(org-pomodoro :which-key "Pomodoro"))
  1631. #+END_SRC
  1632. *** Writegood Mode
  1633. #+NAME: emacs-writegood-package
  1634. #+BEGIN_SRC nix
  1635. epkgs.writegood-mode
  1636. #+END_SRC
  1637. [[https://github.com/bnbeckwith/writegood-mode][Writegood Mode]] is an [[https://gnu.org/software/emacs/][Emacs]] minor mode to aid in finding common writing problems. It highlights the text based on the following criteria:
  1638. + Weasel Words
  1639. + Passive Voice
  1640. + Duplicate Words
  1641. #+NAME: emacs-writegood-elisp
  1642. #+BEGIN_SRC emacs-lisp
  1643. ;; Configure `writegood-mode'.
  1644. (dotfiles/leader
  1645. "tg" '(writegood-mode :which-key "Grammar"))
  1646. #+END_SRC
  1647. *** Aspell
  1648. #+NAME: emacs-aspell-extras
  1649. #+BEGIN_SRC nix
  1650. pkgs.aspell
  1651. pkgs.aspellDicts.en
  1652. pkgs.aspellDicts.en-science
  1653. pkgs.aspellDicts.en-computers
  1654. #+END_SRC
  1655. [[https://aspell.net][GNU Aspell]] is a Free and Open Source spell checker designed to replace ISpell. It can be used as a library, or an independent spell checker. Its main feature is that it does a superior job of suggesting possible replacements for mis-spelled words than any other spell checker for the English language.
  1656. #+NAME: emacs-aspell-elisp
  1657. #+BEGIN_SRC emacs-lisp
  1658. ;; Use `aspell' as a drop-in replacement for `ispell'.
  1659. (setq ispell-program-name "aspell"
  1660. ispell-eextra-args '("--sug-mode=fast"))
  1661. ;; Configure the built-in `flyspell-mode'.
  1662. (dotfiles/leader
  1663. "ts" '(flyspell-mode :which-key "Spelling"))
  1664. #+END_SRC
  1665. *** TexLive
  1666. [[https://wikipedia.org/wiki/Tex_Live][TeX Live]] is a free software distributution for the TeX typesetting system that includes major TeX-related programs, macro packages, and fonts. Since TeX Live consists of /thousands/ of packages, to make managing it easier, NixOS replicates the organization of Tex Live into /schemes/ and /collections/:
  1667. | Name | Derivation | Comment |
  1668. |---------+---------------------------------+------------------------------------------------------------|
  1669. | Full | texlive.combined.scheme-full | Contains every TeX Live package |
  1670. | Medium | texlive.combined.scheme-medium | Contains everything in small + more packages and languages |
  1671. | Small | texlive.combined.scheme-small | Contains everything in basic + xetex + metapost |
  1672. | Basic | texlive.combined.scheme-basic | Contains everything in the plain scheme but includes latex |
  1673. | Minimal | texlive.combined.scheme-minimal | Contains plain only |
  1674. #+NAME: emacs-texlive-extras
  1675. #+BEGIN_SRC nix
  1676. # pkgs.texlive.combined.scheme-full
  1677. #+END_SRC
  1678. *** Http
  1679. #+NAME: emacs-http-package
  1680. #+BEGIN_SRC nix
  1681. epkgs.ob-http
  1682. #+END_SRC
  1683. It's possible to make HTTP requests from Org Mode buffers using [[https://github.com/zweifisch/ob-http][ob-http]], this relies on Org Babel (included with [[https://orgmode.org][Org Mode]]) being present and configured properly.
  1684. #+NAME: emacs-http-elisp
  1685. #+BEGIN_SRC emacs-lisp
  1686. ;; Required to setup `ob-http'.
  1687. (org-babel-do-load-languages
  1688. 'org-babel-load-languages
  1689. '((http . t)))
  1690. #+END_SRC
  1691. *** Hugo
  1692. #+NAME: emacs-hugo-package
  1693. #+BEGIN_SRC nix
  1694. epkgs.ox-hugo
  1695. #+END_SRC
  1696. [[https://oxhugo.scripter.co][Ox Hugo]] is an [[https://orgmode.org][Org Mode]] exporter for [[https://gohugo.io][Hugo]] compabile markdown. My dotfiles are a result of this, and are available to view here https://chrishayward.xyz/dotfiles/.
  1697. #+NAME: emacs-hugo-elisp
  1698. #+BEGIN_SRC emacs-lisp
  1699. ;; Configure `ox-hugo' as an `org-mode-export' backend.
  1700. (require 'ox-hugo)
  1701. ;; Set up the base directory.
  1702. (setq org-hugo-base-dir (expand-file-name "/etc/dotfiles/docs"))
  1703. ;; Capture templates.
  1704. ;; Shared content
  1705. ;; (add-to-list 'org-roam-capture-templates
  1706. ;; '("p" "Post" plain "%?"
  1707. ;; :target (file+head "docs/posts/${slug}.org.gpg"
  1708. ;; "
  1709. ;; ,#+TITLE: ${title}
  1710. ;; ,#+AUTHOR: Christopher James Hayward
  1711. ;; ,#+DATE: %<%Y-%m-%d>
  1712. ;; ,#+EXPORT_FILE_NAME: ${slug}
  1713. ;; ,#+OPTIONS: num:nil todo:nil tasks:nil
  1714. ;; ,#+ROAM_KEY: https://chrishayward.xyz/posts/${slug}/
  1715. ;; ,#+HUGO_BASE_DIR: ../
  1716. ;; ,#+HUGO_AUTO_SET_LASTMOD: t
  1717. ;; ,#+HUGO_SECTION: posts
  1718. ;; ,#+HUGO_DRAFT: true
  1719. ;; "
  1720. ;; )
  1721. ;; :unnarrowed t))
  1722. #+END_SRC
  1723. *** Passwords
  1724. #+NAME: emacs-pass-extras
  1725. #+BEGIN_SRC nix
  1726. pkgs.pass
  1727. #+END_SRC
  1728. With [[https://password-store.org][Pass]], each password lives inside of an encrypted [[https://gnupg.org][GPG]] file, whose name is the title of the website or resource that requires the password. These encrypted files may be organized into meaningful folder hierarchies, compies from computer to computer, and in general, manipulated using standard command line tools.
  1729. #+NAME: emacs-pass-package
  1730. #+BEGIN_SRC nix
  1731. epkgs.password-store
  1732. #+END_SRC
  1733. Configure keybindings for passwords behind =SPC p=:
  1734. #+NAME: emacs-pass-elisp
  1735. #+BEGIN_SRC emacs-lisp
  1736. ;; Set the path to the password store.
  1737. (setq password-store-dir (expand-file-name "~/.password-store"))
  1738. ;; Apply custom keybindings.
  1739. (dotfiles/leader
  1740. "p" '(:ignore t :which-key "Passwords")
  1741. "pp" '(password-store-copy :which-key "Copy")
  1742. "pe" '(password-store-edit :which-key "Edit")
  1743. "pi" '(password-store-insert :which-key "Insert")
  1744. "pr" '(password-store-rename :which-key "Rename")
  1745. "pg" '(password-store-generate :which-key "Generate"))
  1746. #+END_SRC
  1747. *** Docker
  1748. #+NAME: emacs-docker-package
  1749. #+BEGIN_SRC nix
  1750. epkgs.docker
  1751. epkgs.dockerfile-mode
  1752. #+END_SRC
  1753. Manage Docker from inside of Emacs using [[https://github.com/Silex/docker.el][Docker.el]]. This is a full docker porcelain similar to Magit, allowing complete control of a Docker system. Add syntax highlighting to Dockerfiles using [[https://github.com/spotify/dockerfile-mode][dockerfile-mode]] from Spotify.
  1754. #+NAME: emacs-docker-elisp
  1755. #+BEGIN_SRC emacs-lisp
  1756. ;; Apply custom keybindings.
  1757. (dotfiles/leader
  1758. "n" '(:ignore t :which-key "Containers")
  1759. "nd" '(docker :which-key "Docker"))
  1760. #+END_SRC
  1761. *** MU4E
  1762. #+NAME: emacs-mu4e-extras
  1763. #+BEGIN_SRC nix
  1764. pkgs.mu
  1765. pkgs.isync
  1766. (pkgs.writeShellScriptBin "mail-init" ''
  1767. ${pkgs.mu} init --maildir="~/.cache/mail" --my-address="chris@chrishayward.xyz"
  1768. ${pkgs.mu} index
  1769. '')
  1770. (pkgs.writeShellScriptBin "mail-sync" ''
  1771. ${pkgs.isync}/bin/mbsync -a
  1772. '')
  1773. #+END_SRC
  1774. [[https://github.com/djcb/mu][MU]] is a tool for dealing with email messages stored in the Maildir-format. Its purpose is to help quickly find the messages needed, and allows users to view messages, extract attachments, create new maildirs, and much more. It's written in C and C++, and includes extensions for Emacs (MU4E) and guile scheme.
  1775. #+NAME: emacs-mu4e-package
  1776. #+BEGIN_SRC nix
  1777. epkgs.mu4e-alert
  1778. #+END_SRC
  1779. [[https://emacswiki.org/emacs/mu4e][MU4E]] is an email client for Emacs. It's based on the mu email indexer / searcher.
  1780. + Fully search based: no folders, only queries
  1781. + Fully documented, with example configurations
  1782. + User-interface optimized for speed, with quick keystrokes for common actions
  1783. + Asynchronous; heavy actions do not block Emacs
  1784. + Support for non-English languages
  1785. + Support for signing and encryption
  1786. + Address auto-completion based on existing messages
  1787. + Extensibile with existing code and snippets
  1788. #+NAME: emacs-mu4e-config
  1789. #+BEGIN_SRC nix
  1790. # Deploy the authinfo file.
  1791. home.file.".authinfo.gpg".source = ../config/authinfo.gpg;
  1792. # Deploy the isync configuration file.
  1793. home.file.".mbsyncrc" = {
  1794. text = ''
  1795. IMAPStore xyz-remote
  1796. Host mail.chrishayward.xyz
  1797. User chris@chrishayward.xyz
  1798. PassCmd "pass chrishayward.xyz/chris"
  1799. SSLType IMAPS
  1800. MaildirStore xyz-local
  1801. Path ~/.cache/mail/
  1802. Inbox ~/.cache/mail/inbox
  1803. SubFolders Verbatim
  1804. Channel xyz
  1805. Far :xyz-remote:
  1806. Near :xyz-local:
  1807. Patterns * !Archives
  1808. Create Both
  1809. Expunge Both
  1810. SyncState *
  1811. '';
  1812. };
  1813. #+END_SRC
  1814. Before using the software inside of Emacs, the maildir must be created in the local filesystem, and indexed. This is done with a single custom shell script binary ~mail-init~ which wraps the underlying mu commands. The emacs extension is shipped with the mu mail indexer. To utilize it, it must be added to the load path inside of Emacs.
  1815. #+NAME: emacs-mu4e-elisp
  1816. #+BEGIN_SRC emacs-lisp
  1817. ;; Add the `mu4e' shipped with `mu' to the load path.
  1818. (add-to-list 'load-path "/etc/profiles/per-user/chris/share/emacs/site-lisp/mu4e/")
  1819. (require 'mu4e)
  1820. ;; Confiugure `mu4e'.
  1821. (setq mu4e-maildir "~/.cache/mail"
  1822. mu4e-update-interval (* 5 60)
  1823. mu4e-get-mail-command "mail-sync"
  1824. mu4e-compose-format-flowed t
  1825. mu4e-change-filenames-when-moving t
  1826. mu4e-compose-signature (concat "Chris Hayward\n"
  1827. "chris@chrishayward.xyz"))
  1828. ;; Sign all outbound email with GPG.
  1829. (add-hook 'message-send-hook 'mml-secure-message-sign-pgpmime)
  1830. (setq message-send-mail-function 'smtpmail-send-it
  1831. mml-secure-openpgp-signers '("37AB1CB72B741E478CA026D43025DCBD46F81C0F"))
  1832. ;; Setup `mu4e' accounts.
  1833. (setq mu4e-contexts
  1834. (list
  1835. ;; Main
  1836. ;; chris@chrishayward.xyz
  1837. (make-mu4e-context
  1838. :name "Main"
  1839. :match-func
  1840. (lambda (msg)
  1841. (when msg
  1842. (string-prefix-p "/Main" (mu4e-message-field msg :maildir))))
  1843. :vars
  1844. '((user-full-name . "Christopher James Hayward")
  1845. (user-mail-address . "chris@chrishayward.xyz")
  1846. (smtpmail-smtp-server . "mail.chrishayward.xyz")
  1847. (smtpmail-smtp-service . 587)
  1848. (smtpmail-stream-type . starttls)))))
  1849. ;; Setup `mu4e-alert'.
  1850. (setq mu4e-alert-set-default-style 'libnotify)
  1851. (mu4e-alert-enable-notifications)
  1852. (mu4e-alert-enable-mode-line-display)
  1853. ;; Open the `mu4e' dashboard.
  1854. (dotfiles/leader
  1855. "m" '(mu4e :which-key "Mail"))
  1856. #+END_SRC
  1857. *** Projectile
  1858. #+NAME: emacs-projectile-package
  1859. #+BEGIN_SRC nix
  1860. epkgs.projectile
  1861. #+END_SRC
  1862. [[https://projectile.mx][Projectile]] is a project interaction library for [[https://gnu.org/software/emacs/][GNU/Emacs]]. Its goal is to provide a nice set of features operating on a project level, without introducing external dependencies.
  1863. #+NAME: emacs-projectile-elisp
  1864. #+BEGIN_SRC emacs-lisp
  1865. ;; Configure the `projectile-project-search-path'.
  1866. (setq projectile-project-search-path '("~/.local/source"))
  1867. (projectile-mode +1)
  1868. #+END_SRC
  1869. *** LSP Mode
  1870. #+NAME: emacs-lsp-package
  1871. #+BEGIN_SRC nix
  1872. epkgs.lsp-mode
  1873. epkgs.lsp-ui
  1874. #+END_SRC
  1875. The [[https://microsoft.github.io/language-server-protocol][Language Server Protocol (LSP)]] defines the protocol used between an Editor or IDE, and a language server that provides features like:
  1876. + Auto Complete
  1877. + Go To Defintion
  1878. + Find All References
  1879. #+NAME: emacs-lsp-elisp
  1880. #+BEGIN_SRC emacs-lisp
  1881. ;; Configure `lsp-mode'.
  1882. (setq lsp-idle-delay 0.5
  1883. lsp-prefer-flymake t)
  1884. ;; Configure `lsp-ui'.
  1885. (setq lsp-ui-doc-position 'at-point
  1886. lsp-ui-doc-delay 0.5)
  1887. ;; Add custom keybindings for `lsp'.
  1888. (dotfiles/leader
  1889. "l" '(:ignore t :which-key "LSP")
  1890. "ll" '(lsp :which-key "LSP"))
  1891. #+END_SRC
  1892. *** CCLS
  1893. #+NAME: emacs-ccls-package
  1894. #+BEGIN_SRC nix
  1895. epkgs.ccls
  1896. #+END_SRC
  1897. [[https://github.com/MaskRay/emacs-ccls][Emacs CCLS]] is a client for CCLS, a C/C++/Objective-C language server supporting multi-million line C++ code bases, powered by libclang.
  1898. #+NAME: emacs-ccls-elisp
  1899. #+BEGIN_SRC emacs-lisp
  1900. ;; Configure `ccls' to work with `lsp-mode'.
  1901. (defun dotfiles/ccls-hook ()
  1902. (require 'ccls)
  1903. (lsp))
  1904. ;; Configure `ccls' mode hooks.
  1905. (add-hook 'c-mode-hook 'dotfiles/ccls-hook)
  1906. (add-hook 'c++-mode-hook 'dotfiles/ccls-hook)
  1907. (add-hook 'objc-mode-hook 'dotfiles/ccls-hook)
  1908. (add-hook 'cuda-mode-hook 'dotfiles/ccls-hook)
  1909. #+END_SRC
  1910. *** Company Mode
  1911. #+NAME: emacs-company-package
  1912. #+BEGIN_SRC nix
  1913. epkgs.company
  1914. #+END_SRC
  1915. [[https://company-mode.github.io][Company Mode]] is a text completion framework for [[https://gnu.org/software/emacs/][GNU/Emacs]]. The name stands for =Complete Anything=. It uses pluggable back-ends and front-ends to retieve and display completion candidates.
  1916. #+NAME: emacs-company-elisp
  1917. #+BEGIN_SRC emacs-lisp
  1918. ;; Configure `company-mode'.
  1919. (setq company-backend 'company-capf
  1920. lsp-completion-provider :capf)
  1921. ;; Enable it globally.
  1922. (global-company-mode +1)
  1923. #+END_SRC
  1924. *** GDScript Mode
  1925. #+NAME: emacs-gdscript-package
  1926. #+BEGIN_SRC nix
  1927. epkgs.gdscript-mode
  1928. #+END_SRC
  1929. https://github.com/godotengine/emacs-gdscript-mode is an Emacs package to get GDScript support and syntax highlighting. Some of its features include:
  1930. + Syntax highlighting
  1931. + Code folding
  1932. + Debugger support
  1933. + Support for scenes and script files
  1934. + Comment wrapping
  1935. + Indentation
  1936. + Automatic parsing
  1937. + Code formatting
  1938. #+NAME: emacs-gdscript-elisp
  1939. #+BEGIN_SRC emacs-lisp
  1940. (require 'gdscript-mode)
  1941. ;; Silence lsp warnings for gdscript.
  1942. (defun lsp--gdscript-ignore-errors (original-function &rest args)
  1943. "Ignore the error message resulting from Godot not replying to the `JSONRPC' request."
  1944. (if (string-equal major-mode "gdscript-mode")
  1945. (let ((json-data (nth 0 args)))
  1946. (if (and (string= (gethash "jsonrpc" json-data "") "2.0")
  1947. (not (gethash "id" json-data nil))
  1948. (not (gethash "method" json-data nil)))
  1949. nil; (message "Method not found")
  1950. (apply original-function args)))
  1951. (apply original-function args)))
  1952. ;; Run the function around `lsp--get-message-type' to suppress warnings.
  1953. (advice-add #'lsp--get-message-type :around #'lsp--gdscript-ignore-errors)
  1954. ;; Add custom keybinds.
  1955. (dotfiles/leader
  1956. "lg" '(gdscript-hydra-show :which-key "GDScript"))
  1957. #+END_SRC
  1958. *** Go Mode
  1959. #+NAME: emacs-golang-package
  1960. #+BEGIN_SRC nix
  1961. epkgs.go-mode
  1962. #+END_SRC
  1963. [[https://emacswiki.org/emacs/GoMode][Go Mode]] is an [[https://gnu.org/software/emacs/][Emacs]] major mode for editing [[https://golang.org][Golang]] source code.
  1964. #+NAME: emacs-golang-elisp
  1965. #+BEGIN_SRC emacs-lisp
  1966. ;; Configure `go-mode' to work with `lsp-mode'.
  1967. (defun dotfiles/go-hook ()
  1968. (add-hook 'before-save-hook #'lsp-format-buffer t t)
  1969. (add-hook 'before-save-hook #'lsp-organize-imports t t))
  1970. ;; Configure a custom `before-save-hook'.
  1971. (add-hook 'go-mode-hook #'dotfiles/go-hook)
  1972. #+END_SRC
  1973. *** Rustic
  1974. #+NAME: emacs-rustic-package
  1975. #+BEGIN_SRC nix
  1976. epkgs.rustic
  1977. #+END_SRC
  1978. Rustic is a fork of Rust Mode that integrates well with the [[https://microsoft.github.io/language-server-protocol][Language Server Protocol (LSP)]]. Include the rust shell before launching [[https://gnu.org/software/emacs/][GNU/Emacs]] to use this!
  1979. #+NAME: emacs-rustic-elisp
  1980. #+BEGIN_SRC emacs-lisp
  1981. ;; Configure `rustic' with `lsp-mode'.
  1982. (setq rustic-format-on-save t
  1983. rustic-lsp-server 'rls)
  1984. #+END_SRC
  1985. *** Python Mode
  1986. #+NAME: emacs-python-package
  1987. #+BEGIN_SRC nix
  1988. epkgs.pretty-mode
  1989. #+END_SRC
  1990. The built in [[https://emacswiki.org/emacs/PythonProgrammingInEmacs][Python Mode]] has a nice feature set for working with [[https://python.org][Python]] code in [[https://gnu.org/software/emacs/][GNU/Emacs]]. It is complimented with the addition of a [[https://microsoft.github.io/language-server-protocol][Language Server Protocol (LSP)]] server. These tools are included in the Development Shell for Python.
  1991. #+NAME: emacs-python-elisp
  1992. #+BEGIN_SRC emacs-lisp
  1993. ;; Configure `pretty-mode' to work with `python-mode'.
  1994. (add-hook 'python-mode-hook
  1995. (lambda ()
  1996. (turn-on-pretty-mode)))
  1997. #+END_SRC
  1998. *** Protobuf Mode
  1999. #+NAME: emacs-protobuf-package
  2000. #+BEGIN_SRC nix
  2001. epkgs.protobuf-mode
  2002. #+END_SRC
  2003. *** Typescript Mode
  2004. #+NAME: emacs-typescript-package
  2005. #+BEGIN_SRC nix
  2006. epkgs.typescript-mode
  2007. #+END_SRC
  2008. *** PlantUML
  2009. #+NAME: emacs-plantuml-extras
  2010. #+BEGIN_SRC nix
  2011. pkgs.plantuml
  2012. #+END_SRC
  2013. [[https://plantuml.com][PlantUML]] is an open-source tool allowing users to create diagrams from a plain-text language. Besides various UML diagrams, PlantUML has support for various other software developmented related formats, as well as visualizations of =JSON= and =YAML= files.
  2014. #+NAME: emacs-plantuml-package
  2015. #+BEGIN_SRC nix
  2016. epkgs.plantuml-mode
  2017. #+END_SRC
  2018. [[https://github.com/skuro/plantuml-mode][PlantUML Mode]] is a major mode for editing [[https://plantuml.com][PlantUML]] sources in [[https://gnu.org/software/emacs/][GNU/Emacs]].
  2019. #+NAME: emacs-plantuml-elisp
  2020. #+BEGIN_SRC emacs-lisp
  2021. ;; Configure `plantuml-mode'.
  2022. (add-to-list 'org-src-lang-modes '("plantuml" . plantuml))
  2023. (org-babel-do-load-languages 'org-babel-load-languages '((plantuml . t)))
  2024. (setq plantuml-default-exec-mode 'executable
  2025. org-plantuml-exec-mode 'plantuml)
  2026. #+END_SRC
  2027. *** Swiper
  2028. #+NAME: emacs-swiper-package
  2029. #+BEGIN_SRC nix
  2030. epkgs.ivy
  2031. epkgs.counsel
  2032. epkgs.ivy-rich
  2033. epkgs.ivy-posframe
  2034. epkgs.ivy-prescient
  2035. #+END_SRC
  2036. [[https://github.com/abo-abo/swiper][Ivy (Swiper)]] is a generic completion mechanism for [[https://gnu.org/software/emacs/][GNU/Emacs]]. While operating similarily to other completion schemes like =icomplete-mode=, it aims to be more efficient, smaller, simpler, and smoother to use, while remaining highly customizable.
  2037. #+NAME: emacs-swiper-elisp
  2038. #+BEGIN_SRC emacs-lisp
  2039. ;; Configure `ivy'.
  2040. (setq counsel-linux-app-format-function
  2041. #'counsel-linux-app-format-function-name-only)
  2042. (ivy-mode +1)
  2043. (counsel-mode +1)
  2044. ;; Configure `ivy-rich'.
  2045. (ivy-rich-mode +1)
  2046. ;; Configure `ivy-posframe'.
  2047. (setq ivy-posframe-parameters '((parent-frame nil))
  2048. ivy-posframe-display-functions-alist '((t . ivy-posframe-display)))
  2049. (ivy-posframe-mode +1)
  2050. ;; Configure `ivy-prescient'.
  2051. (setq ivy-prescient-enable-filtering nil)
  2052. (ivy-prescient-mode +1)
  2053. #+END_SRC
  2054. *** Transparency
  2055. It's possible to control the frame opacity in [[https://gnu.org/software/emacs/][GNU/Emacs]]. Unlike other transparency hacks, it's not merely showing the desktop background image, but is true transparency -- you can see other windows behind the Emacs window.
  2056. #+NAME: emacs-transparency-elisp
  2057. #+BEGIN_SRC emacs-lisp
  2058. ;; Configure the default frame transparency.
  2059. (set-frame-parameter (selected-frame) 'alpha '(95 . 95))
  2060. (add-to-list 'default-frame-alist '(alpha . (95 . 95)))
  2061. #+END_SRC
  2062. *** Desktop Environment
  2063. #+NAME: emacs-desktop-extras
  2064. #+BEGIN_SRC nix
  2065. pkgs.brightnessctl
  2066. #+END_SRC
  2067. The [[https://github.com/DamienCassou/desktop-environment][Desktop Environment]] package provides commands and a global minor mode for controlling your [[https://linux.org][GNU/Linux]] desktop from within [[https://gnu.org/software/emacs/][GNU/Emacs]].
  2068. #+NAME: emacs-desktop-package
  2069. #+BEGIN_SRC nix
  2070. epkgs.desktop-environment
  2071. #+END_SRC
  2072. You can control the brightness, volume, take screenshots, and lock / unlock the screen. The package depends on the availability of shell commands to do the heavy lifting. They can be changed by customizing the appropriate variables.
  2073. #+NAME: emacs-desktop-elisp
  2074. #+BEGIN_SRC emacs-lisp
  2075. ;; Configure `desktop-environment'.
  2076. (require 'desktop-environment)
  2077. (desktop-environment-mode +1)
  2078. #+END_SRC
  2079. *** Doom Themes
  2080. #+NAME: emacs-doom-themes-package
  2081. #+BEGIN_SRC nix
  2082. epkgs.doom-themes
  2083. #+END_SRC
  2084. [[https://github.com/hlissner/emacs-doom-themes][Doom Themes]] is a theme megapack for [[https://gnu.org/software/emacs/][GNU/Emacs]], inspired by community favourites.
  2085. #+NAME: emacs-doom-themes-elisp
  2086. #+BEGIN_SRC emacs-lisp
  2087. ;; Include modern themes from `doom-themes'.
  2088. (setq doom-themes-enable-bold t
  2089. doom-themes-enable-italic t)
  2090. ;; Load the `doom-nord' and `doom-nord-light' themes.
  2091. ;; (load-theme 'doom-nord-light t)
  2092. (load-theme 'doom-nord t)
  2093. ;; Define a method for returning information about the current theme.
  2094. ;; This is based off the function `org-roam-ui-get-theme'.
  2095. (defun dotfiles/theme ()
  2096. "Return information about the current theme."
  2097. (list `(bg . ,(face-background hl-line-face))
  2098. `(bg-alt . ,(face-background 'default))
  2099. `(fg . ,(face-foreground 'default))
  2100. `(fg-alt . ,(face-foreground font-lock-comment-face))
  2101. `(red . ,(face-foreground 'error))
  2102. `(orange . ,(face-foreground 'warning))
  2103. `(yellow . ,(face-foreground font-lock-builtin-face))
  2104. `(green . ,(face-foreground 'success))
  2105. `(cyan . ,(face-foreground font-lock-constant-face))
  2106. `(blue . ,(face-foreground font-lock-keyword-face))
  2107. `(violet . ,(face-foreground font-lock-constant-face))
  2108. `(magenta . ,(face-foreground font-lock-preprocessor-face))))
  2109. ;; Load a new theme with <SPC> t t.
  2110. (dotfiles/leader
  2111. "tt" '(counsel-load-theme :which-key "Theme"))
  2112. #+END_SRC
  2113. Create a shell command that returns a JSON string of the current theme in the following format:
  2114. #+BEGIN_SRC json
  2115. {
  2116. "bg": "#272C36",
  2117. "bg-alt": "#2E3440",
  2118. "fg": "#ECEFF4",
  2119. "fg-alt": "#6f7787",
  2120. "red": "#BF616A",
  2121. "orange": "#EBCB8B",
  2122. "yellow": "#81A1C1",
  2123. "green": "#A3BE8C",
  2124. "cyan": "#81A1C1",
  2125. "blue": "#81A1C1",
  2126. "violet": "#81A1C1",
  2127. "magenta": "#81A1C1"
  2128. }
  2129. #+END_SRC
  2130. #+NAME: emacs-doom-themes-extras
  2131. #+BEGIN_SRC nix
  2132. (pkgs.writeShellScriptBin "dotfiles-theme" ''
  2133. ${myEmacs}/bin/emacsclient --no-wait --eval '(json-encode (dotfiles/theme))' | sed "s/\\\\//g" | sed -e 's/^"//' -e 's/"$//'
  2134. '')
  2135. #+END_SRC
  2136. *** Doom Modeline
  2137. #+NAME: emacs-doom-modeline-package
  2138. #+BEGIN_SRC nix
  2139. epkgs.doom-modeline
  2140. #+END_SRC
  2141. [[https://github.com/seagle0128/doom-modeline][Doom Modeline]] is a fancy and fast modeline inspired by minimalism design. It's integrated into Centaur Emacs, Doom Emacs, and Spacemacs.
  2142. #+NAME: emacs-doom-modeline-elisp
  2143. #+BEGIN_SRC emacs-lisp
  2144. ;; Configure `doom-modeline'.
  2145. (require 'doom-modeline)
  2146. (setq doom-modeline-height 16
  2147. doom-modeline-icon t)
  2148. ;; Launch after initialization.
  2149. (add-hook 'after-init-hook 'doom-modeline-mode)
  2150. ;; Define a modeline segment to show the workspace information.
  2151. (doom-modeline-def-segment dotfiles/workspaces
  2152. (exwm-workspace--update-switch-history)
  2153. (concat
  2154. (doom-modeline-spc)
  2155. (elt (let* ((num (exwm-workspace--count))
  2156. (sequence (number-sequence 0 (1- num)))
  2157. (not-empty (make-vector num nil)))
  2158. (dolist (i exwm--id-buffer-alist)
  2159. (with-current-buffer (cdr i)
  2160. (when exwm--frame
  2161. (setf (aref not-empty
  2162. (exwm-workspace--position exwm--frame))
  2163. t))))
  2164. (mapcar
  2165. (lambda (i)
  2166. (mapconcat
  2167. (lambda (j)
  2168. (format (if (= i j) "[%s]" " %s ")
  2169. (propertize
  2170. (apply exwm-workspace-index-map (list j))
  2171. 'face
  2172. (cond ((frame-parameter (elt exwm-workspace--list j)
  2173. 'exwm-urgency)
  2174. '(:inherit warning :weight bold))
  2175. ((= i j) '(:inherit underline :weight bold))
  2176. ((aref not-empty j) '(:inherit success :weight bold))
  2177. (t `((:foreground ,(face-foreground 'mode-line-inactive))))))))
  2178. sequence ""))
  2179. sequence))
  2180. (exwm-workspace--position (selected-frame)))))
  2181. ;; Define a custom modeline to override the default.
  2182. (doom-modeline-def-modeline 'dotfiles/modeline
  2183. '(bar workspace-name dotfiles/workspaces window-number modals matches buffer-info remote-host buffer-position word-count parrot selection-info)
  2184. '(objed-state misc-info persp-name battery grip irc mu4e gnus github debug repl lsp minor-modes input-method indent-info buffer-encoding major-mode process vcs checker))
  2185. ;; Define a method to load the modeline.
  2186. (defun dotfiles/load-modeline ()
  2187. "Load the default modeline."
  2188. (doom-modeline-set-modeline 'dotfiles/modeline 'default))
  2189. ;; Enable `doom-modeline'.
  2190. (add-hook 'doom-modeline-mode-hook 'dotfiles/load-modeline)
  2191. (doom-modeline-mode +1)
  2192. (doom-modeline-set-modeline 'dotfiles/modeline 'default)
  2193. #+END_SRC
  2194. ** Website Configuration
  2195. #+ATTR_ORG: :width 800px
  2196. #+ATTR_HTML: :width 800px
  2197. #+ATTR_LATEX: :width 800px
  2198. [[./docs/images/website.png]]
  2199. My [[https://chrishayward.xyz][personal website]] is a static HTML page written with [[https://gohugo.io][Hugo]], and is fully integrated into this configuration. It uses the ~config.toml~, ~config.yaml~, or ~config.json~ file (found in the sites root directory) as the default site config. Working with this requires the module to be enabled.
  2200. #+BEGIN_SRC conf :noweb yes :tangle docs/config.toml
  2201. # <<file-warning>>
  2202. title = "Chris Hayward"
  2203. copyright = "Licensed under Attribution 4.0 International (CC BY 4.0)"
  2204. baseURL = "https://chrishayward.xyz/"
  2205. theme = "hello-friend-ng"
  2206. languageCode = "en-us"
  2207. defaultContentLanguage = "en"
  2208. pygmentsCodefences = true
  2209. pygmentsUseClasses = false
  2210. pygmentsStyle = "dracula"
  2211. <<website-params>>
  2212. <<website-privacy>>
  2213. <<website-layout>>
  2214. #+END_SRC
  2215. *** Params
  2216. Dates are important in [[https://gohugo.io][Hugo]], and they configure how dates are assigned and displayed in your content pages. Themes are also able to extract information from the configuration to display, including social media icons, subtitles, and footer sections.
  2217. #+NAME: website-params
  2218. #+BEGIN_SRC conf
  2219. [params]
  2220. dateform = "Jan 2, 2006"
  2221. dateformShort = "Jan 2"
  2222. dateformNum = "2006-01-02"
  2223. dateformNumTime = "2006-01-02 15:04 -0700"
  2224. authorName = "Christopher James Hayward"
  2225. homeSubtitle = "Airplanes, Linux, and Metalcore"
  2226. footerCopyright = ' &#183; <a href="http://creativecommons.org/licenses/by/4.0/" target="_blank" rel="noopener">CC BY 4.0</a>'
  2227. enableThemeToggle = true
  2228. [[params.social]]
  2229. name = "paypal"
  2230. url = "https://paypal.me/chrishaywardxyz"
  2231. [[params.social]]
  2232. name = "github"
  2233. url = "https://github.com/chayward1/"
  2234. [[params.social]]
  2235. name = "gitlab"
  2236. url = "https://gitlab.com/chayward1/"
  2237. [[params.social]]
  2238. name = "email"
  2239. url = "mailto:chris@chrishayward.xyz"
  2240. #+END_SRC
  2241. *** Privacy
  2242. I do not use any analytics or tracking in my website. Depending on the theme selected, some of these features may be enabled. I opt to override those settings here to make sure no unwanted trackers are loaded.
  2243. #+NAME: website-privacy
  2244. #+BEGIN_SRC conf
  2245. [privacy]
  2246. [privacy.disqus]
  2247. disable = true
  2248. [privacy.googleAnalytics]
  2249. disable = true
  2250. [privacy.instagram]
  2251. disable = true
  2252. [privacy.twitter]
  2253. disable = true
  2254. [privacy.vimeo]
  2255. disable = true
  2256. [privacy.youtube]
  2257. disable = true
  2258. #+END_SRC
  2259. *** Layout
  2260. Individual pages can be configured here to define the layout of the page. This is where quick links can be configured, and other sections such as blog posts, an about section, or a contact page can be added.
  2261. #+NAME: website-layout
  2262. #+BEGIN_SRC conf
  2263. [menu]
  2264. [[menu.main]]
  2265. identifier = "cloud"
  2266. name = "Cloud"
  2267. url = "https://cloud.chrishayward.xyz"
  2268. [[menu.main]]
  2269. identifier = "dotfiles"
  2270. name = "Dotfiles"
  2271. url = "/dotfiles"
  2272. [[menu.main]]
  2273. identifier = "projects"
  2274. name = "Projects"
  2275. url = "https://git.chrishayward.xyz"
  2276. #+END_SRC
  2277. * Footnotes