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.

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