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.

2897 lines
94 KiB

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