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.

2917 lines
93 KiB

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