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.

2840 lines
93 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
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
  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. [[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.
  78. #+BEGIN_SRC nix :noweb yes :tangle flake.nix
  79. # <<file-warning>>
  80. {
  81. description = "<<description>>";
  82. inputs = {
  83. <<os-nixpkgs>>
  84. <<os-home-manager>>
  85. <<os-emacs-overlay>>
  86. <<os-nixos-hardware>>
  87. };
  88. outputs = inputs @ { self, nixpkgs, nixpkgs-unstable, ... }: {
  89. nixosConfigurations = {
  90. <<host-default>>
  91. };
  92. };
  93. }
  94. #+END_SRC
  95. ** Nixpkgs
  96. [[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:
  97. 1) The current stable release
  98. 2) The Unstable branch following the latest development
  99. #+NAME: os-nixpkgs
  100. #+BEGIN_SRC nix
  101. nixpkgs.url = "nixpkgs/nixos-unstable";
  102. nixpkgs-unstable.url = "nixpkgs/master";
  103. #+END_SRC
  104. ** Home Manager
  105. [[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.
  106. #+NAME: os-home-manager
  107. #+BEGIN_SRC nix
  108. home-manager.url = "github:nix-community/home-manager";
  109. home-manager.inputs.nixpkgs.follows = "nixpkgs";
  110. #+END_SRC
  111. ** Emacs Overlay
  112. 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.
  113. #+NAME: os-emacs-overlay
  114. #+BEGIN_SRC nix
  115. emacs-overlay.url = "github:nix-community/emacs-overlay";
  116. #+END_SRC
  117. ** NixOS Hardware
  118. [[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.
  119. #+NAME: os-nixos-hardware
  120. #+BEGIN_SRC nix
  121. nixos-hardware.url = "github:nixos/nixos-hardware";
  122. #+END_SRC
  123. * Development Shells
  124. 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.
  125. Import this shell with ~nix-shell /etc/dotfiles/shell.nix~.
  126. #+BEGIN_SRC nix :noweb yes :tangle shell.nix
  127. # <<file-warning>>
  128. { pkgs ? import <nixpkgs> { } }:
  129. with pkgs;
  130. let
  131. nixBin = writeShellScriptBin "nix" ''
  132. exec ${nixFlakes}/bin/nix --option experimental-features "nix-command flakes" "$@"
  133. '';
  134. in mkShell {
  135. buildInputs = [
  136. git
  137. ];
  138. shellHook = ''
  139. export FLAKE="$(pwd)"
  140. export PATH="$FLAKE/bin:${nixBin}/bin:$PATH"
  141. '';
  142. }
  143. #+END_SRC
  144. ** Go
  145. [[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.
  146. Import this shell with ~nix-shell /etc/dotfiles/shells/go.nix~
  147. #+BEGIN_SRC nix :noweb yes :tangle shells/go.nix
  148. # <<file-warning>>
  149. { pkgs ? import <nixpkgs> { } }:
  150. with pkgs;
  151. mkShell {
  152. buildInputs = [
  153. go
  154. gopls
  155. protoc-gen-go
  156. protoc-gen-go-grpc
  157. ];
  158. shellHook = ''
  159. export GO111MODULE=on
  160. export GOPATH=$XDG_DATA_HOME/go
  161. export PATH=$GOPATH/bin:$PATH
  162. '';
  163. }
  164. #+END_SRC
  165. ** Rust
  166. [[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.
  167. Import this shell with ~nix-shell /etc/dotfiles/shells/rust.nix~.
  168. #+BEGIN_SRC nix :noweb yes :tangle shells/rust.nix
  169. # <<file-warning>>
  170. { pkgs ? import <nixpkgs> { } }:
  171. with pkgs;
  172. mkShell {
  173. buildInputs = [
  174. rustup
  175. ];
  176. shellHook = ''
  177. export RUSTUP_HOME="$XDG_DATA_HOME/rustup"
  178. export CARGO_HOME="$XDG_DATA_HOME/cargo"
  179. export PATH="$CARGO_HOME/bin:$PATH"
  180. '';
  181. }
  182. #+END_SRC
  183. ** Node
  184. [[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.
  185. Import this shell with ~nix-shell /etc/dotfiles/shells/node.nix~.
  186. #+BEGIN_SRC nix :noweb yes :tangle shells/node.nix
  187. # <<file-warning>>
  188. { pkgs ? import <nixpkgs> { } }:
  189. with pkgs;
  190. mkShell {
  191. buildInputs = [
  192. nodejs
  193. yarn
  194. ];
  195. shellHook = ''
  196. export NPM_CONFIG_TMP="$XDG_RUNTIME_DIR/npm"
  197. export NPM_CONFIG_CACHE="$XDG_CACHE_HOME/npm"
  198. export NPM_CACHE_PREFIX="$XDG_CACHE_HOME/npm"
  199. export PATH="$(yarn global bin):$PATH"
  200. '';
  201. }
  202. #+END_SRC
  203. ** Java
  204. [[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.
  205. Import this shell with ~nix-shell /etc/dotfiles/shells/java.nix~.
  206. #+BEGIN_SRC nix :noweb yes :tangle shells/java.nix
  207. # <<file-warning>>
  208. { pkgs ? import <nixpkgs> { } }:
  209. with pkgs;
  210. mkShell {
  211. buildInputs = [
  212. # openjdk8 # Legacy Java 8 VM.
  213. # openjdk11 # Current LTS version of OpenJDK.
  214. openjdk14 # Current version of OpenJDK.
  215. ];
  216. shellHook = ''
  217. '';
  218. }
  219. #+END_SRC
  220. ** gRPC
  221. [[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.
  222. Import this shell with ~nix-shell /etc/dotfiles/shells/grpc.nix~.
  223. #+BEGIN_SRC nix :noweb yes :tangle shells/grpc.nix
  224. # <<file-warning>>
  225. { pkgs ? import <nixpkgs> { } }:
  226. with pkgs;
  227. mkShell {
  228. buildInputs = [
  229. grpc
  230. grpcui
  231. grpcurl
  232. grpc-tools
  233. ];
  234. shellHook = ''
  235. '';
  236. }
  237. #+END_SRC
  238. ** C/C++
  239. [[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.
  240. Import this shell with ~nix-shell /etc/dotfiles/shells/cc.nix~.
  241. #+BEGIN_SRC nix :noweb yes :tangle shells/cc.nix
  242. # <<file-warning>>
  243. { pkgs ? import <nixpkgs> { } }:
  244. with pkgs;
  245. mkShell {
  246. buildInputs = [
  247. gdb
  248. ccls
  249. cmake
  250. gnumake
  251. gcc-unwrapped
  252. ];
  253. shellHook = ''
  254. '';
  255. }
  256. #+END_SRC
  257. ** Python
  258. [[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.
  259. Import this shell with ~nix-shell /etc/dotfiles/shells/python.nix~
  260. #+BEGIN_SRC nix :noweb yes :tangle shells/python.nix
  261. # <<file-warning>>
  262. { pkgs ? import <nixpkgs> { } }:
  263. with pkgs;
  264. mkShell {
  265. buildInputs = [
  266. python310Packages.pip
  267. python310Packages.pip-tools
  268. python310Packages.python-lsp-black
  269. python310Packages.python-lsp-server
  270. python310Packages.python-lsp-jsonrpc
  271. ];
  272. shellHook = ''
  273. '';
  274. }
  275. #+END_SRC
  276. ** Docker
  277. [[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.
  278. [[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.
  279. [[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.
  280. Import this shell with ~nix-shell /etc/dotfiles/shells/docker.nix~
  281. #+BEGIN_SRC nix :noweb yes :tangle shells/docker.nix
  282. # <<file-warning>>
  283. { pkgs ? import <nixpkgs> { } }:
  284. with pkgs;
  285. mkShell {
  286. buildInputs = [
  287. docker-compose
  288. docker-machine
  289. ];
  290. shellHook = ''
  291. '';
  292. }
  293. #+END_SRC
  294. ** Heroku
  295. [[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.
  296. Import this shell with ~nix-shell /etc/dotfiles/shells/heroku.nix~
  297. #+BEGIN_SRC nix :noweb yes :tangle shells/heroku.nix
  298. # <<file-warning>>
  299. { pkgs ? import <nixpkgs> { } }:
  300. with pkgs;
  301. mkShell {
  302. buildInputs = [
  303. heroku
  304. ];
  305. shellHook = ''
  306. '';
  307. }
  308. #+END_SRC
  309. ** Clojure
  310. [[https://clojure.org][Clojure]] is a dynamic and functional dialect of the Lisp programming language on the Java platform. Like other dialects, Clojure treats code as data and has a Lisp macro system. The current development process is community driven. Unfortunately the tooling does not comply with the XDG directory specification, so we bring it into the modern age kicking and screaming with a custom shell script binary.
  311. Import this shell with ~nix-shell /etc/dotfiles/shells/clojure.nix~.
  312. #+BEGIN_SRC nix :noweb yes :tangle shells/clojure.nix
  313. # <<file-warning>>
  314. { pkgs ? import <nixpkgs> { } }:
  315. with pkgs;
  316. let
  317. myLein = pkgs.writeShellScriptBin "lein" ''
  318. HOME=~/.local/share/lein ${pkgs.leiningen}/bin/lein
  319. '';
  320. in mkShell {
  321. buildInputs = [
  322. myLein
  323. ];
  324. shellHook = ''
  325. '';
  326. }
  327. #+END_SRC
  328. * Host Configurations
  329. [[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:
  330. #+NAME: host-config-wifi
  331. #+BEGIN_SRC nix
  332. networking.wireless.networks = {
  333. MyWiFi_5C1870 = {
  334. priority = 3;
  335. pskRaw = "409b3c85fef1c5737f284d2f82f20dc6023e41804e862d4fa26265ef8193b326";
  336. };
  337. SM-G975W3034 = {
  338. priority = 1;
  339. pskRaw = "74835d96a98ca2c56ffe4eaf92223f8a555168b59ec2bb22b1e46b2a333adc80";
  340. };
  341. };
  342. #+END_SRC
  343. 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:
  344. #+NAME: host-config-home
  345. #+BEGIN_SRC nix
  346. networking.hosts = {
  347. # "192.168.3.105" = [ "gamingpc" ];
  348. # "192.168.3.163" = [ "acernitro" ];
  349. # "192.168.3.182" = [ "raspberry" ];
  350. # "192.168.3.183" = [ "homecloud" ];
  351. };
  352. #+END_SRC
  353. 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.
  354. #+NAME: host-config-ssh
  355. #+BEGIN_SRC nix
  356. users.users.chris.openssh.authorizedKeys.keys = [
  357. "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIO4wka/LfG3pto15DIm9LIRbb6rWr7/ipCRiCdAKSlY4 chris@chrishayward.xyz"
  358. ];
  359. #+END_SRC
  360. ** Default
  361. 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.
  362. #+NAME: host-default
  363. #+BEGIN_SRC nix :noweb yes
  364. nixos = nixpkgs.lib.nixosSystem {
  365. system = "x86_64-linux";
  366. specialArgs = { inherit inputs; };
  367. modules = [
  368. ./hosts/nixos
  369. <<module-x11>>
  370. <<module-ssh>>
  371. <<module-hugo>>
  372. <<module-godot>>
  373. <<module-flakes>>
  374. <<module-cachix>>
  375. <<module-firefox>>
  376. <<module-home-manager>>
  377. ];
  378. };
  379. #+END_SRC
  380. Deploy this configuration with ~nixos-rebuild switch --flake /etc/dotfiles/#nixos~.
  381. #+BEGIN_SRC nix :noweb yes :tangle hosts/nixos/default.nix
  382. # <<file-warning>>
  383. { ... }:
  384. {
  385. imports = [
  386. ./configuration.nix
  387. ./hardware.nix
  388. ];
  389. }
  390. #+END_SRC
  391. *** Configuration
  392. 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.
  393. #+BEGIN_SRC nix :noweb yes :tangle hosts/nixos/configuration.nix
  394. # <<file-warning>>
  395. { config, pkgs, inputs, ... }:
  396. {
  397. time.timeZone = "America/Toronto";
  398. networking.hostName = "nixos";
  399. networking.useDHCP = false;
  400. networking.firewall.enable = false;
  401. networking.interfaces.ens3.useDHCP = true;
  402. <<host-config-home>>
  403. <<host-config-ssh>>
  404. programs.mtr.enable = true;
  405. programs.fish.enable = true;
  406. programs.gnupg.agent.enable = true;
  407. users.users.chris = {
  408. shell = pkgs.fish;
  409. isNormalUser = true;
  410. extraGroups = [ "wheel" ];
  411. };
  412. }
  413. #+END_SRC
  414. *** Hardware
  415. 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.
  416. #+BEGIN_SRC nix :noweb yes :tangle hosts/nixos/hardware.nix
  417. # <<file-warning>>
  418. { config, lib, pkgs, modulesPath, ... }:
  419. {
  420. imports =
  421. [ (modulesPath + "/profiles/qemu-guest.nix")
  422. ];
  423. boot.initrd.availableKernelModules = [ "ata_piix" "floppy" "sd_mod" "sr_mod" ];
  424. boot.initrd.kernelModules = [ ];
  425. boot.kernelModules = [ ];
  426. boot.extraModulePackages = [ ];
  427. boot.loader.grub.enable = true;
  428. boot.loader.grub.version = 2;
  429. boot.loader.grub.device = "/dev/sda";
  430. fileSystems."/" =
  431. { device = "/dev/disk/by-label/nixos";
  432. fsType = "ext4";
  433. };
  434. swapDevices =
  435. [ { device = "/dev/disk/by-label/swap"; }
  436. ];
  437. }
  438. #+END_SRC
  439. * Module Definitions
  440. 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.
  441. ** X11
  442. #+NAME: module-x11
  443. #+BEGIN_SRC nix
  444. ./modules/x11.nix
  445. #+END_SRC
  446. [[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.
  447. #+BEGIN_SRC nix :noweb yes :tangle modules/x11.nix
  448. # <<file-warning>>
  449. { config, pkgs, ... }:
  450. {
  451. services.xserver.enable = true;
  452. services.xserver.layout = "us";
  453. services.xserver.libinput.enable = true;
  454. services.xserver.displayManager.startx.enable = true;
  455. environment = {
  456. variables = {
  457. XDG_DESKTOP_DIR = "$HOME/";
  458. XDG_CACHE_HOME = "$HOME/.cache";
  459. XDG_CONFIG_HOME = "$HOME/.config";
  460. XDG_DATA_HOME = "$HOME/.local/share";
  461. XDG_BIN_HOME = "$HOME/.local/bin";
  462. };
  463. systemPackages = with pkgs; [
  464. pkgs.sqlite
  465. pkgs.pfetch
  466. pkgs.cmatrix
  467. pkgs.asciiquarium
  468. ];
  469. extraInit = ''
  470. export XAUTHORITY=/tmp/Xauthority
  471. export xserverauthfile=/tmp/xserverauth
  472. [ -e ~/.Xauthority ] && mv -f ~/.Xauthority "$XAUTHORITY"
  473. [ -e ~/.serverauth.* ] && mv -f ~/.serverauth.* "$xserverauthfile"
  474. '';
  475. };
  476. services.picom.enable = true;
  477. services.printing.enable = true;
  478. fonts.fonts = with pkgs; [
  479. iosevka-bin
  480. emacs-all-the-icons-fonts
  481. ];
  482. }
  483. #+END_SRC
  484. ** SSH
  485. #+NAME: module-ssh
  486. #+BEGIN_SRC nix
  487. ./modules/ssh.nix
  488. #+END_SRC
  489. [[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.
  490. Apply some configuration to the default settings:
  491. + Disable logging in as =root=
  492. + Disable password authentication
  493. #+BEGIN_SRC nix :noweb yes :tangle modules/ssh.nix
  494. # <<file-warning>>
  495. { config, pkgs, ... }:
  496. {
  497. services.openssh = {
  498. enable = true;
  499. permitRootLogin = "no";
  500. passwordAuthentication = false;
  501. };
  502. }
  503. #+END_SRC
  504. ** Hugo
  505. #+NAME: module-hugo
  506. #+BEGIN_SRC nix
  507. ./modules/hugo.nix
  508. #+END_SRC
  509. [[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.
  510. #+BEGIN_SRC nix :noweb yes :tangle modules/hugo.nix
  511. # <<file-warning>>
  512. { config, pkgs, ... }:
  513. let
  514. mySiteDir = "/etc/dotfiles/docs/public/";
  515. mySiteTgt = "ubuntu@chrishayward.xyz:/var/www/wedding";
  516. mySiteBuild = pkgs.writeShellScriptBin "my-site-build" ''
  517. pushd ${mySiteDir}../ && ${pkgs.hugo}/bin/hugo -v ; popd
  518. '';
  519. mySiteUpdate = pkgs.writeShellScriptBin "my-site-update" ''
  520. ${pkgs.rsync}/bin/rsync -aP ${mySiteDir} ${mySiteTgt}
  521. '';
  522. in {
  523. environment.systemPackages = [
  524. mySiteBuild
  525. mySiteUpdate
  526. ];
  527. }
  528. #+END_SRC
  529. ** Godot
  530. #+NAME: module-godot
  531. #+BEGIN_SRC nix
  532. ./modules/godot.nix
  533. #+END_SRC
  534. [[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.
  535. #+BEGIN_SRC nix :noweb yes :tangle modules/godot.nix
  536. # <<file-warning>>
  537. { config, pkgs, ... }:
  538. {
  539. environment.systemPackages = [
  540. pkgs.tiled
  541. pkgs.godot
  542. pkgs.godot-server
  543. pkgs.godot-headless
  544. pkgs.python310Packages.gdtoolkit
  545. ];
  546. }
  547. #+END_SRC
  548. ** Flakes
  549. #+NAME: module-flakes
  550. #+BEGIN_SRC nix
  551. ./modules/flakes.nix
  552. #+END_SRC
  553. [[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.
  554. #+BEGIN_SRC nix :noweb yes :tangle modules/flakes.nix
  555. # <<file-warning>>
  556. { config, pkgs, inputs, ... }:
  557. {
  558. nix = {
  559. package = pkgs.nixUnstable;
  560. extraOptions = ''
  561. experimental-features = nix-command flakes
  562. '';
  563. };
  564. nixpkgs = {
  565. config = { allowUnfree = true; };
  566. overlays = [ inputs.emacs-overlay.overlay ];
  567. };
  568. }
  569. #+END_SRC
  570. ** Cachix
  571. #+NAME: module-cachix
  572. #+BEGIN_SRC nix
  573. ./modules/cachix.nix
  574. #+END_SRC
  575. [[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.
  576. #+BEGIN_SRC nix :noweb yes :tangle modules/cachix.nix
  577. # <<file-warning>>
  578. { config, ... }:
  579. {
  580. nix = {
  581. settings = {
  582. substituters = [
  583. "https://nix-community.cachix.org"
  584. ];
  585. trusted-public-keys = [
  586. "nix-community.cachix.org-1:mB9FSh9qf2dCimDSUo8Zy7bkq5CX+/rkCWyvRCYg3Fs="
  587. ];
  588. };
  589. };
  590. }
  591. #+END_SRC
  592. ** Docker
  593. #+NAME: module-docker
  594. #+BEGIN_SRC nix
  595. ./modules/docker.nix
  596. #+END_SRC
  597. [[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.
  598. #+BEGIN_SRC nix :noweb yes :tangle modules/docker.nix
  599. { config, pkgs, ... }:
  600. {
  601. # Enable the docker virutalization platform.
  602. virtualisation.docker = {
  603. enable = true;
  604. enableOnBoot = true;
  605. autoPrune.enable = true;
  606. };
  607. # Required for the `docker' command.
  608. users.users.chris.extraGroups = [ "docker" ];
  609. }
  610. #+END_SRC
  611. ** Firefox
  612. #+NAME: module-firefox
  613. #+BEGIN_SRC nix
  614. ./modules/firefox.nix
  615. #+END_SRC
  616. [[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.
  617. #+BEGIN_SRC nix :noweb yes :tangle modules/firefox.nix
  618. # <<file-warning>>
  619. { config, pkgs, ... }:
  620. let
  621. myFirefox = pkgs.writeShellScriptBin "firefox" ''
  622. HOME=~/.local/share/mozilla ${pkgs.firefox-bin}/bin/firefox
  623. '';
  624. in {
  625. # NOTE: Use the binary until module is developed.
  626. environment.systemPackages = [
  627. myFirefox
  628. ];
  629. }
  630. #+END_SRC
  631. ** Home Manager
  632. [[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.
  633. #+NAME: module-home-manager
  634. #+BEGIN_SRC nix :noweb yes
  635. inputs.home-manager.nixosModules.home-manager {
  636. home-manager.useGlobalPkgs = true;
  637. home-manager.useUserPackages = true;
  638. home-manager.users.chris = {
  639. imports = [
  640. <<module-git>>
  641. <<module-gpg>>
  642. <<module-vim>>
  643. <<module-gtk>>
  644. <<module-emacs>>
  645. ];
  646. };
  647. }
  648. #+END_SRC
  649. Certain modules have to be included within home manager or they will not function correctly.
  650. #+NAME: home-manager-warning
  651. #+BEGIN_SRC text
  652. This module MUST be included within home manager
  653. #+END_SRC
  654. *** Git
  655. #+NAME: module-git
  656. #+BEGIN_SRC nix
  657. ./modules/git.nix
  658. #+END_SRC
  659. [[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.
  660. #+BEGIN_SRC nix :noweb yes :tangle modules/git.nix
  661. # <<file-warning>>
  662. # <<home-manager-warning>>
  663. { pkgs, ... }:
  664. let
  665. # Fix any corruptions in the local copy.
  666. myGitFix = pkgs.writeShellScriptBin "git-fix" ''
  667. if [ -d .git/objects/ ]; then
  668. find .git/objects/ -type f -empty | xargs rm -f
  669. git fetch -p
  670. git fsck --full
  671. fi
  672. exit 1
  673. '';
  674. in {
  675. home.packages = [ myGitFix ];
  676. programs.git = {
  677. enable = true;
  678. userName = "Christopher James Hayward";
  679. userEmail = "chris@chrishayward.xyz";
  680. signing = {
  681. key = "37AB1CB72B741E478CA026D43025DCBD46F81C0F";
  682. signByDefault = true;
  683. };
  684. };
  685. }
  686. #+END_SRC
  687. *** Gpg
  688. #+NAME: module-gpg
  689. #+BEGIN_SRC nix
  690. ./modules/gpg.nix
  691. #+END_SRC
  692. [[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.
  693. #+BEGIN_SRC nix :noweb yes :tangle modules/gpg.nix
  694. # <<file-warning>>
  695. # <<home-manager-warning>>
  696. { pkgs, ... }:
  697. {
  698. services.gpg-agent = {
  699. enable = true;
  700. defaultCacheTtl = 1800;
  701. enableSshSupport = true;
  702. pinentryFlavor = "gtk2";
  703. };
  704. }
  705. #+END_SRC
  706. *** Vim
  707. #+NAME: module-vim
  708. #+BEGIN_SRC nix
  709. ./modules/vim.nix
  710. #+END_SRC
  711. [[https://neovim.io][Neovim]] is a project that seeks to aggressively refactor Vim in order to:
  712. + Simplify maintenance and encourage contributions
  713. + Split the work between multiple developers
  714. + Enable advanced UIs without core modification
  715. + Maximize extensibility
  716. #+BEGIN_SRC nix :noweb yes :tangle modules/vim.nix
  717. # <<file-warning>>
  718. # <<home-manager-warning>>
  719. { pkgs, ... }:
  720. {
  721. programs.neovim = {
  722. enable = true;
  723. viAlias = true;
  724. vimAlias = true;
  725. vimdiffAlias = true;
  726. extraConfig = ''
  727. set number relativenumber
  728. set nobackup
  729. '';
  730. extraPackages = [
  731. pkgs.nixfmt
  732. ];
  733. plugins = with pkgs.vimPlugins; [
  734. vim-nix
  735. vim-airline
  736. vim-polyglot
  737. ];
  738. };
  739. }
  740. #+END_SRC
  741. *** GTK
  742. #+NAME: module-gtk
  743. #+BEGIN_SRC nix
  744. ./modules/gtk.nix
  745. #+END_SRC
  746. [[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.
  747. #+BEGIN_SRC nix :noweb yes :tangle modules/gtk.nix
  748. # <<file-warning>>
  749. # <<home-manager-warning>>
  750. { pkgs, ... }:
  751. {
  752. home.packages = [
  753. pkgs.nordic
  754. pkgs.arc-icon-theme
  755. pkgs.lxappearance
  756. ];
  757. home.file.".gtkrc-2.0" = {
  758. text = ''
  759. gtk-theme-name="Nordic-darker"
  760. gtk-icon-theme-name="Arc"
  761. gtk-font-name="Iosevka 11"
  762. gtk-cursor-theme-size=0
  763. gtk-toolbar-style=GTK_TOOLBAR_BOTH_HORIZ
  764. gtk-toolbar-icon-size=GTK_ICON_SIZE_LARGE_TOOLBAR
  765. gtk-button-images=0
  766. gtk-menu-images=0
  767. gtk-enable-event-sounds=1
  768. gtk-enable-input-feedback-sounds=1
  769. gtk-xft-antialias=1
  770. gtk-xft-hinting=1
  771. gtk-xft-hintstyle="hintmedium"
  772. '';
  773. };
  774. home.file.".config/gtk-2.0/gtkfilechooser.ini" = {
  775. text = ''
  776. [Filechooser Settings]
  777. LocationMode=path-bar
  778. ShowHidden=false
  779. ShowSizeColumn=true
  780. GeometryX=442
  781. GeometryY=212
  782. GeometryWidth=1036
  783. GeometryHeight=609
  784. SortColumn=name
  785. SortOrder=ascending
  786. StartupMode=recent
  787. '';
  788. };
  789. home.file.".config/gtk-3.0/settings.ini" = {
  790. text = ''
  791. [Settings]
  792. gtk-theme-name=Nordic-darker
  793. gtk-icon-theme-name=Arc
  794. gtk-font-name=Iosevka 11
  795. gtk-cursor-theme-size=0
  796. gtk-toolbar-style=GTK_TOOLBAR_BOTH_HORIZ
  797. gtk-toolbar-icon-size=GTK_ICON_SIZE_LARGE_TOOLBAR
  798. gtk-button-images=0
  799. gtk-menu-images=0
  800. gtk-enable-event-sounds=1
  801. gtk-enable-input-feedback-sounds=1
  802. gtk-xft-antialias=1
  803. gtk-xft-hinting=1
  804. gtk-xft-hintstyle=hintmedium
  805. '';
  806. };
  807. }
  808. #+END_SRC
  809. * Emacs Configuration
  810. [[./docs/images/emacs.png]]
  811. #+NAME: module-emacs
  812. #+BEGIN_SRC nix
  813. ./modules/emacs.nix
  814. #+END_SRC
  815. [[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:
  816. + Highly customizable
  817. + Full Unicopde support
  818. + Content-aware editing modes
  819. + Complete built-in documentation
  820. + Wide range of functionality beyond text editing
  821. #+BEGIN_SRC nix :noweb yes :tangle modules/emacs.nix
  822. # <<file-warning>>
  823. # <<home-manager-warning>>
  824. { pkgs, ... }:
  825. let
  826. myEmacs = pkgs.emacsWithPackagesFromUsePackage {
  827. config = ../README.org;
  828. package = <<emacs-native-comp-package>>
  829. alwaysEnsure = true;
  830. alwaysTangle = true;
  831. extraEmacsPackages = epkgs: [
  832. # Required packages...
  833. <<emacs-exwm-package>>
  834. <<emacs-evil-package>>
  835. <<emacs-general-package>>
  836. <<emacs-which-key-package>>
  837. # Optional packages.
  838. <<emacs-org-package>>
  839. <<emacs-org-roam-package>>
  840. <<emacs-org-roam-ui-package>>
  841. <<emacs-org-drill-package>>
  842. <<emacs-pomodoro-package>>
  843. <<emacs-writegood-package>>
  844. <<emacs-http-package>>
  845. <<emacs-hugo-package>>
  846. <<emacs-pass-package>>
  847. <<emacs-docker-package>>
  848. <<emacs-mu4e-package>>
  849. <<emacs-dired-package>>
  850. <<emacs-icons-package>>
  851. <<emacs-emoji-package>>
  852. <<emacs-eshell-package>>
  853. <<emacs-vterm-package>>
  854. <<emacs-magit-package>>
  855. <<emacs-hydra-package>>
  856. <<emacs-elfeed-package>>
  857. <<emacs-nix-mode-package>>
  858. <<emacs-projectile-package>>
  859. <<emacs-lsp-package>>
  860. <<emacs-company-package>>
  861. <<emacs-gdscript-package>>
  862. <<emacs-ccls-package>>
  863. <<emacs-golang-package>>
  864. <<emacs-python-package>>
  865. <<emacs-rustic-package>>
  866. <<emacs-protobuf-package>>
  867. <<emacs-typescript-package>>
  868. <<emacs-clojure-package>>
  869. <<emacs-plantuml-package>>
  870. # User interface packages.
  871. <<emacs-swiper-package>>
  872. <<emacs-desktop-package>>
  873. <<emacs-doom-themes-package>>
  874. <<emacs-doom-modeline-package>>
  875. ];
  876. };
  877. in {
  878. home.packages = [
  879. <<emacs-exwm-extras>>
  880. <<emacs-pass-extras>>
  881. <<emacs-mu4e-extras>>
  882. <<emacs-aspell-extras>>
  883. <<emacs-texlive-extras>>
  884. <<emacs-desktop-extras>>
  885. <<emacs-plantuml-extras>>
  886. <<emacs-nix-mode-extras>>
  887. <<emacs-doom-themes-extras>>
  888. ];
  889. programs.emacs = {
  890. enable = true;
  891. package = myEmacs;
  892. };
  893. <<emacs-exwm-config>>
  894. <<emacs-exwm-xinitrc>>
  895. <<emacs-mu4e-config>>
  896. }
  897. #+END_SRC
  898. 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.
  899. #+BEGIN_SRC emacs-lisp :noweb yes :tangle ~/.config/emacs/init.el
  900. ;; <<file-warning>>
  901. ;; Required inputs.
  902. <<emacs-exwm-elisp>>
  903. <<emacs-evil-elisp>>
  904. <<emacs-general-elisp>>
  905. <<emacs-which-key-elisp>>
  906. ;; Optional inputs.
  907. <<emacs-org-elisp>>
  908. <<emacs-org-roam-elisp>>
  909. <<emacs-org-roam-ui-elisp>>
  910. <<emacs-org-drill-elisp>>
  911. <<emacs-org-agenda-elisp>>
  912. <<emacs-pomodoro-elisp>>
  913. <<emacs-writegood-elisp>>
  914. <<emacs-aspell-elisp>>
  915. <<emacs-eww-elisp>>
  916. <<emacs-http-elisp>>
  917. <<emacs-hugo-elisp>>
  918. <<emacs-pass-elisp>>
  919. <<emacs-docker-elisp>>
  920. <<emacs-erc-elisp>>
  921. <<emacs-mu4e-elisp>>
  922. <<emacs-dired-elisp>>
  923. <<emacs-icons-elisp>>
  924. <<emacs-emoji-elisp>>
  925. <<emacs-eshell-elisp>>
  926. <<emacs-vterm-elisp>>
  927. <<emacs-magit-elisp>>
  928. <<emacs-fonts-elisp>>
  929. <<emacs-frames-elisp>>
  930. <<emacs-elfeed-elisp>>
  931. <<emacs-projectile-elisp>>
  932. <<emacs-lsp-elisp>>
  933. <<emacs-company-elisp>>
  934. <<emacs-gdscript-elisp>>
  935. <<emacs-golang-elisp>>
  936. <<emacs-python-elisp>>
  937. <<emacs-rustic-elisp>>
  938. <<emacs-clojure-elisp>>
  939. <<emacs-plantuml-elisp>>
  940. <<emacs-desktop-elisp>>
  941. ;; User interface.
  942. <<emacs-swiper-elisp>>
  943. <<emacs-transparency-elisp>>
  944. <<emacs-doom-themes-elisp>>
  945. <<emacs-doom-modeline-elisp>>
  946. #+END_SRC
  947. 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=.
  948. #+BEGIN_SRC emacs-lisp :noweb yes :tangle ~/.config/emacs/early-init.el
  949. ;; <<file-warning>>
  950. <<emacs-disable-ui-elisp>>
  951. <<emacs-native-comp-elisp>>
  952. <<emacs-backup-files-elisp>>
  953. <<emacs-shell-commands-elisp>>
  954. <<emacs-improved-prompts>>
  955. #+END_SRC
  956. ** Native Comp
  957. #+NAME: emacs-native-comp-package
  958. #+BEGIN_SRC nix
  959. pkgs.emacsNativeComp;
  960. #+END_SRC
  961. 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.
  962. #+NAME: emacs-native-comp-elisp
  963. #+BEGIN_SRC emacs-lisp
  964. ;; Silence warnings from packages that don't support `native-comp'.
  965. (setq comp-async-report-warnings-errors nil ;; Emacs 27.2 ...
  966. native-comp-async-report-warnings-errors nil) ;; Emacs 28+ ...
  967. #+END_SRC
  968. ** Disable UI
  969. [[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.
  970. #+NAME: emacs-disable-ui-elisp
  971. #+BEGIN_SRC emacs-lisp
  972. ;; Disable unwanted UI elements.
  973. (tooltip-mode -1)
  974. (menu-bar-mode -1)
  975. (tool-bar-mode -1)
  976. (scroll-bar-mode -1)
  977. ;; Fix the scrolling behaviour.
  978. (setq scroll-conservatively 101)
  979. ;; Fix mouse-wheel scrolling behaviour.
  980. (setq mouse-wheel-follow-mouse t
  981. mouse-wheel-progressive-speed t
  982. mouse-wheel-scroll-amount '(3 ((shift) . 3)))
  983. ;; Start in fullscreen/maximized.
  984. (add-to-list 'default-frame-alist '(fullscreen . maximized))
  985. #+END_SRC
  986. ** Backup Files
  987. [[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.
  988. #+NAME: emacs-backup-files-elisp
  989. #+BEGIN_SRC emacs-lisp
  990. ;; Disable unwanted features.
  991. (setq make-backup-files nil
  992. create-lockfiles nil)
  993. #+END_SRC
  994. ** Shell Commands
  995. Define some methods for interaction between [[https://gnu.org/software/emacs/][GNU/Emacs]], and the systems underyling shell:
  996. 1) Method to run an external process, launching any application on a new process without interference
  997. 2) Method to apply commands to the current call process, effecting the running instance
  998. #+NAME: emacs-shell-commands-elisp
  999. #+BEGIN_SRC emacs-lisp
  1000. ;; Define a method to run an external process.
  1001. (defun dotfiles/run (cmd)
  1002. "Run an external process."
  1003. (interactive (list (read-shell-command "λ ")))
  1004. (start-process-shell-command cmd nil cmd))
  1005. ;; Define a method to run a background process.
  1006. (defun dotfiles/run-in-background (cmd)
  1007. (let ((command-parts (split-string cmd "[ ]+")))
  1008. (apply #'call-process `(,(car command-parts) nil 0 nil ,@(cdr command-parts)))))
  1009. #+END_SRC
  1010. ** Improved prompts
  1011. 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.
  1012. #+NAME: emacs-improved-prompts
  1013. #+BEGIN_SRC emacs-lisp
  1014. ;; Use 'y' and 'n' instead of 'yes' and 'no'.
  1015. (defalias 'yes-or-no-p 'y-or-n-p)
  1016. #+END_SRC
  1017. ** Nix Mode
  1018. #+NAME: emacs-nix-mode-extras
  1019. #+BEGIN_SRC nix
  1020. pkgs.nixfmt
  1021. pkgs.rnix-lsp
  1022. #+END_SRC
  1023. [[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.
  1024. #+NAME: emacs-nix-mode-package
  1025. #+BEGIN_SRC nix
  1026. epkgs.nix-mode
  1027. #+END_SRC
  1028. ** Evil Mode
  1029. [[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.
  1030. #+NAME: emacs-evil-package
  1031. #+BEGIN_SRC nix
  1032. epkgs.evil
  1033. epkgs.evil-collection
  1034. epkgs.evil-surround
  1035. epkgs.evil-nerd-commenter
  1036. #+END_SRC
  1037. 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]].
  1038. #+NAME: emacs-evil-elisp
  1039. #+BEGIN_SRC emacs-lisp
  1040. ;; Enable the Extensible VI Layer for Emacs.
  1041. (setq evil-want-integration t ;; Required for `evil-collection.'
  1042. evil-want-keybinding nil ;; Same as above.
  1043. evil-want-C-i-jump nil) ;; Disable jumping in terminal.
  1044. (evil-mode +1)
  1045. ;; Configure `evil-collection'.
  1046. (evil-collection-init)
  1047. ;; Configure `evil-surround'.
  1048. (global-evil-surround-mode +1)
  1049. ;; Configure `evil-nerd-commenter'.
  1050. (global-set-key (kbd "M-;") 'evilnc-comment-or-uncomment-lines)
  1051. ;; Invoke `org-cycle' in normal mode inside of `org-mode' buffers.
  1052. (evil-define-key 'normal 'org-mode-map (kbd "<tab>") #'org-cycle)
  1053. #+END_SRC
  1054. ** EXWM
  1055. #+NAME: emacs-exwm-package
  1056. #+BEGIN_SRC nix
  1057. epkgs.exwm
  1058. #+END_SRC
  1059. [[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:
  1060. + Fully keyboard-driven operations
  1061. + Hybrid layout modes (tiling & stacking)
  1062. + Dynamic workspace support
  1063. + ICCM/EWMH compliance
  1064. #+NAME: emacs-exwm-extras
  1065. #+BEGIN_SRC nix
  1066. pkgs.nitrogen
  1067. pkgs.autorandr
  1068. #+END_SRC
  1069. 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]].
  1070. #+NAME: emacs-exwm-config
  1071. #+BEGIN_SRC nix
  1072. xsession = {
  1073. enable = true;
  1074. windowManager.command = ''
  1075. ${pkgs.nitrogen}/bin/nitrogen --restore
  1076. ${myEmacs}/bin/emacs --daemon -f exwm-enable
  1077. ${myEmacs}/bin/emacsclient -c
  1078. '';
  1079. };
  1080. #+END_SRC
  1081. [[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=.
  1082. #+NAME: emacs-exwm-xinitrc
  1083. #+BEGIN_SRC nix
  1084. home.file.".xinitrc" = {
  1085. text = ''
  1086. exec ./.xsession
  1087. '';
  1088. };
  1089. #+END_SRC
  1090. #+NAME: emacs-exwm-elisp
  1091. #+BEGIN_SRC emacs-lisp
  1092. ;; Configure `exwm'.
  1093. (setq exwm-workspace-number 5
  1094. exwm-layout-show-all-buffers t
  1095. exwm-worspace-show-all-buffers t)
  1096. ;; Configure input keys.
  1097. (setq exwm-input-prefix-keys
  1098. '(?\M-x
  1099. ?\C-g
  1100. ?\C-\ ))
  1101. (setq exwm-input-global-keys
  1102. `(([?\s-r] . exwm-reset)
  1103. ,@(mapcar (lambda (i)
  1104. `(,(kbd (format "s-%d" i)) .
  1105. (lambda ()
  1106. (interactive)
  1107. (exwm-workspace-switch-create ,i))))
  1108. (number-sequence 0 9))))
  1109. ;; Configure `exwm-randr'.
  1110. (require 'exwm-randr)
  1111. (exwm-randr-enable)
  1112. ;; Configure custom hooks.
  1113. (setq display-time-day-and-date t)
  1114. (add-hook 'exwm-init-hook
  1115. (lambda ()
  1116. (display-battery-mode +1) ;; Display battery info (if available).
  1117. (display-time-mode +1))) ;; Display the time in the modeline.
  1118. ;; Setup buffer display names.
  1119. (add-hook 'exwm-update-class-hook
  1120. (lambda ()
  1121. (exwm-workspace-rename-buffer exwm-class-name))) ;; Use the system class name.
  1122. ;; Configure monitor hot-swapping.
  1123. (add-hook 'exwm-randr-screen-change-hook
  1124. (lambda ()
  1125. (dotfiles/run-in-background "autorandr --change --force"))) ;; Swap to the next screen config.
  1126. #+END_SRC
  1127. ** General
  1128. #+NAME: emacs-general-package
  1129. #+BEGIN_SRC nix
  1130. epkgs.general
  1131. #+END_SRC
  1132. [[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.
  1133. #+NAME: emacs-general-elisp
  1134. #+BEGIN_SRC emacs-lisp
  1135. ;; Use <SPC> as a leader key via `general.el'.
  1136. (general-create-definer dotfiles/leader
  1137. :keymaps '(normal insert visual emacs)
  1138. :prefix "SPC"
  1139. :global-prefix "C-SPC")
  1140. ;; Setup general to work with `evil-mode'.
  1141. (setq general-evil-setup t)
  1142. ;; Find files with <SPC> <period> ...
  1143. ;; Switch buffers with <SPC> <comma> ...
  1144. (dotfiles/leader
  1145. "." '(find-file :which-key "File")
  1146. "," '(switch-to-buffer :which-key "Buffer")
  1147. "k" '(kill-buffer :which-key "Kill")
  1148. "c" '(kill-buffer-and-window :which-key "Close"))
  1149. ;; Add keybindings for executing shell commands.
  1150. (dotfiles/leader
  1151. "r" '(:ignore t :which-key "Run")
  1152. "rr" '(dotfiles/run :which-key "Run")
  1153. "ra" '(async-shell-command :which-key "Async"))
  1154. ;; Add keybindings for quitting Emacs.
  1155. (dotfiles/leader
  1156. "q" '(:ignore t :which-key "Quit")
  1157. "qq" '(save-buffers-kill-emacs :which-key "Save")
  1158. "qw" '(kill-emacs :which-key "Now")
  1159. "qf" '(delete-frame :which-key "Frame"))
  1160. ;; Add keybindings for toggles / tweaks.
  1161. (dotfiles/leader
  1162. "t" '(:ignore t :which-key "Toggle / Tweak"))
  1163. #+END_SRC
  1164. ** Which Key
  1165. [[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.
  1166. #+NAME: emacs-which-key-package
  1167. #+BEGIN_SRC nix
  1168. epkgs.which-key
  1169. #+END_SRC
  1170. #+NAME: emacs-which-key-elisp
  1171. #+BEGIN_SRC emacs-lisp
  1172. ;; Configure `which-key' to see keyboard bindings in the
  1173. ;; mini-buffer and when using M-x.
  1174. (setq which-key-idle-delay 0.0)
  1175. (which-key-mode +1)
  1176. #+END_SRC
  1177. ** EWW
  1178. [[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.
  1179. + Use ~eww~ as the default browser
  1180. + Don't use any special fonts or colours
  1181. #+NAME: emacs-eww-elisp
  1182. #+BEGIN_SRC emacs-lisp
  1183. ;; Set `eww' as the default browser.
  1184. (setq browse-url-browser-function 'eww-browse-url)
  1185. ;; Configure the `shr' rendering engine.
  1186. (setq shr-use-fonts nil
  1187. shr-use-colors nil)
  1188. #+END_SRC
  1189. ** ERC
  1190. [[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.
  1191. #+NAME: emacs-erc-elisp
  1192. #+BEGIN_SRC emacs-lisp
  1193. ;; Configure `erc'.
  1194. (setq erc-autojoin-channels-alist '(("irc.libera.chat" "#emacs" "#nixos" "#org-mode" "#systemcrafters"))
  1195. erc-track-exclude-types '("JOIN" "NICK" "QUIT" "MODE")
  1196. erc-lurker-hide-list '("JOIN" "PART" "QUIT"))
  1197. ;; Configure `erc-fill-column'.
  1198. (add-hook 'window-configuration-change-hook
  1199. '(lambda ()
  1200. (setq erc-fill-column (- (window-width) 12))))
  1201. ;; Connect to IRC via `erc'.
  1202. (defun dotfiles/erc-connect ()
  1203. "Connected to IRC via `erc'."
  1204. (interactive)
  1205. (erc-tls :server "irc.libera.chat"
  1206. :port 6697
  1207. :nick "megaphone"
  1208. :password (password-store-get "libera.chat/megaphone")
  1209. :full-name "Chris Hayward"))
  1210. ;; Configure keybindings.
  1211. (dotfiles/leader
  1212. "i" '(dotfiles/erc-connect :which-key "Chat"))
  1213. #+END_SRC
  1214. ** Dired
  1215. #+NAME: emacs-dired-package
  1216. #+BEGIN_SRC nix
  1217. epkgs.dired-single
  1218. #+END_SRC
  1219. [[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.
  1220. #+NAME: emacs-dired-elisp
  1221. #+BEGIN_SRC emacs-lisp
  1222. ;; Include `dired-x' for the `jump' method.
  1223. (require 'dired-x)
  1224. ;; Configure `dired-single' to support `evil' keys.
  1225. (evil-collection-define-key 'normal 'dired-mode-map
  1226. "h" 'dired-single-up-directory
  1227. "l" 'dired-single-buffer)
  1228. ;; Configure keybindings for `dired'.
  1229. (dotfiles/leader
  1230. "d" '(dired-jump :which-key "Dired"))
  1231. #+END_SRC
  1232. ** Icons
  1233. #+NAME: emacs-icons-package
  1234. #+BEGIN_SRC nix
  1235. epkgs.all-the-icons
  1236. epkgs.all-the-icons-dired
  1237. epkgs.all-the-icons-ivy-rich
  1238. #+END_SRC
  1239. [[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]].
  1240. #+NAME: emacs-icons-elisp
  1241. #+BEGIN_SRC emacs-lisp
  1242. ;; Setup `all-the-icons-dired'.
  1243. (add-hook 'dired-mode-hook 'all-the-icons-dired-mode)
  1244. ;; Disable monochrome icons.
  1245. (setq all-the-icons-dired-monochrome nil)
  1246. ;; Display default font ligatures.
  1247. (global-prettify-symbols-mode +1)
  1248. #+END_SRC
  1249. ** Emojis
  1250. #+NAME: emacs-emoji-package
  1251. #+BEGIN_SRC nix
  1252. epkgs.emojify
  1253. #+END_SRC
  1254. [[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.
  1255. #+NAME: emacs-emoji-elisp
  1256. #+BEGIN_SRC emacs-lisp
  1257. ;; Setup `emojify'.
  1258. (add-hook 'after-init-hook 'global-emojify-mode)
  1259. #+END_SRC
  1260. ** EShell
  1261. #+NAME: emacs-eshell-package
  1262. #+BEGIN_SRC nix
  1263. epkgs.eshell-prompt-extras
  1264. #+END_SRC
  1265. [[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.
  1266. #+NAME: emacs-eshell-elisp
  1267. #+BEGIN_SRC emacs-lisp
  1268. ;; Configure `eshell'.
  1269. (setq eshell-highlight-prompt nil
  1270. eshell-prefer-lisp-functions nil)
  1271. ;; Configure the lambda prompt.
  1272. (autoload 'epe-theme-lambda "eshell-prompt-extras")
  1273. (setq eshell-prompt-function 'epe-theme-lambda)
  1274. ;; Configure keybindings for `eshell'.
  1275. (dotfiles/leader
  1276. "e" '(eshell :which-key "EShell"))
  1277. #+END_SRC
  1278. ** VTerm
  1279. [[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.
  1280. #+NAME: emacs-vterm-package
  1281. #+BEGIN_SRC nix
  1282. epkgs.vterm
  1283. #+END_SRC
  1284. #+NAME: emacs-vterm-elisp
  1285. #+BEGIN_SRC emacs-lisp
  1286. ;; Add keybindings for interacting with the shell(s).
  1287. (dotfiles/leader
  1288. "v" '(vterm :which-key "VTerm"))
  1289. #+END_SRC
  1290. ** Magit
  1291. [[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.
  1292. #+NAME: emacs-magit-package
  1293. #+BEGIN_SRC nix
  1294. epkgs.magit
  1295. #+END_SRC
  1296. #+NAME: emacs-magit-elisp
  1297. #+BEGIN_SRC emacs-lisp
  1298. ;; Add keybindings for working with `magit'.
  1299. (dotfiles/leader
  1300. "g" '(:ignore t :which-key "Git")
  1301. "gg" '(magit-status :which-key "Status")
  1302. "gc" '(magit-clone :which-key "Clone")
  1303. "gf" '(magit-fetch :which-key "Fetch")
  1304. "gp" '(magit-pull :which-key "Pull"))
  1305. #+END_SRC
  1306. ** Hydra
  1307. #+NAME: emacs-hydra-package
  1308. #+BEGIN_SRC nix
  1309. epkgs.hydra
  1310. #+END_SRC
  1311. [[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.
  1312. ** Fonts
  1313. [[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.
  1314. #+NAME: emacs-fonts-elisp
  1315. #+BEGIN_SRC emacs-lisp
  1316. ;; Configure the font when running as `emacs-server'.
  1317. (custom-set-faces
  1318. '(default ((t (:inherit nil :height 120 :family "Iosevka")))))
  1319. ;; Define a `hydra' function for scaling the text interactively.
  1320. (defhydra hydra-text-scale (:timeout 4)
  1321. "Scale the text in the current buffer."
  1322. ("k" text-scale-decrease "Decrease")
  1323. ("j" text-scale-increase "Increase")
  1324. ("f" nil "Finished" :exit t))
  1325. ;; Create keybinding for calling the function.
  1326. (dotfiles/leader
  1327. "tf" '(hydra-text-scale/body :which-key "Font"))
  1328. #+END_SRC
  1329. ** Frames
  1330. 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:
  1331. #+NAME: emacs-frames-elisp
  1332. #+BEGIN_SRC emacs-lisp
  1333. ;; Define a `hydra' function for resizing the current frame.
  1334. (defhydra hydra-resize-frame (:timeout 4)
  1335. "Scale the current frame."
  1336. ("h" shrink-window-horizontally "Left")
  1337. ("j" enlarge-window "Down")
  1338. ("k" shrink-window "Up")
  1339. ("l" enlarge-window-horizontally "Right")
  1340. ("f" nil "Finished" :exit t))
  1341. ;; Add keybindings for working with frames to replace
  1342. ;; the C-x <num> <num> method of bindings, which is awful.
  1343. (dotfiles/leader
  1344. "w" '(:ignore t :which-key "Windows")
  1345. "ww" '(window-swap-states :which-key "Swap")
  1346. "wc" '(delete-window :which-key "Close")
  1347. "wh" '(windmove-left :which-key "Left")
  1348. "wj" '(windmove-down :which-key "Down")
  1349. "wk" '(windmove-up :which-key "Up")
  1350. "wl" '(windmove-right :which-key "Right")
  1351. "ws" '(:ignore t :which-key "Split")
  1352. "wsj" '(split-window-below :which-key "Below")
  1353. "wsl" '(split-window-right :which-key "Right")
  1354. "wr" '(hydra-resize-frame/body :which-key "Resize"))
  1355. #+END_SRC
  1356. ** Elfeed
  1357. #+NAME: emacs-elfeed-package
  1358. #+BEGIN_SRC nix
  1359. epkgs.elfeed
  1360. #+END_SRC
  1361. [[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.
  1362. #+NAME: emacs-elfeed-elisp
  1363. #+BEGIN_SRC emacs-lisp
  1364. ;; Configure `elfeed'.
  1365. (setq elfeed-db-directory (expand-file-name "~/.cache/elfeed"))
  1366. ;; Add custom feeds for `elfeed' to fetch.
  1367. (setq elfeed-feeds (quote
  1368. (("https://hexdsl.co.uk/rss.xml")
  1369. ("https://lukesmith.xyz/rss.xml")
  1370. ("https://friendo.monster/rss.xml")
  1371. ("https://chrishayward.xyz/index.xml")
  1372. ("https://protesilaos.com/master.xml"))))
  1373. ;; Add custom keybindings for `elfeed'.
  1374. (dotfiles/leader
  1375. "f" '(:ignore t :which-key "Elfeed")
  1376. "fl" '(elfeed :which-key "Open")
  1377. "fu" '(elfeed-update :which-key "Update"))
  1378. #+END_SRC
  1379. ** Org Mode
  1380. #+NAME: emacs-org-package
  1381. #+BEGIN_SRC nix
  1382. epkgs.org
  1383. #+END_SRC
  1384. [[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.
  1385. #+NAME: emacs-org-elisp
  1386. #+BEGIN_SRC emacs-lisp
  1387. ;; Configure `org-mode' source blocks.
  1388. (setq org-src-fontify-natively t ;; Make source blocks prettier.
  1389. org-src-tab-acts-natively t ;; Use TAB indents within source blocks.
  1390. org-hide-emphasis-markers t ;; Don't show emphasis markup.
  1391. org-src-preserve-indentation t ;; Stop `org-mode' from formatting blocks.
  1392. org-confirm-babel-evaluate nil) ;; Don't ask for confirmation to evaluate blocks.
  1393. ;; Add an `org-mode-hook'.
  1394. (add-hook 'org-mode-hook
  1395. (lambda ()
  1396. (org-indent-mode)
  1397. (visual-line-mode)))
  1398. ;; Remove the `Validate XHTML 1.0' message from HTML export.
  1399. (setq org-export-html-validation-link nil
  1400. org-html-validation-link nil)
  1401. ;; Configure the keywords in the TODO -> DONE sequence.
  1402. (setq org-todo-keywords '((sequence "TODO" "START" "WAIT" "DONE")))
  1403. ;; Track ids globally.
  1404. (setq org-id-track-globally t)
  1405. ;; Configure `org-babel' languages.
  1406. (org-babel-do-load-languages
  1407. 'org-babel-load-languages
  1408. '((C . t)))
  1409. ;; Log / Clock into property drawers.
  1410. (setq org-log-into-drawer t
  1411. org-clock-into-drawer t)
  1412. ;; Encrypt files with the public key.
  1413. (setq epa-file-select-keys 2
  1414. epa-file-encrypt-to "37AB1CB72B741E478CA026D43025DCBD46F81C0F"
  1415. epa-cache-passphrase-for-symmetric-encryption t)
  1416. ;; TODO: Configure default structure templates.
  1417. ;; (require 'org-tempo)
  1418. ;; Apply custom keybindings.
  1419. (dotfiles/leader
  1420. "o" '(:ignore t :which-key "Org")
  1421. "oe" '(org-export-dispatch :which-key "Export")
  1422. "ot" '(org-babel-tangle :which-key "Tangle")
  1423. "oi" '(org-toggle-inline-images :which-key "Images")
  1424. "of" '(:ignore t :which-key "Footnotes")
  1425. "ofn" '(org-footnote-normalize :which-key "Normalize"))
  1426. #+END_SRC
  1427. ** Org Roam
  1428. #+NAME: emacs-org-roam-package
  1429. #+BEGIN_SRC nix
  1430. epkgs.org-roam
  1431. #+END_SRC
  1432. [[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.
  1433. #+NAME: emacs-org-roam-elisp
  1434. #+BEGIN_SRC emacs-lisp
  1435. ;; Setup `org-roam'.
  1436. (require 'org-roam)
  1437. ;; Silence the migration warnings.
  1438. (setq org-roam-v2-ack t)
  1439. ;; Enable `visual-line-mode' in `org-roam' buffer.
  1440. (add-hook 'org-roam-mode-hook
  1441. (lambda ()
  1442. (visual-line-mode +1)))
  1443. ;; Enable completion everywhere.
  1444. (setq org-roam-completion-everywhere t)
  1445. ;; Set the roam directories.
  1446. (setq org-roam-directory (expand-file-name "/etc/dotfiles")
  1447. org-roam-dailies-directory (concat org-roam-directory "/docs/daily"))
  1448. ;; Clear the deafult capture templates.
  1449. (setq org-roam-capture-templates '()
  1450. org-roam-dailies-capture-templates '())
  1451. ;; Override the default slug method.
  1452. (cl-defmethod org-roam-node-slug ((node org-roam-node))
  1453. (let ((title (org-roam-node-title node))
  1454. (slug-trim-chars '(768 ; U+0300 COMBINING GRAVE ACCENT
  1455. 769 ; U+0301 COMBINING ACUTE ACCENT
  1456. 770 ; U+0302 COMBINING CIRCUMFLEX ACCENT
  1457. 771 ; U+0303 COMBINING TILDE
  1458. 772 ; U+0304 COMBINING MACRON
  1459. 774 ; U+0306 COMBINING BREVE
  1460. 775 ; U+0307 COMBINING DOT ABOVE
  1461. 776 ; U+0308 COMBINING DIAERESIS
  1462. 777 ; U+0309 COMBINING HOOK ABOVE
  1463. 778 ; U+030A COMBINING RING ABOVE
  1464. 780 ; U+030C COMBINING CARON
  1465. 795 ; U+031B COMBINING HORN
  1466. 803 ; U+0323 COMBINING DOT BELOW
  1467. 804 ; U+0324 COMBINING DIAERESIS BELOW
  1468. 805 ; U+0325 COMBINING RING BELOW
  1469. 807 ; U+0327 COMBINING CEDILLA
  1470. 813 ; U+032D COMBINING CIRCUMFLEX ACCENT BELOW
  1471. 814 ; U+032E COMBINING BREVE BELOW
  1472. 816 ; U+0330 COMBINING TILDE BELOW
  1473. 817 ; U+0331 COMBINING MACRON BELOW
  1474. )))
  1475. (cl-flet* ((nonspacing-mark-p (char)
  1476. (memq char slug-trim-chars))
  1477. (strip-nonspacing-marks (s)
  1478. (ucs-normalize-NFC-string
  1479. (apply #'string (seq-remove #'nonspacing-mark-p
  1480. (ucs-normalize-NFD-string s)))))
  1481. (cl-replace (title pair)
  1482. (replace-regexp-in-string (car pair) (cdr pair) title)))
  1483. (let* ((pairs `(("[^[:alnum:][:digit:]]" . "-")
  1484. ("--*" . "-")
  1485. ("^-" . "")
  1486. ("-$" . "")))
  1487. (slug (-reduce-from #'cl-replace (strip-nonspacing-marks title) pairs)))
  1488. (downcase slug)))))
  1489. ;; Configure capture templates.
  1490. ;; Standard document.
  1491. (add-to-list 'org-roam-capture-templates
  1492. '("d" "Default" plain "%?"
  1493. :target (file+head "docs/%<%Y%m%d%H%M%S>-${slug}.org.gpg"
  1494. "
  1495. ,#+TITLE: ${title}
  1496. ,#+AUTHOR: Christopher James Hayward
  1497. ,#+EMAIL: chris@chrishayward.xyz
  1498. "
  1499. )
  1500. :unnarrowed t))
  1501. ;; Daily notes.
  1502. (add-to-list 'org-roam-dailies-capture-templates
  1503. '("d" "Default" entry "* %?"
  1504. :target (file+head "%<%Y-%m-%d>.org.gpg"
  1505. "
  1506. ,#+TITLE: %<%Y-%m-%d>
  1507. ,#+AUTHOR: Christopher James Hayward
  1508. ,#+EMAIL: chris@chrishayward.xyz
  1509. ")))
  1510. ;; Apply custom keybindings.
  1511. (dotfiles/leader
  1512. "or" '(:ignore t :which-key "Roam")
  1513. "ori" '(org-roam-node-insert :which-key "Insert")
  1514. "orf" '(org-roam-node-find :which-key "Find")
  1515. "orc" '(org-roam-capture :which-key "Capture")
  1516. "orb" '(org-roam-buffer-toggle :which-key "Buffer"))
  1517. ;; Apply custom keybindings for dailies.
  1518. (dotfiles/leader
  1519. "ord" '(:ignore t :which-key "Dailies")
  1520. "ordd" '(org-roam-dailies-goto-date :which-key "Date")
  1521. "ordt" '(org-roam-dailies-goto-today :which-key "Today")
  1522. "ordm" '(org-roam-dailies-goto-tomorrow :which-key "Tomorrow")
  1523. "ordy" '(org-roam-dailies-goto-yesterday :which-key "Yesterday"))
  1524. ;; Run the setup command.
  1525. (org-roam-setup)
  1526. #+END_SRC
  1527. ** Org Roam UI
  1528. #+NAME: emacs-org-roam-ui-package
  1529. #+BEGIN_SRC nix
  1530. epkgs.org-roam-ui
  1531. epkgs.websocket
  1532. epkgs.simple-httpd
  1533. #+END_SRC
  1534. [[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]].
  1535. #+NAME: emacs-org-roam-ui-elisp
  1536. #+BEGIN_SRC emacs-lisp
  1537. ;; HACK: Set up `org-roam-ui'.
  1538. ;; (add-to-list 'load-path "~/.local/source/org-roam-ui")
  1539. (load-library "org-roam-ui")
  1540. ;; Configure `org-roam-ui'.
  1541. (setq org-roam-ui-follow t
  1542. org-roam-ui-sync-theme t
  1543. org-roam-ui-open-on-start t
  1544. org-roam-ui-update-on-save t
  1545. org-roam-ui-browser-function #'browse-url-firefox)
  1546. ;; Configure keybindings.
  1547. (dotfiles/leader
  1548. "oru" '(:ignore t :which-key "UI")
  1549. "oruu" '(org-roam-ui-mode :which-key "Toggle UI")
  1550. "orut" '(orui-sync-theme :which-key "Sync Theme"))
  1551. #+END_SRC
  1552. ** Org Drill
  1553. #+NAME: emacs-org-drill-package
  1554. #+BEGIN_SRC nix
  1555. epkgs.org-drill
  1556. #+END_SRC
  1557. [[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.
  1558. #+NAME: emacs-org-drill-elisp
  1559. #+BEGIN_SRC emacs-lisp
  1560. ;; Exclude :drill: items from `org-roam'.
  1561. (setq org-roam-db-node-include-function
  1562. (defun dotfiles/org-roam-include ()
  1563. (not (member "drill" (org-get-tags)))))
  1564. ;; Configure keybindings for `org-drill'.
  1565. (dotfiles/leader
  1566. "od" '(:ignore t :which-key "Drill")
  1567. "odd" '(org-drill :which-key "Drill")
  1568. "odc" '(org-drill-cram :which-key "Cram")
  1569. "odr" '(org-drill-resume :which-key "Resume"))
  1570. #+END_SRC
  1571. ** Org Agenda
  1572. 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.
  1573. #+NAME: emacs-org-agenda-elisp
  1574. #+BEGIN_SRC emacs-lisp
  1575. ;; Configure `org-agenda' to use the project files.
  1576. (setq org-agenda-files '("/etc/dotfiles/"
  1577. "/etc/dotfiles/docs/"
  1578. "/etc/dotfiles/docs/daily/"))
  1579. ;; Include files encrypted with `gpg'.
  1580. (require 'org)
  1581. (unless (string-match-p "\\.gpg" org-agenda-file-regexp)
  1582. (setq org-agenda-file-regexp
  1583. (replace-regexp-in-string "\\\\\\.org" "\\\\.org\\\\(\\\\.gpg\\\\)?"
  1584. org-agenda-file-regexp)))
  1585. ;; Open an agenda buffer with SPC o a.
  1586. (dotfiles/leader
  1587. "oa" '(org-agenda :which-key "Agenda"))
  1588. #+END_SRC
  1589. ** Org Pomodoro
  1590. #+NAME: emacs-pomodoro-package
  1591. #+BEGIN_SRC nix
  1592. epkgs.org-pomodoro
  1593. #+END_SRC
  1594. [[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.
  1595. #+NAME: emacs-pomodoro-elisp
  1596. #+BEGIN_SRC emacs-lisp
  1597. ;; Configure `org-pomodor' with the overtime workflow.
  1598. (setq org-pomodoro-manual-break t
  1599. org-pomodoro-keep-killed-time t)
  1600. ;; Configure keybindings.
  1601. (dotfiles/leader
  1602. "op" '(org-pomodoro :which-key "Pomodoro"))
  1603. #+END_SRC
  1604. ** Writegood Mode
  1605. #+NAME: emacs-writegood-package
  1606. #+BEGIN_SRC nix
  1607. epkgs.writegood-mode
  1608. #+END_SRC
  1609. [[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:
  1610. + Weasel Words
  1611. + Passive Voice
  1612. + Duplicate Words
  1613. #+NAME: emacs-writegood-elisp
  1614. #+BEGIN_SRC emacs-lisp
  1615. ;; Configure `writegood-mode'.
  1616. (dotfiles/leader
  1617. "tg" '(writegood-mode :which-key "Grammar"))
  1618. #+END_SRC
  1619. ** Aspell
  1620. #+NAME: emacs-aspell-extras
  1621. #+BEGIN_SRC nix
  1622. pkgs.aspell
  1623. pkgs.aspellDicts.en
  1624. pkgs.aspellDicts.en-science
  1625. pkgs.aspellDicts.en-computers
  1626. #+END_SRC
  1627. [[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.
  1628. #+NAME: emacs-aspell-elisp
  1629. #+BEGIN_SRC emacs-lisp
  1630. ;; Use `aspell' as a drop-in replacement for `ispell'.
  1631. (setq ispell-program-name "aspell"
  1632. ispell-eextra-args '("--sug-mode=fast"))
  1633. ;; Configure the built-in `flyspell-mode'.
  1634. (dotfiles/leader
  1635. "ts" '(flyspell-mode :which-key "Spelling"))
  1636. #+END_SRC
  1637. ** TexLive
  1638. [[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/:
  1639. | Name | Derivation | Comment |
  1640. |---------+---------------------------------+------------------------------------------------------------|
  1641. | Full | texlive.combined.scheme-full | Contains every TeX Live package |
  1642. | Medium | texlive.combined.scheme-medium | Contains everything in small + more packages and languages |
  1643. | Small | texlive.combined.scheme-small | Contains everything in basic + xetex + metapost |
  1644. | Basic | texlive.combined.scheme-basic | Contains everything in the plain scheme but includes latex |
  1645. | Minimal | texlive.combined.scheme-minimal | Contains plain only |
  1646. #+NAME: emacs-texlive-extras
  1647. #+BEGIN_SRC nix
  1648. # pkgs.texlive.combined.scheme-full
  1649. #+END_SRC
  1650. ** Http
  1651. #+NAME: emacs-http-package
  1652. #+BEGIN_SRC nix
  1653. epkgs.ob-http
  1654. #+END_SRC
  1655. 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.
  1656. #+NAME: emacs-http-elisp
  1657. #+BEGIN_SRC emacs-lisp
  1658. ;; Required to setup `ob-http'.
  1659. (org-babel-do-load-languages
  1660. 'org-babel-load-languages
  1661. '((http . t)))
  1662. #+END_SRC
  1663. ** Hugo
  1664. #+NAME: emacs-hugo-package
  1665. #+BEGIN_SRC nix
  1666. epkgs.ox-hugo
  1667. #+END_SRC
  1668. [[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/.
  1669. #+NAME: emacs-hugo-elisp
  1670. #+BEGIN_SRC emacs-lisp
  1671. ;; Configure `ox-hugo' as an `org-mode-export' backend.
  1672. (require 'ox-hugo)
  1673. ;; Set up the base directory.
  1674. (setq org-hugo-base-dir (expand-file-name "/etc/dotfiles/docs"))
  1675. ;; Capture templates.
  1676. ;; Shared content
  1677. ;; (add-to-list 'org-roam-capture-templates
  1678. ;; '("p" "Post" plain "%?"
  1679. ;; :target (file+head "docs/posts/${slug}.org.gpg"
  1680. ;; "
  1681. ;; ,#+TITLE: ${title}
  1682. ;; ,#+AUTHOR: Christopher James Hayward
  1683. ;; ,#+DATE: %<%Y-%m-%d>
  1684. ;; ,#+EXPORT_FILE_NAME: ${slug}
  1685. ;; ,#+OPTIONS: num:nil todo:nil tasks:nil
  1686. ;; ,#+ROAM_KEY: https://chrishayward.xyz/posts/${slug}/
  1687. ;; ,#+HUGO_BASE_DIR: ../
  1688. ;; ,#+HUGO_AUTO_SET_LASTMOD: t
  1689. ;; ,#+HUGO_SECTION: posts
  1690. ;; ,#+HUGO_DRAFT: true
  1691. ;; "
  1692. ;; )
  1693. ;; :unnarrowed t))
  1694. #+END_SRC
  1695. ** Passwords
  1696. #+NAME: emacs-pass-extras
  1697. #+BEGIN_SRC nix
  1698. pkgs.pass
  1699. #+END_SRC
  1700. 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.
  1701. #+NAME: emacs-pass-package
  1702. #+BEGIN_SRC nix
  1703. epkgs.password-store
  1704. #+END_SRC
  1705. Configure keybindings for passwords behind =SPC p=:
  1706. #+NAME: emacs-pass-elisp
  1707. #+BEGIN_SRC emacs-lisp
  1708. ;; Set the path to the password store.
  1709. (setq password-store-dir (expand-file-name "~/.password-store"))
  1710. ;; Apply custom keybindings.
  1711. (dotfiles/leader
  1712. "p" '(:ignore t :which-key "Passwords")
  1713. "pp" '(password-store-copy :which-key "Copy")
  1714. "pe" '(password-store-edit :which-key "Edit")
  1715. "pi" '(password-store-insert :which-key "Insert")
  1716. "pr" '(password-store-rename :which-key "Rename")
  1717. "pg" '(password-store-generate :which-key "Generate"))
  1718. #+END_SRC
  1719. ** Docker
  1720. #+NAME: emacs-docker-package
  1721. #+BEGIN_SRC nix
  1722. epkgs.docker
  1723. epkgs.dockerfile-mode
  1724. #+END_SRC
  1725. 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.
  1726. #+NAME: emacs-docker-elisp
  1727. #+BEGIN_SRC emacs-lisp
  1728. ;; Apply custom keybindings.
  1729. (dotfiles/leader
  1730. "n" '(:ignore t :which-key "Containers")
  1731. "nd" '(docker :which-key "Docker"))
  1732. #+END_SRC
  1733. ** MU4E
  1734. #+NAME: emacs-mu4e-extras
  1735. #+BEGIN_SRC nix
  1736. pkgs.mu
  1737. pkgs.isync
  1738. (pkgs.writeShellScriptBin "mail-init" ''
  1739. ${pkgs.mu} init --maildir="~/.cache/mail" --my-address="chris@chrishayward.xyz"
  1740. ${pkgs.mu} index
  1741. '')
  1742. (pkgs.writeShellScriptBin "mail-sync" ''
  1743. ${pkgs.isync}/bin/mbsync -a
  1744. '')
  1745. #+END_SRC
  1746. [[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.
  1747. #+NAME: emacs-mu4e-package
  1748. #+BEGIN_SRC nix
  1749. epkgs.mu4e-alert
  1750. #+END_SRC
  1751. [[https://emacswiki.org/emacs/mu4e][MU4E]] is an email client for Emacs. It's based on the mu email indexer / searcher.
  1752. + Fully search based: no folders, only queries
  1753. + Fully documented, with example configurations
  1754. + User-interface optimized for speed, with quick keystrokes for common actions
  1755. + Asynchronous; heavy actions do not block Emacs
  1756. + Support for non-English languages
  1757. + Support for signing and encryption
  1758. + Address auto-completion based on existing messages
  1759. + Extensibile with existing code and snippets
  1760. #+NAME: emacs-mu4e-config
  1761. #+BEGIN_SRC nix
  1762. # Deploy the authinfo file.
  1763. home.file.".authinfo.gpg".source = ../config/authinfo.gpg;
  1764. # Deploy the isync configuration file.
  1765. home.file.".mbsyncrc" = {
  1766. text = ''
  1767. IMAPStore xyz-remote
  1768. Host mail.chrishayward.xyz
  1769. User chris@chrishayward.xyz
  1770. PassCmd "pass chrishayward.xyz/chris"
  1771. SSLType IMAPS
  1772. MaildirStore xyz-local
  1773. Path ~/.cache/mail/
  1774. Inbox ~/.cache/mail/inbox
  1775. SubFolders Verbatim
  1776. Channel xyz
  1777. Far :xyz-remote:
  1778. Near :xyz-local:
  1779. Patterns * !Archives
  1780. Create Both
  1781. Expunge Both
  1782. SyncState *
  1783. '';
  1784. };
  1785. #+END_SRC
  1786. 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.
  1787. #+NAME: emacs-mu4e-elisp
  1788. #+BEGIN_SRC emacs-lisp
  1789. ;; Add the `mu4e' shipped with `mu' to the load path.
  1790. (add-to-list 'load-path "/etc/profiles/per-user/chris/share/emacs/site-lisp/mu4e/")
  1791. (require 'mu4e)
  1792. ;; Confiugure `mu4e'.
  1793. (setq mu4e-maildir "~/.cache/mail"
  1794. mu4e-update-interval (* 5 60)
  1795. mu4e-get-mail-command "mail-sync"
  1796. mu4e-compose-format-flowed t
  1797. mu4e-change-filenames-when-moving t
  1798. mu4e-compose-signature (concat "Chris Hayward\n"
  1799. "chris@chrishayward.xyz"))
  1800. ;; Sign all outbound email with GPG.
  1801. (add-hook 'message-send-hook 'mml-secure-message-sign-pgpmime)
  1802. (setq message-send-mail-function 'smtpmail-send-it
  1803. mml-secure-openpgp-signers '("37AB1CB72B741E478CA026D43025DCBD46F81C0F"))
  1804. ;; Setup `mu4e' accounts.
  1805. (setq mu4e-contexts
  1806. (list
  1807. ;; Main
  1808. ;; chris@chrishayward.xyz
  1809. (make-mu4e-context
  1810. :name "Main"
  1811. :match-func
  1812. (lambda (msg)
  1813. (when msg
  1814. (string-prefix-p "/Main" (mu4e-message-field msg :maildir))))
  1815. :vars
  1816. '((user-full-name . "Christopher James Hayward")
  1817. (user-mail-address . "chris@chrishayward.xyz")
  1818. (smtpmail-smtp-server . "mail.chrishayward.xyz")
  1819. (smtpmail-smtp-service . 587)
  1820. (smtpmail-stream-type . starttls)))))
  1821. ;; Setup `mu4e-alert'.
  1822. (setq mu4e-alert-set-default-style 'libnotify)
  1823. (mu4e-alert-enable-notifications)
  1824. (mu4e-alert-enable-mode-line-display)
  1825. ;; Open the `mu4e' dashboard.
  1826. (dotfiles/leader
  1827. "m" '(mu4e :which-key "Mail"))
  1828. #+END_SRC
  1829. ** Projectile
  1830. #+NAME: emacs-projectile-package
  1831. #+BEGIN_SRC nix
  1832. epkgs.projectile
  1833. #+END_SRC
  1834. [[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.
  1835. #+NAME: emacs-projectile-elisp
  1836. #+BEGIN_SRC emacs-lisp
  1837. ;; Configure the `projectile-project-search-path'.
  1838. (setq projectile-project-search-path '("~/.local/source"))
  1839. (projectile-mode +1)
  1840. #+END_SRC
  1841. ** LSP Mode
  1842. #+NAME: emacs-lsp-package
  1843. #+BEGIN_SRC nix
  1844. epkgs.lsp-mode
  1845. epkgs.lsp-ui
  1846. #+END_SRC
  1847. 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:
  1848. + Auto Complete
  1849. + Go To Defintion
  1850. + Find All References
  1851. #+NAME: emacs-lsp-elisp
  1852. #+BEGIN_SRC emacs-lisp
  1853. ;; Configure `lsp-mode'.
  1854. (setq lsp-idle-delay 0.5
  1855. lsp-prefer-flymake t)
  1856. ;; Configure `lsp-ui'.
  1857. (setq lsp-ui-doc-position 'at-point
  1858. lsp-ui-doc-delay 0.5)
  1859. ;; Add custom keybindings for `lsp'.
  1860. (dotfiles/leader
  1861. "l" '(:ignore t :which-key "LSP")
  1862. "ll" '(lsp :which-key "LSP"))
  1863. #+END_SRC
  1864. ** CCLS
  1865. #+NAME: emacs-ccls-package
  1866. #+BEGIN_SRC nix
  1867. epkgs.ccls
  1868. #+END_SRC
  1869. [[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.
  1870. #+NAME: emacs-ccls-elisp
  1871. #+BEGIN_SRC emacs-lisp
  1872. ;; Configure `ccls' to work with `lsp-mode'.
  1873. (defun dotfiles/ccls-hook ()
  1874. (require 'ccls)
  1875. (lsp))
  1876. ;; Configure `ccls' mode hooks.
  1877. (add-hook 'c-mode-hook 'dotfiles/ccls-hook)
  1878. (add-hook 'c++-mode-hook 'dotfiles/ccls-hook)
  1879. (add-hook 'objc-mode-hook 'dotfiles/ccls-hook)
  1880. (add-hook 'cuda-mode-hook 'dotfiles/ccls-hook)
  1881. #+END_SRC
  1882. ** Company Mode
  1883. #+NAME: emacs-company-package
  1884. #+BEGIN_SRC nix
  1885. epkgs.company
  1886. #+END_SRC
  1887. [[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.
  1888. #+NAME: emacs-company-elisp
  1889. #+BEGIN_SRC emacs-lisp
  1890. ;; Configure `company-mode'.
  1891. (setq company-backend 'company-capf
  1892. lsp-completion-provider :capf)
  1893. ;; Enable it globally.
  1894. (global-company-mode +1)
  1895. #+END_SRC
  1896. ** GDScript Mode
  1897. #+NAME: emacs-gdscript-package
  1898. #+BEGIN_SRC nix
  1899. epkgs.gdscript-mode
  1900. #+END_SRC
  1901. https://github.com/godotengine/emacs-gdscript-mode is an Emacs package to get GDScript support and syntax highlighting. Some of its features include:
  1902. + Syntax highlighting
  1903. + Code folding
  1904. + Debugger support
  1905. + Support for scenes and script files
  1906. + Comment wrapping
  1907. + Indentation
  1908. + Automatic parsing
  1909. + Code formatting
  1910. #+NAME: emacs-gdscript-elisp
  1911. #+BEGIN_SRC emacs-lisp
  1912. (require 'gdscript-mode)
  1913. ;; Silence lsp warnings for gdscript.
  1914. (defun lsp--gdscript-ignore-errors (original-function &rest args)
  1915. "Ignore the error message resulting from Godot not replying to the `JSONRPC' request."
  1916. (if (string-equal major-mode "gdscript-mode")
  1917. (let ((json-data (nth 0 args)))
  1918. (if (and (string= (gethash "jsonrpc" json-data "") "2.0")
  1919. (not (gethash "id" json-data nil))
  1920. (not (gethash "method" json-data nil)))
  1921. nil; (message "Method not found")
  1922. (apply original-function args)))
  1923. (apply original-function args)))
  1924. ;; Run the function around `lsp--get-message-type' to suppress warnings.
  1925. (advice-add #'lsp--get-message-type :around #'lsp--gdscript-ignore-errors)
  1926. ;; Add custom keybinds.
  1927. (dotfiles/leader
  1928. "lg" '(gdscript-hydra-show :which-key "GDScript"))
  1929. #+END_SRC
  1930. ** Go Mode
  1931. #+NAME: emacs-golang-package
  1932. #+BEGIN_SRC nix
  1933. epkgs.go-mode
  1934. #+END_SRC
  1935. [[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.
  1936. #+NAME: emacs-golang-elisp
  1937. #+BEGIN_SRC emacs-lisp
  1938. ;; Configure `go-mode' to work with `lsp-mode'.
  1939. (defun dotfiles/go-hook ()
  1940. (add-hook 'before-save-hook #'lsp-format-buffer t t)
  1941. (add-hook 'before-save-hook #'lsp-organize-imports t t))
  1942. ;; Configure a custom `before-save-hook'.
  1943. (add-hook 'go-mode-hook #'dotfiles/go-hook)
  1944. #+END_SRC
  1945. ** Rustic
  1946. #+NAME: emacs-rustic-package
  1947. #+BEGIN_SRC nix
  1948. epkgs.rustic
  1949. #+END_SRC
  1950. 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!
  1951. #+NAME: emacs-rustic-elisp
  1952. #+BEGIN_SRC emacs-lisp
  1953. ;; Configure `rustic' with `lsp-mode'.
  1954. (setq rustic-format-on-save t
  1955. rustic-lsp-server 'rls)
  1956. #+END_SRC
  1957. ** Python Mode
  1958. #+NAME: emacs-python-package
  1959. #+BEGIN_SRC nix
  1960. epkgs.pretty-mode
  1961. #+END_SRC
  1962. 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.
  1963. #+NAME: emacs-python-elisp
  1964. #+BEGIN_SRC emacs-lisp
  1965. ;; Configure `pretty-mode' to work with `python-mode'.
  1966. (add-hook 'python-mode-hook
  1967. (lambda ()
  1968. (turn-on-pretty-mode)))
  1969. #+END_SRC
  1970. ** Protobuf Mode
  1971. #+NAME: emacs-protobuf-package
  1972. #+BEGIN_SRC nix
  1973. epkgs.protobuf-mode
  1974. #+END_SRC
  1975. ** Typescript Mode
  1976. #+NAME: emacs-typescript-package
  1977. #+BEGIN_SRC nix
  1978. epkgs.typescript-mode
  1979. #+END_SRC
  1980. ** Clojure Environment
  1981. #+NAME: emacs-clojure-package
  1982. #+BEGIN_SRC nix
  1983. epkgs.clojure-mode
  1984. epkgs.cider
  1985. #+END_SRC
  1986. [[https://github.com/clojure-emacs/clojure-mode][Clojure Mode]] is an Emacs major mode that provides font-lock (syntax highlighting), indentation, navigation, and refactoring support for the [[https://clojure.org][Clojure]] programming language. [[https://github.com/clojure-emacs/cider][Cider]] extends Emacs with support for interactive programming in Clojure. The features are centered around =cider-mode=, adding a running process for compilation, code completion, debugging, definition and documentation lookup, running tests, and more.
  1987. #+NAME: emacs-clojure-elisp
  1988. #+BEGIN_SRC emacs-lisp
  1989. ;; Configure `clojure-mode' and `cider'.
  1990. (add-hook 'clojure-mode-hook 'lsp)
  1991. (add-hook 'clojurescript-mode-hook 'lsp)
  1992. (add-hook 'clojurec-mode-hook 'lso)
  1993. #+END_SRC
  1994. ** PlantUML
  1995. #+NAME: emacs-plantuml-extras
  1996. #+BEGIN_SRC nix
  1997. pkgs.plantuml
  1998. #+END_SRC
  1999. [[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.
  2000. #+NAME: emacs-plantuml-package
  2001. #+BEGIN_SRC nix
  2002. epkgs.plantuml-mode
  2003. #+END_SRC
  2004. [[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]].
  2005. #+NAME: emacs-plantuml-elisp
  2006. #+BEGIN_SRC emacs-lisp
  2007. ;; Configure `plantuml-mode'.
  2008. (add-to-list 'org-src-lang-modes '("plantuml" . plantuml))
  2009. (org-babel-do-load-languages 'org-babel-load-languages '((plantuml . t)))
  2010. (setq plantuml-default-exec-mode 'executable
  2011. org-plantuml-exec-mode 'plantuml)
  2012. #+END_SRC
  2013. ** Swiper
  2014. #+NAME: emacs-swiper-package
  2015. #+BEGIN_SRC nix
  2016. epkgs.ivy
  2017. epkgs.counsel
  2018. epkgs.ivy-rich
  2019. epkgs.ivy-posframe
  2020. epkgs.ivy-prescient
  2021. #+END_SRC
  2022. [[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.
  2023. #+NAME: emacs-swiper-elisp
  2024. #+BEGIN_SRC emacs-lisp
  2025. ;; Configure `ivy'.
  2026. (setq counsel-linux-app-format-function
  2027. #'counsel-linux-app-format-function-name-only)
  2028. (ivy-mode +1)
  2029. (counsel-mode +1)
  2030. ;; Configure `ivy-rich'.
  2031. (ivy-rich-mode +1)
  2032. ;; Configure `ivy-posframe'.
  2033. (setq ivy-posframe-parameters '((parent-frame nil))
  2034. ivy-posframe-display-functions-alist '((t . ivy-posframe-display)))
  2035. (ivy-posframe-mode +1)
  2036. ;; Configure `ivy-prescient'.
  2037. (setq ivy-prescient-enable-filtering nil)
  2038. (ivy-prescient-mode +1)
  2039. #+END_SRC
  2040. ** Transparency
  2041. 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.
  2042. #+NAME: emacs-transparency-elisp
  2043. #+BEGIN_SRC emacs-lisp
  2044. ;; Configure the default frame transparency.
  2045. (set-frame-parameter (selected-frame) 'alpha '(95 . 95))
  2046. (add-to-list 'default-frame-alist '(alpha . (95 . 95)))
  2047. #+END_SRC
  2048. ** Desktop Environment
  2049. #+NAME: emacs-desktop-extras
  2050. #+BEGIN_SRC nix
  2051. pkgs.brightnessctl
  2052. #+END_SRC
  2053. 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]].
  2054. #+NAME: emacs-desktop-package
  2055. #+BEGIN_SRC nix
  2056. epkgs.desktop-environment
  2057. #+END_SRC
  2058. 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.
  2059. #+NAME: emacs-desktop-elisp
  2060. #+BEGIN_SRC emacs-lisp
  2061. ;; Configure `desktop-environment'.
  2062. (require 'desktop-environment)
  2063. (desktop-environment-mode +1)
  2064. #+END_SRC
  2065. ** Doom Themes
  2066. #+NAME: emacs-doom-themes-package
  2067. #+BEGIN_SRC nix
  2068. epkgs.doom-themes
  2069. #+END_SRC
  2070. [[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.
  2071. #+NAME: emacs-doom-themes-elisp
  2072. #+BEGIN_SRC emacs-lisp
  2073. ;; Include modern themes from `doom-themes'.
  2074. (setq doom-themes-enable-bold t
  2075. doom-themes-enable-italic t)
  2076. ;; Load the `doom-nord' and `doom-nord-light' themes.
  2077. ;; (load-theme 'doom-nord-light t)
  2078. (load-theme 'doom-nord t)
  2079. ;; Define a method for returning information about the current theme.
  2080. ;; This is based off the function `org-roam-ui-get-theme'.
  2081. (defun dotfiles/theme ()
  2082. "Return information about the current theme."
  2083. (list `(bg . ,(face-background hl-line-face))
  2084. `(bg-alt . ,(face-background 'default))
  2085. `(fg . ,(face-foreground 'default))
  2086. `(fg-alt . ,(face-foreground font-lock-comment-face))
  2087. `(red . ,(face-foreground 'error))
  2088. `(orange . ,(face-foreground 'warning))
  2089. `(yellow . ,(face-foreground font-lock-builtin-face))
  2090. `(green . ,(face-foreground 'success))
  2091. `(cyan . ,(face-foreground font-lock-constant-face))
  2092. `(blue . ,(face-foreground font-lock-keyword-face))
  2093. `(violet . ,(face-foreground font-lock-constant-face))
  2094. `(magenta . ,(face-foreground font-lock-preprocessor-face))))
  2095. ;; Load a new theme with <SPC> t t.
  2096. (dotfiles/leader
  2097. "tt" '(counsel-load-theme :which-key "Theme"))
  2098. #+END_SRC
  2099. Create a shell command that returns a JSON string of the current theme in the following format:
  2100. #+BEGIN_SRC json
  2101. {
  2102. "bg": "#272C36",
  2103. "bg-alt": "#2E3440",
  2104. "fg": "#ECEFF4",
  2105. "fg-alt": "#6f7787",
  2106. "red": "#BF616A",
  2107. "orange": "#EBCB8B",
  2108. "yellow": "#81A1C1",
  2109. "green": "#A3BE8C",
  2110. "cyan": "#81A1C1",
  2111. "blue": "#81A1C1",
  2112. "violet": "#81A1C1",
  2113. "magenta": "#81A1C1"
  2114. }
  2115. #+END_SRC
  2116. #+NAME: emacs-doom-themes-extras
  2117. #+BEGIN_SRC nix
  2118. (pkgs.writeShellScriptBin "dotfiles-theme" ''
  2119. ${myEmacs}/bin/emacsclient --no-wait --eval '(json-encode (dotfiles/theme))' | sed "s/\\\\//g" | sed -e 's/^"//' -e 's/"$//'
  2120. '')
  2121. #+END_SRC
  2122. ** Doom Modeline
  2123. #+NAME: emacs-doom-modeline-package
  2124. #+BEGIN_SRC nix
  2125. epkgs.doom-modeline
  2126. #+END_SRC
  2127. [[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.
  2128. #+NAME: emacs-doom-modeline-elisp
  2129. #+BEGIN_SRC emacs-lisp
  2130. ;; Configure `doom-modeline'.
  2131. (require 'doom-modeline)
  2132. (setq doom-modeline-height 16
  2133. doom-modeline-icon t)
  2134. ;; Launch after initialization.
  2135. (add-hook 'after-init-hook 'doom-modeline-mode)
  2136. ;; Define a modeline segment to show the workspace information.
  2137. (doom-modeline-def-segment dotfiles/workspaces
  2138. (exwm-workspace--update-switch-history)
  2139. (concat
  2140. (doom-modeline-spc)
  2141. (elt (let* ((num (exwm-workspace--count))
  2142. (sequence (number-sequence 0 (1- num)))
  2143. (not-empty (make-vector num nil)))
  2144. (dolist (i exwm--id-buffer-alist)
  2145. (with-current-buffer (cdr i)
  2146. (when exwm--frame
  2147. (setf (aref not-empty
  2148. (exwm-workspace--position exwm--frame))
  2149. t))))
  2150. (mapcar
  2151. (lambda (i)
  2152. (mapconcat
  2153. (lambda (j)
  2154. (format (if (= i j) "[%s]" " %s ")
  2155. (propertize
  2156. (apply exwm-workspace-index-map (list j))
  2157. 'face
  2158. (cond ((frame-parameter (elt exwm-workspace--list j)
  2159. 'exwm-urgency)
  2160. '(:inherit warning :weight bold))
  2161. ((= i j) '(:inherit underline :weight bold))
  2162. ((aref not-empty j) '(:inherit success :weight bold))
  2163. (t `((:foreground ,(face-foreground 'mode-line-inactive))))))))
  2164. sequence ""))
  2165. sequence))
  2166. (exwm-workspace--position (selected-frame)))))
  2167. ;; Define a custom modeline to override the default.
  2168. (doom-modeline-def-modeline 'dotfiles/modeline
  2169. '(bar workspace-name dotfiles/workspaces window-number modals matches buffer-info remote-host buffer-position word-count parrot selection-info)
  2170. '(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))
  2171. ;; Define a method to load the modeline.
  2172. (defun dotfiles/load-modeline ()
  2173. "Load the default modeline."
  2174. (doom-modeline-set-modeline 'dotfiles/modeline 'default))
  2175. ;; Enable `doom-modeline'.
  2176. (add-hook 'doom-modeline-mode-hook 'dotfiles/load-modeline)
  2177. (doom-modeline-mode +1)
  2178. (doom-modeline-set-modeline 'dotfiles/modeline 'default)
  2179. #+END_SRC
  2180. * Website Configuration
  2181. #+ATTR_ORG: :width 800px
  2182. #+ATTR_HTML: :width 800px
  2183. #+ATTR_LATEX: :width 800px
  2184. [[./docs/images/website.png]]
  2185. 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.
  2186. #+BEGIN_SRC conf :noweb yes :tangle docs/config.toml
  2187. # <<file-warning>>
  2188. title = "Chris Hayward"
  2189. copyright = "Licensed under Attribution 4.0 International (CC BY 4.0)"
  2190. baseURL = "https://chrishayward.xyz/"
  2191. theme = "hello-friend-ng"
  2192. languageCode = "en-us"
  2193. defaultContentLanguage = "en"
  2194. pygmentsCodefences = true
  2195. pygmentsUseClasses = true
  2196. <<website-params>>
  2197. <<website-privacy>>
  2198. <<website-layout>>
  2199. #+END_SRC
  2200. ** Params
  2201. 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.
  2202. #+NAME: website-params
  2203. #+BEGIN_SRC conf
  2204. [params]
  2205. dateform = "Jan 2, 2006"
  2206. dateformShort = "Jan 2"
  2207. dateformNum = "2006-01-02"
  2208. dateformNumTime = "2006-01-02 15:04 -0700"
  2209. authorName = "Christopher James Hayward"
  2210. homeSubtitle = "Airplanes, Linux, and Metalcore"
  2211. footerCopyright = ' &#183; <a href="http://creativecommons.org/licenses/by/4.0/" target="_blank" rel="noopener">CC BY 4.0</a>'
  2212. [[params.social]]
  2213. name = "paypal"
  2214. url = "https://paypal.me/chrishaywardxyz"
  2215. [[params.social]]
  2216. name = "github"
  2217. url = "https://github.com/chayward1/"
  2218. [[params.social]]
  2219. name = "gitlab"
  2220. url = "https://gitlab.com/chayward1/"
  2221. [[params.social]]
  2222. name = "email"
  2223. url = "mailto:chris@chrishayward.xyz"
  2224. #+END_SRC
  2225. ** Privacy
  2226. 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.
  2227. #+NAME: website-privacy
  2228. #+BEGIN_SRC conf
  2229. [privacy]
  2230. [privacy.disqus]
  2231. disable = true
  2232. [privacy.googleAnalytics]
  2233. disable = true
  2234. [privacy.instagram]
  2235. disable = true
  2236. [privacy.twitter]
  2237. disable = true
  2238. [privacy.vimeo]
  2239. disable = true
  2240. [privacy.youtube]
  2241. disable = true
  2242. #+END_SRC
  2243. ** Layout
  2244. 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.
  2245. #+NAME: website-layout
  2246. #+BEGIN_SRC conf
  2247. [menu]
  2248. [[menu.main]]
  2249. identifier = "cloud"
  2250. name = "Cloud"
  2251. url = "https://cloud.chrishayward.xyz"
  2252. [[menu.main]]
  2253. identifier = "dotfiles"
  2254. name = "Dotfiles"
  2255. url = "/dotfiles"
  2256. [[menu.main]]
  2257. identifier = "projects"
  2258. name = "Projects"
  2259. url = "https://git.chrishayward.xyz"
  2260. #+END_SRC
  2261. * Footnotes