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.

2260 lines
66 KiB

4 years ago
4 years ago
4 years ago
4 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
4 years ago
3 years ago
  1. #+TITLE: Dotfiles
  2. #+AUTHOR: Christopher James Hayward
  3. #+EMAIL: chris@chrishayward.xyz
  4. #+EXPORT_FILE_NAME: dotfiles
  5. #+ROAM_KEY: https://chrishayward.xyz/dotfiles
  6. #+HUGO_BASE_DIR: docs
  7. #+HUGO_AUTO_SET_LASTMOD: t
  8. #+HUGO_SECTION:
  9. #+HUGO_DRAFT: false
  10. #+NAME: description
  11. #+BEGIN_SRC text
  12. Immutable NixOS dotfiles.
  13. #+END_SRC
  14. Built for Life, Liberty, and the Open Road.
  15. + 100% Immutable
  16. + 100% Declarative
  17. + 100% Reproducible
  18. * Introduction
  19. This is my personal configuration(s) for GNU/Linux[fn:1] systems. It enables a consistent experience and computing environment across all of my machines. This project is written with GNU/Emacs[fn:2], leveraging its capabilities for Literate Programming[fn:3], a technique where programs are written in a natural language, such as English, interspersed with snippets of code to describe a software project.
  20. #+NAME: file-warning
  21. #+BEGIN_SRC text
  22. This file is controlled by /etc/dotfiles/README.org
  23. #+END_SRC
  24. ** Getting Started
  25. 1) Download the latest version of NixOS https://nixos.org/download.html
  26. 2) Partition drives and mount the file system https://nixos.org/manual/nixos/stable/#sec-installation-partitioning
  27. 3) Clone the project to =/mnt/etc/dotfiles= ~git clone git@git.chrishayward.xyz:chris/dotfiles /mnt/etc/dotfiles~
  28. 4) Load the default shell environment ~nix-shell /mnt/etc/dotfiles~
  29. 5) Install the default system ~sudo nixos-install --flake /mnt/etc/dotfiles#nixos~
  30. 6) Reboot and login, start a graphical system with ~startx~
  31. ** Making Changes
  32. 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:
  33. + switch :: Build and activate the new configuration, making it the new boot default
  34. + boot :: Build the new configuration and make it the boot default, without activation
  35. + test :: Build and activate the new configuration, without adding it to the boot menu
  36. + build :: Build the new configuration, without activation, nor adding it to the boot menu
  37. + build-vm :: Build a script that starts a virtual machine with the desired configuration
  38. #+BEGIN_SRC shell
  39. # Build and activate a new configuration.
  40. sudo nixos-rebuild switch --flake $FLAKE#$HOSTNAME
  41. #+END_SRC
  42. 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.
  43. #+BEGIN_SRC shell
  44. # Rollback to the previous generation.
  45. sudo nixos-rebuild switch --rollback
  46. #+END_SRC
  47. ** Docker Container
  48. It's possible to use parts of this configuration using the 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.
  49. #+BEGIN_SRC conf :tangle Dockerfile
  50. # Derive from the official image.
  51. FROM nixos/nix
  52. # Add the unstable channel.
  53. RUN nix-channel --add https://nixos.org/channels/nixpkgs-unstable nixpkgs
  54. RUN nix-channel --update
  55. # Setup the default environment.
  56. WORKDIR /etc/dotfiles
  57. COPY . .
  58. # Load the default system shell.
  59. RUN nix-shell /etc/dotfiles
  60. #+END_SRC
  61. * Operating System
  62. NixOS[fn:4] is a purely functional Linux distribution built on top of the Nix[fn:5] package manager. It uses a declarative configuration language to define entire computer systems, and allows reliable system upgrades and rollbacks. NixOS[fn:4] also has tool dedicated to DevOps and deployment tasks, and makes it trivial to share development environments.
  63. #+BEGIN_SRC nix :noweb yes :tangle flake.nix
  64. # <<file-warning>>
  65. {
  66. description = "<<description>>";
  67. inputs = {
  68. <<os-nixpkgs>>
  69. <<os-home-manager>>
  70. <<os-emacs-overlay>>
  71. <<os-nixos-hardware>>
  72. };
  73. outputs = inputs @ { self, nixpkgs, nixpkgs-unstable, ... }: {
  74. nixosConfigurations = {
  75. <<host-default>>
  76. <<host-acernitro>>
  77. };
  78. };
  79. }
  80. #+END_SRC
  81. ** Nixpkgs
  82. Nixpkgs[fn:6] is a collection of over 60,000 software packages that can be installed with the Nix[fn:5] package manager. Two main branches are offered:
  83. 1) The current stable release
  84. 2) The Unstable branch following the latest development
  85. #+NAME: os-nixpkgs
  86. #+BEGIN_SRC nix
  87. nixpkgs.url = "nixpkgs/nixos-unstable";
  88. nixpkgs-unstable.url = "nixpkgs/master";
  89. #+END_SRC
  90. ** Home Manager
  91. Home Manager[fn:7] provides a basic system for managing user environments using the Nix[fn:5] package manager together with the Nix libraries found in Nixpkgs[fn:6]. It allows declarative configuration of user specific (non-global) packages and files.
  92. #+NAME: os-home-manager
  93. #+BEGIN_SRC nix
  94. home-manager.url = "github:nix-community/home-manager";
  95. home-manager.inputs.nixpkgs.follows = "nixpkgs";
  96. #+END_SRC
  97. ** Emacs Overlay
  98. Adding the Emacs Overlay[fn:8] extends the GNU/Emacs[fn:2] package set to contain the latest versions, and daily generations from popular package sources, including the needed dependencies to run GNU/Emacs[fn:2] as a Window Manager.
  99. #+NAME: os-emacs-overlay
  100. #+BEGIN_SRC nix
  101. emacs-overlay.url = "github:nix-community/emacs-overlay";
  102. #+END_SRC
  103. ** NixOS Hardware
  104. NixOS Hardware[fn:9] is a collection of NixOS[fn:4] 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.
  105. #+NAME: os-nixos-hardware
  106. #+BEGIN_SRC nix
  107. nixos-hardware.url = "github:nixos/nixos-hardware";
  108. #+END_SRC
  109. * Host Configurations
  110. NixOS[fn:4] 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.
  111. ** Default
  112. The default host, built using QEMU[fn:10], a free and open-source emulator that can perform hardware virtualization. It features a lightweight system optimized for development, running GNU/Emacs[fn:2] + EXWM[fn:11] as the graphical environment.
  113. #+NAME: host-default
  114. #+BEGIN_SRC nix :noweb yes
  115. nixos = nixpkgs.lib.nixosSystem {
  116. system = "x86_64-linux";
  117. specialArgs = { inherit inputs; };
  118. modules = [
  119. ./hosts/nixos
  120. <<module-x11>>
  121. <<module-flakes>>
  122. <<module-cachix>>
  123. <<module-home-manager>>
  124. ];
  125. };
  126. #+END_SRC
  127. Deploy this configuration with ~nixos-rebuild switch --flake /etc/dotfiles/#nixos~.
  128. #+BEGIN_SRC nix :noweb yes :tangle hosts/nixos/default.nix
  129. # <<file-warning>>
  130. { ... }:
  131. {
  132. imports = [
  133. ./configuration.nix
  134. ./hardware.nix
  135. ];
  136. }
  137. #+END_SRC
  138. *** Configuration
  139. This is a basic default configuration that specified the indended default configuration of the system. Because NixOS[fn:4] has a declarative configuration model, you can create or edit a description of the desired configuration, and update it from one file.
  140. #+BEGIN_SRC nix :noweb yes :tangle hosts/nixos/configuration.nix
  141. # <<file-warning>>
  142. { config, pkgs, inputs, ... }:
  143. {
  144. boot.loader.grub.enable = true;
  145. boot.loader.grub.version = 2;
  146. boot.loader.grub.device = "/dev/sda";
  147. time.timeZone = "America/Toronto";
  148. networking.hostName = "nixos";
  149. networking.useDHCP = false;
  150. networking.firewall.enable = false;
  151. networking.interfaces.ens3.useDHCP = true;
  152. programs.mtr.enable = true;
  153. programs.fish.enable = true;
  154. programs.gnupg.agent.enable = true;
  155. users.users.chris = {
  156. shell = pkgs.fish;
  157. isNormalUser = true;
  158. extraGroups = [ "wheel" ];
  159. };
  160. }
  161. #+END_SRC
  162. *** Hardware
  163. The file system for this host is a single 24GB QCOW file, a format for disk images used by QEMU[fn:10]. The file can be recreated easily by following the steps listed in the NixOS[fn:4] installation manual, specifically the section on disk formatting.
  164. #+BEGIN_SRC nix :noweb yes :tangle hosts/nixos/hardware.nix
  165. # <<file-warning>>
  166. { config, lib, pkgs, modulesPath, ... }:
  167. {
  168. imports =
  169. [ (modulesPath + "/profiles/qemu-guest.nix")
  170. ];
  171. boot.initrd.availableKernelModules = [ "ata_piix" "floppy" "sd_mod" "sr_mod" ];
  172. boot.initrd.kernelModules = [ ];
  173. boot.kernelModules = [ ];
  174. boot.extraModulePackages = [ ];
  175. fileSystems."/" =
  176. { device = "/dev/disk/by-uuid/fddc37ff-a442-41fa-afc4-abf878be7c5a";
  177. fsType = "ext4";
  178. };
  179. swapDevices =
  180. [ { device = "/dev/disk/by-uuid/5fc0e3df-e796-4fe2-8482-c6acaed9d36f"; }
  181. ];
  182. }
  183. #+END_SRC
  184. ** Acernitro
  185. My gaming laptop, the model is an Acer Nitro AN-515-53[fn:12]. The Nitro 5 has more in common with the mid-range notebooks rather than the gaming models due to its cooling design, chassis, and overall construction.
  186. Here are the specs:
  187. | Slot | Component |
  188. |---------+---------------------------------------|
  189. | CPU | Intel Core i5-8300H |
  190. | GPU | NVIDIA GeForce GTX 1050Ti (4GB GDDR5) |
  191. | RAM | 16GB DDR4 |
  192. | Display | 15.6" Full HD (1920 x 1080), IPS |
  193. | Storage | 1000GB HDD |
  194. | Weight | 2.48kg (5.5 lbs) |
  195. #+NAME: host-acernitro
  196. #+BEGIN_SRC nix :noweb yes
  197. acernitro = nixpkgs.lib.nixosSystem {
  198. system = "x86_64-linux";
  199. specialArgs = { inherit inputs; };
  200. modules = [
  201. ./hosts/acernitro
  202. <<module-x11>>
  203. <<module-flakes>>
  204. <<module-cachix>>
  205. <<module-firefox>>
  206. <<module-moonlight>>
  207. <<module-teamviewer>>
  208. <<module-home-manager>>
  209. ];
  210. };
  211. #+END_SRC
  212. Deploy this configuration with ~nixos-rebuild switch --flake /etc/dotfiles/#acernitro~.
  213. #+BEGIN_SRC nix :noweb yes :tangle hosts/acernitro/default.nix
  214. # <<file-warning>>
  215. { ... }:
  216. {
  217. imports = [
  218. ./configuration.nix
  219. ./hardware.nix
  220. ];
  221. }
  222. #+END_SRC
  223. *** Configuration
  224. This configuration is nearly identical to the default, except for a few key differences:
  225. + Enables sound
  226. + Applies the desired hostname
  227. + It adds support for =UEFI= systems
  228. + Enables support for wireless networking
  229. #+BEGIN_SRC nix :noweb yes :tangle hosts/acernitro/configuration.nix
  230. # <<file-warning>>
  231. { config, pkgs, inputs, ... }:
  232. {
  233. boot.loader.systemd-boot.enable = true;
  234. boot.loader.efi.canTouchEfiVariables = true;
  235. time.timeZone = "America/Toronto";
  236. networking.hostName = "acernitro";
  237. networking.firewall.enable = false;
  238. networking.wireless.enable = true;
  239. networking.wireless.userControlled.enable = true;
  240. networking.useDHCP = false;
  241. networking.interfaces.enp6s0f1.useDHCP = true;
  242. networking.interfaces.wlp0s20f3.useDHCP = true;
  243. # Pre-configured wireless networks.
  244. networking.wireless.networks.MyWiFi_5C1870.pskRaw =
  245. "409b3c85fef1c5737f284d2f82f20dc6023e41804e862d4fa26265ef8193b326";
  246. services.openssh.enable = true;
  247. services.printing.enable = true;
  248. programs.mtr.enable = true;
  249. programs.fish.enable = true;
  250. programs.gnupg.agent.enable = true;
  251. users.users.chris = {
  252. shell = pkgs.fish;
  253. isNormalUser = true;
  254. extraGroups = [ "wheel" ];
  255. };
  256. }
  257. #+END_SRC
  258. *** Hardware
  259. + Override the default =DPI=
  260. + Enables sound via PulseAudio
  261. + Adds support for the NVIDIA Hybrid GPU
  262. #+BEGIN_SRC nix :noweb yes :tangle hosts/acernitro/hardware.nix
  263. # <<file-warning>>
  264. { config, lib, pkgs, modulesPath, ... }:
  265. {
  266. imports =
  267. [ (modulesPath + "/installer/scan/not-detected.nix")
  268. ];
  269. boot.initrd.availableKernelModules = [ "xhci_pci" "ahci" "usb_storage" "sd_mod" "rtsx_pci_sdmmc" ];
  270. boot.initrd.kernelModules = [ ];
  271. boot.kernelModules = [ "kvm-intel" ];
  272. boot.extraModulePackages = [ ];
  273. sound.enable = true;
  274. hardware.pulseaudio.enable = true;
  275. hardware.pulseaudio.support32Bit = true;
  276. services.xserver.dpi = 96;
  277. fileSystems."/" =
  278. { device = "/dev/disk/by-uuid/2f548eb9-47ce-4280-950f-9c6d1d162852";
  279. fsType = "ext4";
  280. };
  281. fileSystems."/boot" =
  282. { device = "/dev/disk/by-uuid/5BC3-73F3";
  283. fsType = "vfat";
  284. };
  285. swapDevices =
  286. [ { device = "/dev/disk/by-uuid/bef7bf62-d26f-45b1-a1f8-1227c2f8b26a"; }
  287. ];
  288. powerManagement.cpuFreqGovernor = lib.mkDefault "powersave";
  289. }
  290. #+END_SRC
  291. * Development Shells
  292. The command ~nix-shell~[fn:13] will build the dependencies of the specified derivation, but not the derivation itself. It will then start an interactive shell in which all environment variables defined by the derivation /path/ have been set to their corresponding values.
  293. Import this shell with ~nix-shell /etc/dotfiles~.
  294. #+BEGIN_SRC nix :noweb yes :tangle shell.nix
  295. # <<file-warning>>
  296. { pkgs ? import <nixpkgs> { } }:
  297. with pkgs;
  298. let
  299. nixBin = writeShellScriptBin "nix" ''
  300. ${nixFlakes}/bin/nix --option experimental-features "nix-command flakes" "$@"
  301. '';
  302. in mkShell {
  303. buildInputs = [
  304. git
  305. ];
  306. shellHook = ''
  307. export FLAKE="$(pwd)"
  308. export PATH="$FLAKE/bin:${nixBin}/bin:$PATH"
  309. '';
  310. }
  311. #+END_SRC
  312. ** Go
  313. Go[fn:14] 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.
  314. Import this shell with ~nix-shell /etc/dotfiles/shells/go~
  315. #+BEGIN_SRC nix :noweb yes :tangle shells/go.nix
  316. # <<file-warning>>
  317. { pkgs ? import <nixpkgs> { } }:
  318. with pkgs;
  319. mkShell {
  320. buildInputs = [
  321. go
  322. gopls
  323. protoc-gen-go-grpc
  324. ];
  325. shellHook = ''
  326. export GO111MODULE=on
  327. export GOPATH=$HOME/.go/
  328. export PATH=$GOPATH/bin:$PATH
  329. '';
  330. }
  331. #+END_SRC
  332. ** gRPC
  333. gRPC[fn:15] 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.
  334. Import this shell with ~nix-shell /etc/dotfiles/shells/grpc~
  335. #+BEGIN_SRC nix :noweb yes :tangle shells/grpc.nix
  336. # <<file-warning>>
  337. { pkgs ? import <nixpkgs> { } }:
  338. with pkgs;
  339. mkShell {
  340. buildInputs = [
  341. grpc
  342. grpc-tools
  343. grpcui
  344. grpcurl
  345. ];
  346. shellHook = ''
  347. '';
  348. }
  349. #+END_SRC
  350. ** C/C++
  351. C[fn:16] 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. C++[fn:17] is a general-purpose programming language created as an extension of the C[fn:16] programming language.
  352. Import this shell with ~nix-shell /etc/dotfiles/shells/cc~
  353. #+BEGIN_SRC nix :noweb yes :tangle shells/cc.nix
  354. # <<file-warning>>
  355. { pkgs ? import <nixpkgs> { } }:
  356. with pkgs;
  357. mkShell {
  358. buildInputs = [
  359. ccls
  360. gnumake
  361. libstdcxx5
  362. gcc-unwrapped
  363. ];
  364. shellHook = ''
  365. '';
  366. }
  367. #+END_SRC
  368. ** Python
  369. Python[fn:18] 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.
  370. Import this shell with ~nix-shell /etc/dotfiles/shells/python~
  371. #+BEGIN_SRC nix :noweb yes :tangle shells/python.nix
  372. # <<file-warning>>
  373. { pkgs ? import <nixpkgs> { } }:
  374. with pkgs;
  375. mkShell {
  376. buildInputs = [
  377. python39Packages.pip
  378. python39Packages.pip-tools
  379. python39Packages.pyls-mypy
  380. python39Packages.pyls-isort
  381. python39Packages.pyls-black
  382. ];
  383. shellHook = ''
  384. '';
  385. }
  386. #+END_SRC
  387. * Module Definitions
  388. Modules are files combined by NixOS[fn:4] to produce the full system configuration. Modules wre introduced to allow extending NixOS[fn:4] without modifying its source code. They also allow splitting up =configuration.nix=, making the system configuration easier to maintain and use.
  389. ** X11
  390. #+NAME: module-x11
  391. #+BEGIN_SRC nix
  392. ./modules/x11.nix
  393. #+END_SRC
  394. X11, or X[fn:19] is the generic name for the X Window System Display Server. All graphical GNU/Linux[fn:1] applications connect to an X-Window[fn:19] (or Wayland[fn:20]) 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.
  395. #+BEGIN_SRC nix :noweb yes :tangle modules/x11.nix
  396. # <<file-warning>>
  397. { config, pkgs, ... }:
  398. {
  399. services.xserver.enable = true;
  400. services.xserver.layout = "us";
  401. services.xserver.libinput.enable = true;
  402. services.xserver.displayManager.startx.enable = true;
  403. environment = {
  404. systemPackages = with pkgs; [
  405. pkgs.sqlite
  406. pkgs.pfetch
  407. pkgs.cmatrix
  408. pkgs.asciiquarium
  409. ];
  410. extraInit = ''
  411. export XAUTHORITY=/tmp/Xauthority
  412. export xserverauthfile=$XAUTHORITY
  413. [ -e ~/.Xauthority ] && mv -f ~/.Xauthority "$XAUTHORITY"
  414. '';
  415. };
  416. services.picom.enable = true;
  417. services.openssh.enable = true;
  418. services.printing.enable = true;
  419. fonts.fonts = with pkgs; [
  420. iosevka
  421. emacs-all-the-icons-fonts
  422. ];
  423. }
  424. #+END_SRC
  425. ** Flakes
  426. #+NAME: module-flakes
  427. #+BEGIN_SRC nix
  428. ./modules/flakes.nix
  429. #+END_SRC
  430. Nix Flakes[fn:21] are an upcoming feature of the Nix package manager[fn:5]. 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[fn:21] 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[fn:21] are not available unless explicitly enabled.
  431. #+BEGIN_SRC nix :noweb yes :tangle modules/flakes.nix
  432. # <<file-warning>>
  433. { config, pkgs, inputs, ... }:
  434. {
  435. nix = {
  436. package = pkgs.nixUnstable;
  437. extraOptions = ''
  438. experimental-features = nix-command flakes
  439. '';
  440. };
  441. nixpkgs = {
  442. config = { allowUnfree = true; };
  443. overlays = [ inputs.emacs-overlay.overlay ];
  444. };
  445. }
  446. #+END_SRC
  447. ** Cachix
  448. #+NAME: module-cachix
  449. #+BEGIN_SRC nix
  450. ./modules/cachix.nix
  451. #+END_SRC
  452. Cachix[fn:22] is a Command line client for Nix[fn:5] 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.
  453. #+BEGIN_SRC nix :noweb yes :tangle modules/cachix.nix
  454. # <<file-warning>>
  455. { config, ... }:
  456. {
  457. nix = {
  458. binaryCaches = [
  459. "https://nix-community.cachix.org"
  460. ];
  461. binaryCachePublicKeys = [
  462. "nix-community.cachix.org-1:mB9FSh9qf2dCimDSUo8Zy7bkq5CX+/rkCWyvRCYg3Fs="
  463. ];
  464. };
  465. }
  466. #+END_SRC
  467. ** Firefox
  468. #+NAME: module-firefox
  469. #+BEGIN_SRC nix
  470. ./modules/firefox.nix
  471. #+END_SRC
  472. Firefox Browser[fn:23], 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.
  473. #+BEGIN_SRC nix :noweb yes :tangle modules/firefox.nix
  474. # <<file-warning>>
  475. { pkgs, ... }:
  476. {
  477. # NOTE: Use the binary until module is developed.
  478. environment.systemPackages = [
  479. pkgs.firefox-bin
  480. ];
  481. }
  482. #+END_SRC
  483. ** Moonlight
  484. #+NAME: module-moonlight
  485. #+BEGIN_SRC nix
  486. ./modules/moonlight.nix
  487. #+END_SRC
  488. Moonlight[fn:24] is an open-source implementation of NVIDIA's GameStream Protocol. You can stream your collection of PC games from your GameStream-compatible PC to any supported device and play them remotely. Moonlight[fn:24] is perfect for gaming on the go (or on GNU/Linux[fn:1]) without sacrificing the graphics and game selection available for the PC.
  489. #+BEGIN_SRC nix :noweb yes :tangle modules/moonlight.nix
  490. # <<file-warning>>
  491. { pkgs, ... }:
  492. {
  493. environment.systemPackages = [
  494. pkgs.moonlight-qt
  495. ];
  496. }
  497. #+END_SRC
  498. ** Teamviewer
  499. #+NAME: module-teamviewer
  500. #+BEGIN_SRC nix
  501. ./modules/teamviewer.nix
  502. #+END_SRC
  503. The Teamviewer[fn:25] remote connectivity cloud platform enables secure remote access to any device, across platforms, from anywhere, anytime. Teamviewer[fn:25] connects computers, smartphones, servers, IoT devices, robots -- anything -- with fast, high performance connections through their global access network. It has been used in outer-space low-bandwidth environments.
  504. #+BEGIN_SRC nix :noweb yes :tangle modules/teamviewer.nix
  505. # <<file-warning>>
  506. { pkgs, ... }:
  507. {
  508. environment.systemPackages = [
  509. pkgs.teamviewer
  510. ];
  511. }
  512. #+END_SRC
  513. ** Home Manager
  514. Home Manager[fn:7] 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.
  515. #+NAME: module-home-manager
  516. #+BEGIN_SRC nix :noweb yes
  517. inputs.home-manager.nixosModules.home-manager {
  518. home-manager.useGlobalPkgs = true;
  519. home-manager.useUserPackages = true;
  520. home-manager.users.chris = {
  521. imports = [
  522. <<module-git>>
  523. <<module-gpg>>
  524. <<module-vim>>
  525. <<module-gtk>>
  526. <<module-emacs>>
  527. ];
  528. };
  529. }
  530. #+END_SRC
  531. *** Git
  532. #+NAME: module-git
  533. #+BEGIN_SRC nix
  534. ./modules/git.nix
  535. #+END_SRC
  536. Git[fn:26] 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.
  537. #+BEGIN_SRC nix :noweb yes :tangle modules/git.nix
  538. # <<file-warning>>
  539. { pkgs, ... }:
  540. {
  541. programs.git = {
  542. enable = true;
  543. userName = "Christopher James Hayward";
  544. userEmail = "chris@chrishayward.xyz";
  545. signing = {
  546. key = "37AB1CB72B741E478CA026D43025DCBD46F81C0F";
  547. signByDefault = true;
  548. };
  549. };
  550. }
  551. #+END_SRC
  552. *** Gpg
  553. #+NAME: module-gpg
  554. #+BEGIN_SRC nix
  555. ./modules/gpg.nix
  556. #+END_SRC
  557. GNU Privacy Guard[fn:27] 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.
  558. #+BEGIN_SRC nix :noweb yes :tangle modules/gpg.nix
  559. # <<file-warning>>
  560. { pkgs, ... }:
  561. {
  562. services.gpg-agent = {
  563. enable = true;
  564. defaultCacheTtl = 1800;
  565. enableSshSupport = true;
  566. pinentryFlavor = "gtk2";
  567. };
  568. }
  569. #+END_SRC
  570. *** Vim
  571. #+NAME: module-vim
  572. #+BEGIN_SRC nix
  573. ./modules/vim.nix
  574. #+END_SRC
  575. Neovim[fn:28] is a project that seeks to aggressively refactor Vim in order to:
  576. + Simplify maintenance and encourage contributions
  577. + Split the work between multiple developers
  578. + Enable advanced UIs without core modification
  579. + Maximize extensibility
  580. #+BEGIN_SRC nix :noweb yes :tangle modules/vim.nix
  581. # <<file-warning>>
  582. { pkgs, ... }:
  583. {
  584. programs.neovim = {
  585. enable = true;
  586. viAlias = true;
  587. vimAlias = true;
  588. vimdiffAlias = true;
  589. extraConfig = ''
  590. set number relativenumber
  591. set nobackup
  592. '';
  593. extraPackages = [
  594. pkgs.nixfmt
  595. ];
  596. plugins = with pkgs.vimPlugins; [
  597. vim-nix
  598. vim-airline
  599. vim-polyglot
  600. ];
  601. };
  602. }
  603. #+END_SRC
  604. *** GTK
  605. #+NAME: module-gtk
  606. #+BEGIN_SRC nix
  607. ./modules/gtk.nix
  608. #+END_SRC
  609. GTK[fn:29] is a free and open-source, cross-platform widget toolkit for graphical user interfaces. It's one of the most popular toolkits for the Wayland[fn:20] and X11[fn:19] windowing systems.
  610. #+BEGIN_SRC nix :noweb yes :tangle modules/gtk.nix
  611. # <<file-warning>>
  612. { pkgs, ... }:
  613. {
  614. home.packages = [
  615. pkgs.arc-theme
  616. pkgs.arc-icon-theme
  617. pkgs.lxappearance
  618. ];
  619. home.file.".gtkrc-2.0" = {
  620. text = ''
  621. gtk-theme-name="Arc-Dark"
  622. gtk-icon-theme-name="Arc"
  623. gtk-font-name="Sans 10"
  624. gtk-cursor-theme-size=0
  625. gtk-toolbar-style=GTK_TOOLBAR_BOTH_HORIZ
  626. gtk-toolbar-icon-size=GTK_ICON_SIZE_LARGE_TOOLBAR
  627. gtk-button-images=0
  628. gtk-menu-images=0
  629. gtk-enable-event-sounds=1
  630. gtk-enable-input-feedback-sounds=1
  631. gtk-xft-antialias=1
  632. gtk-xft-hinting=1
  633. gtk-xft-hintstyle="hintmedium"
  634. '';
  635. };
  636. }
  637. #+END_SRC
  638. * Emacs Configuration
  639. #+NAME: module-emacs
  640. #+BEGIN_SRC nix
  641. ./modules/emacs.nix
  642. #+END_SRC
  643. GNU/Emacs[fn:2] is an extensible, customizable, free/libre text editor -- and more. At its core is an interpreter for Emacs Lisp[fn:27], a dialect of the Lisp programming language with extensions to support text editing. Other features include:
  644. + Highly customizable
  645. + Full Unicopde support
  646. + Content-aware editing modes
  647. + Complete built-in documentation
  648. + Wide range of functionality beyond text editing
  649. #+BEGIN_SRC nix :noweb yes :tangle modules/emacs.nix
  650. # <<file-warning>>
  651. { pkgs, ... }:
  652. let
  653. myEmacs = pkgs.emacsWithPackagesFromUsePackage {
  654. config = ../README.org;
  655. package = <<emacs-native-comp-package>>
  656. alwaysEnsure = true;
  657. alwaysTangle = true;
  658. extraEmacsPackages = epkgs: [
  659. # Required packages...
  660. <<emacs-exwm-package>>
  661. <<emacs-evil-package>>
  662. <<emacs-general-package>>
  663. <<emacs-which-key-package>>
  664. # Optional packages.
  665. <<emacs-org-package>>
  666. <<emacs-org-roam-package>>
  667. <<emacs-org-drill-package>>
  668. <<emacs-pomodoro-package>>
  669. <<emacs-writegood-package>>
  670. <<emacs-hugo-package>>
  671. <<emacs-reveal-package>>
  672. <<emacs-pass-package>>
  673. <<emacs-mu4e-package>>
  674. <<emacs-dired-package>>
  675. <<emacs-icons-package>>
  676. <<emacs-emoji-package>>
  677. <<emacs-eshell-package>>
  678. <<emacs-vterm-package>>
  679. <<emacs-magit-package>>
  680. <<emacs-elfeed-package>>
  681. <<emacs-nix-mode-package>>
  682. <<emacs-projectile-package>>
  683. <<emacs-lsp-package>>
  684. <<emacs-company-package>>
  685. <<emacs-golang-package>>
  686. <<emacs-python-package>>
  687. <<emacs-plantuml-package>>
  688. <<emacs-swiper-package>>
  689. <<emacs-doom-themes-package>>
  690. <<emacs-doom-modeline-package>>
  691. ];
  692. };
  693. in {
  694. home.packages = [
  695. <<emacs-exwm-extras>>
  696. <<emacs-hugo-extras>>
  697. <<emacs-pass-extras>>
  698. <<emacs-mu4e-extras>>
  699. <<emacs-aspell-extras>>
  700. <<emacs-plantuml-extras>>
  701. <<emacs-nix-mode-extras>>
  702. ];
  703. programs.emacs = {
  704. enable = true;
  705. package = myEmacs;
  706. };
  707. <<emacs-exwm-config>>
  708. <<emacs-exwm-xinitrc>>
  709. <<emacs-mu4e-config>>
  710. }
  711. #+END_SRC
  712. 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.
  713. #+BEGIN_SRC emacs-lisp :noweb yes :tangle ~/.emacs.d/init.el
  714. ;; <<file-warning>>
  715. ;; Required inputs.
  716. <<emacs-exwm-elisp>>
  717. <<emacs-evil-elisp>>
  718. <<emacs-general-elisp>>
  719. <<emacs-which-key-elisp>>
  720. ;; Optional inputs.
  721. <<emacs-org-elisp>>
  722. <<emacs-org-roam-elisp>>
  723. <<emacs-org-drill-elisp>>
  724. <<emacs-org-agenda-elisp>>
  725. <<emacs-pomodoro-elisp>>
  726. <<emacs-writegood-elisp>>
  727. <<emacs-aspell-elisp>>
  728. <<emacs-eww-elisp>>
  729. <<emacs-hugo-elisp>>
  730. <<emacs-reveal-elisp>>
  731. <<emacs-pass-elisp>>
  732. <<emacs-mu4e-elisp>>
  733. <<emacs-dired-elisp>>
  734. <<emacs-icons-elisp>>
  735. <<emacs-emoji-elisp>>
  736. <<emacs-eshell-elisp>>
  737. <<emacs-vterm-elisp>>
  738. <<emacs-magit-elisp>>
  739. <<emacs-fonts-elisp>>
  740. <<emacs-elfeed-elisp>>
  741. <<emacs-projectile-elisp>>
  742. <<emacs-lsp-elisp>>
  743. <<emacs-company-elisp>>
  744. <<emacs-golang-elisp>>
  745. <<emacs-python-elisp>>
  746. <<emacs-plantuml-elisp>>
  747. ;; User interface.
  748. <<emacs-swiper-elisp>>
  749. <<emacs-transparency-elisp>>
  750. <<emacs-doom-themes-elisp>>
  751. <<emacs-doom-modeline-elisp>>
  752. #+END_SRC
  753. 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=.
  754. #+BEGIN_SRC emacs-lisp :noweb yes :tangle ~/.emacs.d/early-init.el
  755. ;; <<file-warning>>
  756. <<emacs-disable-ui-elisp>>
  757. <<emacs-native-comp-elisp>>
  758. <<emacs-backup-files-elisp>>
  759. <<emacs-shell-commands-elisp>>
  760. #+END_SRC
  761. ** Disable UI
  762. Emacs[fn:2] 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.
  763. #+NAME: emacs-disable-ui-elisp
  764. #+BEGIN_SRC emacs-lisp
  765. ;; Disable unwanted UI elements.
  766. (tooltip-mode -1)
  767. (menu-bar-mode -1)
  768. (tool-bar-mode -1)
  769. (scroll-bar-mode -1)
  770. ;; Fix the scrolling behaviour.
  771. (setq scroll-conservatively 101)
  772. ;; Fix mouse-wheel scrolling behaviour.
  773. (setq mouse-wheel-follow-mouse t
  774. mouse-wheel-progressive-speed t
  775. mouse-wheel-scroll-amount '(3 ((shift) . 3)))
  776. #+END_SRC
  777. ** Native Comp
  778. #+NAME: emacs-native-comp-package
  779. #+BEGIN_SRC nix
  780. pkgs.emacsGcc;
  781. #+END_SRC
  782. Native Comp, also known as GccEmacs, refers to the ~--with-native-compilation~ configuration option when building GNU/Emacs[fn:2]. It adds support for compiling 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.
  783. #+NAME: emacs-native-comp-elisp
  784. #+BEGIN_SRC emacs-lisp
  785. ;; Silence warnings from packages that don't support `native-comp'.
  786. (setq comp-async-report-warnings-errors nil ;; Emacs 27.2 ...
  787. native-comp-async-report-warnings-errors nil) ;; Emacs 28+ ...
  788. #+END_SRC
  789. ** Backup Files
  790. Emacs[fn:2] 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.
  791. #+NAME: emacs-backup-files-elisp
  792. #+BEGIN_SRC emacs-lisp
  793. ;; Disable unwanted features.
  794. (setq make-backup-files nil
  795. create-lockfiles nil)
  796. #+END_SRC
  797. ** Shell Commands
  798. Define some methods for interaction between GNU/Emacs[fn:2], and the systems underyling shell:
  799. 1) Method to run an external process, launching any application on a new process without interferring with Emacs[fn:2]
  800. 2) Method to apply commands to the curren call process, effecting the running instance of Emacs[fn:2]
  801. #+NAME: emacs-shell-commands-elisp
  802. #+BEGIN_SRC emacs-lisp
  803. ;; Define a method to run an external process.
  804. (defun dotfiles/run (cmd)
  805. "Run an external process."
  806. (interactive (list (read-shell-command "λ ")))
  807. (start-process-shell-command cmd nil cmd))
  808. ;; Define a method to run a background process.
  809. (defun dotfiles/run-in-background (cmd)
  810. (let ((command-parts (split-string cmd "[ ]+")))
  811. (apply #'call-process `(,(car command-parts) nil 0 nil ,@(cdr command-parts)))))
  812. #+END_SRC
  813. ** Nix Mode
  814. #+NAME: emacs-nix-mode-extras
  815. #+BEGIN_SRC nix
  816. pkgs.nixfmt
  817. #+END_SRC
  818. Nix-mode[fn:30] is an Emacs[fn:2] major mode for editing Nix[fn:5] expressions. This provides basic handling of =.nix= files. Syntax highlighting and indentation support using =SMIE= are provided.
  819. #+NAME: emacs-nix-mode-package
  820. #+BEGIN_SRC nix
  821. epkgs.nix-mode
  822. #+END_SRC
  823. ** Evil Mode
  824. Evil[fn:12] is an extensible VI layer for GNU/Emacs[fn:2]. It emulates the main features of Vim[fn:28], turning GNU/Emacs[fn:2] into a modal editor.
  825. #+NAME: emacs-evil-package
  826. #+BEGIN_SRC nix
  827. epkgs.evil
  828. epkgs.evil-collection
  829. epkgs.evil-surround
  830. epkgs.evil-nerd-commenter
  831. #+END_SRC
  832. The next time Emacs[fn:2] 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[fn:2] in general, Evil[fn:12] is extensible in Emacs Lisp[fn:27].
  833. #+NAME: emacs-evil-elisp
  834. #+BEGIN_SRC emacs-lisp
  835. ;; Enable the Extensible VI Layer for Emacs.
  836. (setq evil-want-integration t ;; Required for `evil-collection.'
  837. evil-want-keybinding nil) ;; Same as above.
  838. (evil-mode +1)
  839. ;; Configure `evil-collection'.
  840. (evil-collection-init)
  841. ;; Configure `evil-surround'.
  842. (global-evil-surround-mode +1)
  843. ;; Configure `evil-nerd-commenter'.
  844. (global-set-key (kbd "M-;") 'evilnc-comment-or-uncomment-lines)
  845. #+END_SRC
  846. ** EXWM
  847. #+NAME: emacs-exwm-package
  848. #+BEGIN_SRC nix
  849. epkgs.exwm
  850. #+END_SRC
  851. EXWM (Emacs X Window Manager)[fn:11] is a full-featured tiling X window manager for GNU/Emacs[fn:2] built on-top of XELB. It features:
  852. + Fully keyboard-driven operations
  853. + Hybrid layout modes (tiling & stacking)
  854. + Dynamic workspace support
  855. + ICCM/EWMH compliance
  856. #+NAME: emacs-exwm-extras
  857. #+BEGIN_SRC nix
  858. pkgs.nitrogen
  859. pkgs.autorandr
  860. #+END_SRC
  861. 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 EXWM[fn:11].
  862. #+NAME: emacs-exwm-config
  863. #+BEGIN_SRC nix
  864. xsession = {
  865. enable = true;
  866. windowManager.command = ''
  867. ${pkgs.nitrogen}/bin/nitrogen --restore
  868. ${myEmacs}/bin/emacs --daemon -f exwm-enable
  869. ${myEmacs}/bin/emacsclient -c
  870. '';
  871. };
  872. #+END_SRC
  873. EXWM[fn:11] cannot make an X window manager by itself, this is by design; You must tell X to do it. Override the =~/.xinitrc= file to start the =xsession=.
  874. #+NAME: emacs-exwm-xinitrc
  875. #+BEGIN_SRC nix
  876. home.file.".xinitrc" = {
  877. text = ''
  878. exec ./.xsession
  879. '';
  880. };
  881. #+END_SRC
  882. #+NAME: emacs-exwm-elisp
  883. #+BEGIN_SRC emacs-lisp
  884. ;; Configure `exwm'.
  885. (setq exwm-worspace-show-all-buffers t)
  886. (setq exwm-input-prefix-keys
  887. '(?\M-x
  888. ?\C-g
  889. ?\C-\ ))
  890. (setq exwm-input-global-keys
  891. `(([?\s-r] . exwm-reset)
  892. ,@(mapcar (lambda (i)
  893. `(,(kbd (format "s-%d" i)) .
  894. (lambda ()
  895. (interactive)
  896. (exwm-workspace-switch-create ,i))))
  897. (number-sequence 1 9))))
  898. ;; Configure `exwm-randr'.
  899. (require 'exwm-randr)
  900. (exwm-randr-enable)
  901. ;; Configure custom hooks.
  902. (setq display-time-and-date t)
  903. (add-hook 'exwm-init-hook
  904. (lambda ()
  905. (display-battery-mode +1) ;; Display battery info (if available).
  906. (display-time-mode +1))) ;; Display the time in the modeline.
  907. ;; Setup buffer display names.
  908. (add-hook 'exwm-update-class-hook
  909. (lambda ()
  910. (exwm-workspace-rename-buffer exwm-class-name))) ;; Use the system class name.
  911. ;; Configure monitor hot-swapping.
  912. (add-hook 'exwm-randr-screen-change-hook
  913. (lambda ()
  914. (dotfiles/run-in-background "autorandr --change --force"))) ;; Swap to the next screen config.
  915. #+END_SRC
  916. ** General
  917. #+NAME: emacs-general-package
  918. #+BEGIN_SRC nix
  919. epkgs.general
  920. #+END_SRC
  921. General[fn:31] provides a more convenient method for binding keys in Emacs[fn:2], providing a unified interface for key definitions. Its primary purpose is to build on /existing/ functionality to make key definitions more clear and concise.
  922. #+NAME: emacs-general-elisp
  923. #+BEGIN_SRC emacs-lisp
  924. ;; Use <SPC> as a leader key via `general.el'.
  925. (general-create-definer dotfiles/leader
  926. :states '(normal motion)
  927. :keymaps 'override
  928. :prefix "SPC"
  929. :global-prefix "C-SPC")
  930. ;; Find files with <SPC> <period> ...
  931. ;; Switch buffers with <SPC> <comma> ...
  932. (dotfiles/leader
  933. "." '(find-file :which-key "File")
  934. "," '(switch-to-buffer :which-key "Buffer")
  935. "c" '(kill-buffer-and-window :which-key "Close"))
  936. ;; Add keybindings for executing shell commands.
  937. (dotfiles/leader
  938. "r" '(:ignore t :which-key "Run")
  939. "rr" '(dotfiles/run :which-key "Run")
  940. "ra" '(async-shell-command :which-key "Async"))
  941. ;; Add keybindings for quitting Emacs.
  942. (dotfiles/leader
  943. "q" '(:ignore t :which-key "Quit")
  944. "qq" '(save-buffers-kill-emacs :which-key "Save")
  945. "qw" '(kill-emacs :which-key "Now")
  946. "qf" '(delete-frame :which-key "Frame"))
  947. ;; Add keybindings for toggles / tweaks.
  948. (dotfiles/leader
  949. "t" '(:ignore t :which-key "Toggle / Tweak"))
  950. ;; Add keybindings for working with frames to replace
  951. ;; the C-x <num> <num> method of bindings, which is awful.
  952. (dotfiles/leader
  953. "w" '(:ignore t :which-key "Windows")
  954. "ww" '(window-swap-states :which-key "Swap")
  955. "wc" '(delete-window :which-key "Close")
  956. "wh" '(windmove-left :which-key "Left")
  957. "wj" '(windmove-down :which-key "Down")
  958. "wk" '(windmove-up :which-key "Up")
  959. "wl" '(windmove-right :which-key "Right")
  960. "ws" '(:ignore t :which-key "Split")
  961. "wsj" '(split-window-below :which-key "Below")
  962. "wsl" '(split-window-right :which-key "Right"))
  963. #+END_SRC
  964. ** Which Key
  965. Which-key[fn:32] is a minor mode for Emacs[fn:2] that displays the key bindings following your currently entered incomplete command (prefix) in a popup or mini-buffer.
  966. #+NAME: emacs-which-key-package
  967. #+BEGIN_SRC nix
  968. epkgs.which-key
  969. #+END_SRC
  970. #+NAME: emacs-which-key-elisp
  971. #+BEGIN_SRC emacs-lisp
  972. ;; Configure `which-key' to see keyboard bindings in the
  973. ;; mini-buffer and when using M-x.
  974. (setq which-key-idle-delay 0.0)
  975. (which-key-mode +1)
  976. #+END_SRC
  977. ** EWW
  978. The Emacs Web Wowser[fn:33] is a Web browser written in Emacs Lisp[fn:27] based on the ~shr.el~ library. It's my primary browser when it comes to text-based browsing.
  979. + Use ~eww~ as the default browser
  980. + Don't use any special fonts or colours
  981. #+NAME: emacs-eww-elisp
  982. #+BEGIN_SRC emacs-lisp
  983. ;; Set `eww' as the default browser.
  984. (setq browse-url-browser-function 'eww-browse-url)
  985. ;; Configure the `shr' rendering engine.
  986. (setq shr-use-fonts nil
  987. shr-use-colors nil)
  988. #+END_SRC
  989. ** Dired
  990. #+NAME: emacs-dired-package
  991. #+BEGIN_SRC nix
  992. epkgs.dired-single
  993. #+END_SRC
  994. Dired[fn:34] shows a directory listing inside of an Emacs[fn:2] 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. Dired-Extra[fn:35] provides extra functionality for Dired[fn:34].
  995. #+NAME: emacs-dired-elisp
  996. #+BEGIN_SRC emacs-lisp
  997. ;; Include `dired-x' for the `jump' method.
  998. (require 'dired-x)
  999. ;; Configure `dired-single' to support `evil' keys.
  1000. (evil-collection-define-key 'normal 'dired-mode-map
  1001. "h" 'dired-single-up-directory
  1002. "l" 'dired-single-buffer)
  1003. ;; Setup `all-the-icons' and the `dired' extension.
  1004. ;; Configure keybindings for `dired'.
  1005. (dotfiles/leader
  1006. "d" '(dired-jump :which-key "Dired"))
  1007. #+END_SRC
  1008. ** Icons
  1009. #+NAME: emacs-icons-package
  1010. #+BEGIN_SRC nix
  1011. epkgs.all-the-icons
  1012. epkgs.all-the-icons-dired
  1013. #+END_SRC
  1014. All The Icons[fn:36] is a utility package to collect various Icon Fonts and prioritize them within GNU/Emacs[fn:2].
  1015. #+NAME: emacs-icons-elisp
  1016. #+BEGIN_SRC emacs-lisp
  1017. ;; Setup `all-the-icons-dired'.
  1018. (add-hook 'dired-mode-hook 'all-the-icons-dired-mode)
  1019. ;; Display default font ligatures.
  1020. (global-prettify-symbols-mode +1)
  1021. #+END_SRC
  1022. ** Emojis
  1023. #+NAME: emacs-emoji-package
  1024. #+BEGIN_SRC nix
  1025. epkgs.emojify
  1026. #+END_SRC
  1027. Emojify[fn:37] is an Emacs[fn:2] 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.
  1028. #+NAME: emacs-emoji-elisp
  1029. #+BEGIN_SRC emacs-lisp
  1030. ;; Setup `emojify'.
  1031. (add-hook 'after-init-hook 'global-emojify-mode)
  1032. #+END_SRC
  1033. ** EShell
  1034. #+NAME: emacs-eshell-package
  1035. #+BEGIN_SRC nix
  1036. epkgs.eshell-prompt-extras
  1037. #+END_SRC
  1038. EShell [fn:38] is a shell-like command interpreter for GNU/Emacs[fn:2] implemented in Emacs Lisp[fn:27]. 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[fn:2].
  1039. #+NAME: emacs-eshell-elisp
  1040. #+BEGIN_SRC emacs-lisp
  1041. ;; Configure `eshell'.
  1042. (setq eshell-highlight-prompt nil
  1043. eshell-prefer-lisp-functions nil)
  1044. ;; Configure the lambda prompt.
  1045. (autoload 'epe-theme-lambda "eshell-prompt-extras")
  1046. (setq eshell-prompt-function 'epe-theme-lambda)
  1047. ;; Configure keybindings for `eshell'.
  1048. (dotfiles/leader
  1049. "e" '(eshell :which-key "EShell"))
  1050. #+END_SRC
  1051. ** VTerm
  1052. Emacs Libvterm (VTerm)[fn:39] is a fully-fledged terminal emulator inside GNU/Emacs[fn:2] based on Libvterm[fn:40], a blazing fast C library used in Neovim[fn:28]. As a result of using compiled code (instead of Emacs Lisp[fn:27]), VTerm[fn:39] is capable, fast, and it can seamlessly handle large outputs.
  1053. #+NAME: emacs-vterm-package
  1054. #+BEGIN_SRC nix
  1055. epkgs.vterm
  1056. #+END_SRC
  1057. #+NAME: emacs-vterm-elisp
  1058. #+BEGIN_SRC emacs-lisp
  1059. ;; Add keybindings for interacting with the shell(s).
  1060. (dotfiles/leader
  1061. "v" '(vterm :which-key "VTerm"))
  1062. #+END_SRC
  1063. ** Magit
  1064. Magit[fn:41] is an interface to the Git[fn:26] version control system, implemented as a GNU/Emacs[fn:2] package written in Elisp[fn:27]. It fills the glaring gap between the Git[fn:26] command line interface and various GUIs, letting you perform trivial as well as elaborate version control tasks within a few mnemonic key presses.
  1065. #+NAME: emacs-magit-package
  1066. #+BEGIN_SRC nix
  1067. epkgs.magit
  1068. #+END_SRC
  1069. | Key | Description |
  1070. |-----+--------------------------------------|
  1071. | gg | Check the status of a repository |
  1072. | gc | Clone a remote repository |
  1073. | gf | Fetch the contents of the repository |
  1074. | gp | Pull the remotes of the repository |
  1075. #+NAME: emacs-magit-elisp
  1076. #+BEGIN_SRC emacs-lisp
  1077. ;; Add keybindings for working with `magit'.
  1078. (dotfiles/leader
  1079. "g" '(:ignore t :which-key "Git")
  1080. "gg" '(magit-status :which-key "Status")
  1081. "gc" '(magit-clone :which-key "Clone")
  1082. "gf" '(magit-fetch :which-key "Fetch")
  1083. "gp" '(magit-pull :which-key "Pull"))
  1084. #+END_SRC
  1085. ** Fonts
  1086. #+NAME: emacs-fonts-elisp
  1087. #+BEGIN_SRC emacs-lisp
  1088. ;; Configure the font when running as `emacs-server'.
  1089. (custom-set-faces
  1090. '(default ((t (:inherit nil :height 96 :family "Iosevka")))))
  1091. ;; Set all three of Emacs' font faces.
  1092. ;; NOTE: This only works without `emacs-server'.
  1093. ;; (set-face-attribute 'default nil :font "Iosevka" :height 96)
  1094. ;; (set-face-attribute 'fixed-pitch nil :font "Iosevka" :height 96)
  1095. ;; (set-face-attribute 'variable-pitch nil :font "Iosevka" :height 96)
  1096. #+END_SRC
  1097. ** Elfeed
  1098. #+NAME: emacs-elfeed-package
  1099. #+BEGIN_SRC nix
  1100. epkgs.elfeed
  1101. #+END_SRC
  1102. Elfeed[fn:42] is an extensible web feed reader for GNU/Emacs[fn:2], support both =Atom= and =RSS=. It requires =Emacs 24.3+= and is available for download from the standard repositories.
  1103. | Key | Command |
  1104. |-----+---------|
  1105. | l | Open |
  1106. | u | Update |
  1107. #+NAME: emacs-elfeed-elisp
  1108. #+BEGIN_SRC emacs-lisp
  1109. ;; Add custom feeds for `elfeed' to fetch.
  1110. (setq elfeed-feeds (quote
  1111. (("https://hexdsl.co.uk/rss.xml")
  1112. ("https://lukesmith.xyz/rss.xml")
  1113. ("https://friendo.monster/rss.xml")
  1114. ("https://chrishayward.xyz/index.xml")
  1115. ("https://protesilaos.com/codelog.xml"))))
  1116. ;; Add custom keybindings for `elfeed'.
  1117. (dotfiles/leader
  1118. "l" '(:ignore t :which-key "Elfeed")
  1119. "ll" '(elfeed :which-key "Open")
  1120. "lu" '(elfeed-update :which-key "Update"))
  1121. #+END_SRC
  1122. ** Org Mode
  1123. #+NAME: emacs-org-package
  1124. #+BEGIN_SRC nix
  1125. epkgs.org
  1126. #+END_SRC
  1127. Org-mode[fn:43] is a document editing and organizing mode, designed for notes, planning, and authoring within the free software text editor GNU/Emacs[fn:2]. 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.
  1128. #+NAME: emacs-org-elisp
  1129. #+BEGIN_SRC emacs-lisp
  1130. ;; Configure `org-mode' source blocks.
  1131. (setq org-src-fontify-natively t ;; Make source blocks prettier.
  1132. org-src-tab-acts-natively t ;; Use TAB indents within source blocks.
  1133. org-src-preserve-indentation t) ;; Stop `org-mode' from formatting blocks.
  1134. ;; Add an `org-mode-hook'.
  1135. (add-hook 'org-mode-hook
  1136. (lambda ()
  1137. (org-indent-mode)
  1138. (visual-line-mode)))
  1139. ;; Remove the `Validate XHTML 1.0' message from HTML export.
  1140. (setq org-export-html-validation-link nil
  1141. org-html-validation-link nil)
  1142. ;; TODO: Configure default structure templates.
  1143. ;; (require 'org-tempo)
  1144. ;; Apply custom keybindings.
  1145. (dotfiles/leader
  1146. "o" '(:ignore t :which-key "Org")
  1147. "oe" '(org-export-dispatch :which-key "Export")
  1148. "ot" '(org-babel-tangle :which-key "Tangle")
  1149. "oi" '(org-toggle-inline-images :which-key "Images")
  1150. "of" '(:ignore t :which-key "Footnotes")
  1151. "ofn" '(org-footnote-normalize :which-key "Normalize"))
  1152. #+END_SRC
  1153. ** Org Roam
  1154. #+NAME: emacs-org-roam-package
  1155. #+BEGIN_SRC nix
  1156. epkgs.org-roam
  1157. epkgs.org-roam-server
  1158. #+END_SRC
  1159. Org Roam[fn:44] is a plain-text knowledge management system. It borrows principles from the Zettelkasten method[fn:45], providing a solution for non-hierarchical note-taking. It should also work as a plug-and-play solution for anyone already using Org Mode[fn:43] for their personal wiki (me). Org Roam Server[fn:46] is a Web application to visualize the Org Roam[fn:44] database. Although it should automatically reload if there's a change in the database, it can be done so manually by clicking the =reload= button on the Web interface.
  1160. #+NAME: emacs-org-roam-elisp
  1161. #+BEGIN_SRC emacs-lisp
  1162. ;; Setup `org-roam' hooks.
  1163. (add-hook 'after-init-hook
  1164. (lambda ()
  1165. (org-roam-mode)
  1166. (org-roam-server-mode)))
  1167. ;; Configure `org-roam'.
  1168. (setq org-roam-encrypt-files t
  1169. org-roam-directory (expand-file-name "/etc/dotfiles")
  1170. org-roam-capture-templates '()
  1171. org-roam-dailies-capture-templates '())
  1172. ;; Encrypt files with the public key.
  1173. (setq epa-file-select-keys 2
  1174. epa-file-encrypt-to "37AB1CB72B741E478CA026D43025DCBD46F81C0F"
  1175. epa-cache-passphrase-for-symmetric-encryption t)
  1176. ;; Define a new `title-to-slug' function to override the default `org-roam-title-to-slug' function.
  1177. ;; This is done to change the replacement character from "_" to "-".
  1178. (require 'cl-lib)
  1179. (defun dotfiles/title-to-slug (title)
  1180. "Convert TITLE to a filename-suitable slug."
  1181. (cl-flet* ((nonspacing-mark-p (char)
  1182. (eq 'Mn (get-char-code-property char 'general-category)))
  1183. (strip-nonspacing-marks (s)
  1184. (apply #'string (seq-remove #'nonspacing-mark-p
  1185. (ucs-normalize-NFD-string s))))
  1186. (cl-replace (title pair)
  1187. (replace-regexp-in-string (car pair) (cdr pair) title)))
  1188. (let* ((pairs `(("[^[:alnum:][:digit:]]" . "-") ;; Convert anything not alphanumeric.
  1189. ("--*" . "-") ;; Remove sequential dashes.
  1190. ("^-" . "") ;; Remove starting dashes.
  1191. ("-$" . ""))) ;; Remove ending dashes.
  1192. (slug (-reduce-from #'cl-replace (strip-nonspacing-marks title) pairs)))
  1193. (downcase slug))))
  1194. (setq org-roam-title-to-slug-function #'dotfiles/title-to-slug)
  1195. ;; Configure capture templates.
  1196. ;; Standard document.
  1197. (add-to-list 'org-roam-capture-templates
  1198. '("d" "Default" entry (function org-roam-capture--get-point)
  1199. "%?"
  1200. :file-name "docs/${slug}"
  1201. :unnarrowed t
  1202. :head
  1203. "
  1204. ,#+TITLE: ${title}
  1205. ,#+AUTHOR: Christopher James Hayward
  1206. ,#+EMAIL: chris@chrishayward.xyz
  1207. "))
  1208. ;; Course document.
  1209. (add-to-list 'org-roam-capture-templates
  1210. '("c" "Course" plain (function org-roam-capture--get-point)
  1211. "%?"
  1212. :file-name "docs/courses/${slug}"
  1213. :unnarrowed t
  1214. :head
  1215. "
  1216. ,#+TITLE: ${title}
  1217. ,#+SUBTITLE:
  1218. ,#+AUTHOR: Christopher James Hayward
  1219. ,#+EMAIL: chris@chrishayward.xyz
  1220. ,#+OPTIONS: num:nil toc:nil todo:nil tasks:nil tags:nil
  1221. ,#+OPTIONS: skip:nil author:nil email:nil creator:nil timestamp:nil
  1222. "))
  1223. ;; Daily notes.
  1224. (add-to-list 'org-roam-dailies-capture-templates
  1225. '("d" "Default" entry (function org-roam-capture--get-point)
  1226. "* %?"
  1227. :file-name "docs/daily/%<%Y-%m-%d>"
  1228. :head
  1229. "
  1230. ,#+TITLE: %<%Y-%m-%d>
  1231. ,#+AUTHOR: Christopher James Hayward
  1232. ,#+OPTIONS: num:nil toc:nil todo:nil tasks:nil tags:nil
  1233. ,#+OPTIONS: skip:nil author:nil email:nil creator:nil timestamp:nil
  1234. "))
  1235. ;; Apply custom keybindings.
  1236. (dotfiles/leader
  1237. "or" '(:ignore t :which-key "Roam")
  1238. "ori" '(org-roam-insert :which-key "Insert")
  1239. "orf" '(org-roam-find-file :which-key "Find")
  1240. "orc" '(org-roam-capture :which-key "Capture")
  1241. "orb" '(org-roam-buffer-toggle-display :which-key "Buffer"))
  1242. ;; Apply custom keybindings for dailies.
  1243. (dotfiles/leader
  1244. "ord" '(:ignore t :which-key "Dailies")
  1245. "ordd" '(org-roam-dailies-find-date :which-key "Date")
  1246. "ordt" '(org-roam-dailies-find-today :which-key "Today")
  1247. "ordm" '(org-roam-dailies-find-tomorrow :which-key "Tomorrow")
  1248. "ordy" '(org-roam-dailies-find-yesterday :which-key "Yesterday"))
  1249. #+END_SRC
  1250. ** Org Drill
  1251. #+NAME: emacs-org-drill-package
  1252. #+BEGIN_SRC nix
  1253. epkgs.org-drill
  1254. #+END_SRC
  1255. Org Drill[fn:47] is an extension for Org Mode[fn:43] that uses a spaced repition algorithm to conduct interactive /Drill Sessions/ using Org files as sources of facts to be memorized.
  1256. #+NAME: emacs-org-drill-elisp
  1257. #+BEGIN_SRC emacs-lisp
  1258. ;; Configure keybindings for `org-drill'.
  1259. (dotfiles/leader
  1260. "od" '(:ignore t :which-key "Drill")
  1261. "odd" '(org-drill :which-key "Drill")
  1262. "odc" '(org-drill-cram :which-key "Cram")
  1263. "odr" '(org-drill-resume :which-key "Resume"))
  1264. #+END_SRC
  1265. ** Org Agenda
  1266. The way Org Mode[fn:43] 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.
  1267. #+NAME: emacs-org-agenda-elisp
  1268. #+BEGIN_SRC emacs-lisp
  1269. ;; Configure `org-agenda' to use the project files.
  1270. (setq org-agenda-files '("/etc/dotfiles/"
  1271. "/etc/dotfiles/docs/"
  1272. "/etc/dotfiles/docs/courses/"
  1273. "/etc/dotfiles/docs/daily/"
  1274. "/etc/dotfiles/docs/notes/"
  1275. "/etc/dotfiles/docs/posts/"
  1276. "/etc/dotfiles/docs/slides/"))
  1277. ;; Include files encrypted with `gpg'.
  1278. (require 'org)
  1279. (unless (string-match-p "\\.gpg" org-agenda-file-regexp)
  1280. (setq org-agenda-file-regexp
  1281. (replace-regexp-in-string "\\\\\\.org" "\\\\.org\\\\(\\\\.gpg\\\\)?"
  1282. org-agenda-file-regexp)))
  1283. ;; Open an agenda buffer with SPC o a.
  1284. (dotfiles/leader
  1285. "oa" '(org-agenda :which-key "Agenda"))
  1286. #+END_SRC
  1287. ** Org Pomodoro
  1288. #+NAME: emacs-pomodoro-package
  1289. #+BEGIN_SRC nix
  1290. epkgs.org-pomodoro
  1291. #+END_SRC
  1292. Org Pomodoro[fn:48] adds basic support for the Pomodoro Technique[fn:49] in GNU/Emacs[fn:2]. 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.
  1293. #+NAME: emacs-pomodoro-elisp
  1294. #+BEGIN_SRC emacs-lisp
  1295. ;; Configure `org-pomodor' with the overtime workflow.
  1296. (setq org-pomodoro-manual-break t
  1297. org-pomodoro-keep-killed-time t)
  1298. ;; Configure keybindings.
  1299. (dotfiles/leader
  1300. "op" '(org-pomodoro :which-key "Pomodoro"))
  1301. #+END_SRC
  1302. ** Writegood Mode
  1303. #+NAME: emacs-writegood-package
  1304. #+BEGIN_SRC nix
  1305. epkgs.writegood-mode
  1306. #+END_SRC
  1307. Writegood Mode[fn:50] is an Emacs[fn:2] minor mode to aid in finding common writing problems. It highlights the text based on the following criteria:
  1308. + Weasel Words
  1309. + Passive Voice
  1310. + Duplicate Words
  1311. #+NAME: emacs-writegood-elisp
  1312. #+BEGIN_SRC emacs-lisp
  1313. ;; Configure `writegood-mode'.
  1314. (dotfiles/leader
  1315. "tg" '(writegood-mode :which-key "Grammar"))
  1316. #+END_SRC
  1317. ** Aspell
  1318. #+NAME: emacs-aspell-extras
  1319. #+BEGIN_SRC nix
  1320. pkgs.aspell
  1321. pkgs.aspellDicts.en
  1322. pkgs.aspellDicts.en-science
  1323. pkgs.aspellDicts.en-computers
  1324. #+END_SRC
  1325. GNU Aspell[fn:51] 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.
  1326. #+NAME: emacs-aspell-elisp
  1327. #+BEGIN_SRC emacs-lisp
  1328. ;; Use `aspell' as a drop-in replacement for `ispell'.
  1329. (setq ispell-program-name "aspell"
  1330. ispell-eextra-args '("--sug-mode=fast"))
  1331. ;; Configure the built-in `flyspell-mode'.
  1332. (dotfiles/leader
  1333. "ts" '(flyspell-mode :which-key "Spelling"))
  1334. #+END_SRC
  1335. ** Hugo
  1336. #+NAME: emacs-hugo-extras
  1337. #+BEGIN_SRC nix
  1338. pkgs.hugo
  1339. #+END_SRC
  1340. Hugo[fn:52] is one of the most popular open-source static site generators.
  1341. #+NAME: emacs-hugo-package
  1342. #+BEGIN_SRC nix
  1343. epkgs.ox-hugo
  1344. #+END_SRC
  1345. Ox-Hugo[fn:53] is an Org-Mode[fn:43] exporter for Hugo[fn:52] compabile markdown. I post nonsense on my Personal Blog[fn:54], and share my notes on various textbooks, articles, and software Here[fn:55].
  1346. #+NAME: emacs-hugo-elisp
  1347. #+BEGIN_SRC emacs-lisp
  1348. ;; Configure `ox-hugo' as an `org-mode-export' backend.
  1349. (require 'ox-hugo)
  1350. ;; Capture templates.
  1351. ;; Personal blog post.
  1352. (add-to-list 'org-roam-capture-templates
  1353. '("p" "Post" plain (function org-roam-capture--get-point)
  1354. "%?"
  1355. :file-name "docs/posts/${slug}"
  1356. :unnarrowed t
  1357. :head
  1358. "
  1359. ,#+TITLE: ${title}
  1360. ,#+AUTHOR: Christopher James Hayward
  1361. ,#+DATE: %<%Y-%m-%d>
  1362. ,#+OPTIONS: num:nil todo:nil tasks:nil
  1363. ,#+EXPORT_FILE_NAME: ${slug}
  1364. ,#+ROAM_KEY: https://chrishayward.xyz/posts/${slug}/
  1365. ,#+HUGO_BASE_DIR: ../
  1366. ,#+HUGO_AUTO_SET_LASTMOD: t
  1367. ,#+HUGO_SECTION: posts
  1368. ,#+HUGO_DRAFT: true
  1369. "))
  1370. ;; Shared notes.
  1371. (add-to-list 'org-roam-capture-templates
  1372. '("n" "Notes" plain (function org-roam-capture--get-point)
  1373. "%?"
  1374. :file-name "docs/notes/${slug}"
  1375. :unnarrowed t
  1376. :head
  1377. "
  1378. ,#+TITLE: ${title}
  1379. ,#+AUTHOR: Christopher James Hayward
  1380. ,#+OPTIONS: num:nil todo:nil tasks:nil
  1381. ,#+EXPORT_FILE_NAME: ${slug}
  1382. ,#+ROAM_KEY: https://chrishayward.xyz/notes/${slug}/
  1383. ,#+HUGO_BASE_DIR: ../
  1384. ,#+HUGO_AUTO_SET_LASTMOD: t
  1385. ,#+HUGO_SECTION: notes
  1386. ,#+HUGO_DRAFT: true
  1387. "))
  1388. #+END_SRC
  1389. ** Reveal
  1390. #+NAME: emacs-reveal-package
  1391. #+BEGIN_SRC nix
  1392. epkgs.ox-reveal
  1393. #+END_SRC
  1394. Reveal.js[fn:56] is an open source HTML presentation framework. It enables anyone with a web browser to create fully-featured and beautiful presentations for free. Presentations with Reveal.js[fn:56] are built on open web technologies. That means anything you can do on the web, you can do in your presentation. Ox Reveal[fn:57] is an Org Mode[fn:43] export backend.
  1395. #+NAME: emacs-reveal-elisp
  1396. #+BEGIN_SRC emacs-lisp
  1397. ;; Configure `ox-reveal' as an `org-mode-export' backend.
  1398. (require 'ox-reveal)
  1399. ;; Don't rely on any local software.
  1400. (setq org-reveal-root "https://cdn.jsdelivr.net/npm/reveal.js")
  1401. ;; Create a capture template.
  1402. (add-to-list 'org-roam-capture-templates
  1403. '("s" "Slides" plain (function org-roam-capture--get-point)
  1404. "%?"
  1405. :file-name "docs/slides/${slug}"
  1406. :unnarrowed t
  1407. :head
  1408. "
  1409. ,#+TITLE: ${title}
  1410. ,#+AUTHOR: Christopher James Hayward
  1411. ,#+EMAIL: chris@chrishayward.xyz
  1412. ,#+REVEAL_ROOT: https://cdn.jsdelivr.net/npm/reveal.js
  1413. ,#+REVEAL_THEME: serif
  1414. ,#+EXPORT_FILE_NAME: ${slug}
  1415. ,#+OPTIONS: reveal_title_slide:nil
  1416. ,#+OPTIONS: num:nil toc:nil todo:nil tasks:nil tags:nil
  1417. ,#+OPTIONS: skip:nil author:nil email:nil creator:nil timestamp:nil
  1418. "))
  1419. #+END_SRC
  1420. ** Passwords
  1421. #+NAME: emacs-pass-extras
  1422. #+BEGIN_SRC nix
  1423. pkgs.pass
  1424. #+END_SRC
  1425. With Pass[fn:58], each password lives inside of an encrypted =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.
  1426. #+NAME: emacs-pass-package
  1427. #+BEGIN_SRC nix
  1428. epkgs.password-store
  1429. #+END_SRC
  1430. Configure keybindings for passwords behind =SPC p=:
  1431. | Key | Description |
  1432. |-----+---------------------|
  1433. | p | Copy a password |
  1434. | r | Rename a password |
  1435. | g | Generate a password |
  1436. #+NAME: emacs-pass-elisp
  1437. #+BEGIN_SRC emacs-lisp
  1438. ;; Set the path to the password store.
  1439. (setq password-store-dir (expand-file-name "~/.password-store"))
  1440. ;; Apply custom keybindings.
  1441. (dotfiles/leader
  1442. "p" '(:ignore t :which-key "Passwords")
  1443. "pp" '(password-store-copy :which-key "Copy")
  1444. "pr" '(password-store-rename :which-key "Rename")
  1445. "pg" '(password-store-generate :which-key "Generate"))
  1446. #+END_SRC
  1447. ** MU4E
  1448. #+NAME: emacs-mu4e-extras
  1449. #+BEGIN_SRC nix
  1450. pkgs.mu
  1451. pkgs.isync
  1452. #+END_SRC
  1453. #+NAME: emacs-mu4e-package
  1454. #+BEGIN_SRC nix
  1455. epkgs.mu4e-alert
  1456. #+END_SRC
  1457. #+NAME: emacs-mu4e-config
  1458. #+BEGIN_SRC nix
  1459. home.file.".mbsyncrc" = {
  1460. text = ''
  1461. IMAPStore xyz-remote
  1462. Host mail.chrishayward.xyz
  1463. User chris@chrishayward.xyz
  1464. PassCmd "pass chrishayward.xyz/chris"
  1465. SSLType IMAPS
  1466. MaildirStore xyz-local
  1467. Path ~/.cache/mail/
  1468. Inbox ~/.cache/mail/inbox
  1469. SubFolders Verbatim
  1470. Channel xyz
  1471. Far :xyz-remote:
  1472. Near :xyz-local:
  1473. Patterns * !Archives
  1474. Create Both
  1475. Expunge Both
  1476. SyncState *
  1477. '';
  1478. };
  1479. #+END_SRC
  1480. #+BEGIN_SRC sh
  1481. mbsync -a
  1482. mu init --maildir="~/.cache/mail" --my-address="chris@chrishayward.xyz"
  1483. mu index
  1484. #+END_SRC
  1485. #+NAME: emacs-mu4e-elisp
  1486. #+BEGIN_SRC emacs-lisp
  1487. ;; Add the `mu4e' shipped with `mu' to the load path.
  1488. (add-to-list 'load-path "/etc/profiles/per-user/chris/share/emacs/site-lisp/mu4e/")
  1489. (require 'mu4e)
  1490. ;; Confiugure `mu4e'.
  1491. (setq mu4e-maildir "~/.cache/mail"
  1492. mu4e-update-interval (* 5 60)
  1493. mu4e-get-mail-command "mbsync -a"
  1494. mu4e-compose-format-flowed t
  1495. mu4e-change-filenames-when-moving t
  1496. mu4e-compose-signature (concat "Chris Hayward\n"
  1497. "chris@chrishayward.xyz"))
  1498. ;; Sign all outbound email with GPG.
  1499. (add-hook 'message-send-hook 'mml-secure-message-sign-pgpmime)
  1500. (setq message-send-mail-function 'smtpmail-send-it
  1501. mml-secure-openpgp-signers '("37AB1CB72B741E478CA026D43025DCBD46F81C0F"))
  1502. ;; Setup `mu4e' accounts.
  1503. (setq mu4e-contexts
  1504. (list
  1505. ;; Main
  1506. ;; chris@chrishayward.xyz
  1507. (make-mu4e-context
  1508. :name "Main"
  1509. :match-func
  1510. (lambda (msg)
  1511. (when msg
  1512. (string-prefix-p "/Main" (mu4e-message-field msg :maildir))))
  1513. :vars
  1514. '((user-full-name . "Christopher James Hayward")
  1515. (user-mail-address . "chris@chrishayward.xyz")
  1516. (smtpmail-smtp-server . "mail.chrishayward.xyz")
  1517. (smtpmail-smtp-service . 587)
  1518. (smtpmail-stream-type . starttls)))))
  1519. ;; Setup `mu4e-alert'.
  1520. (setq mu4e-alert-set-default-style 'libnotify)
  1521. (mu4e-alert-enable-notifications)
  1522. (mu4e-alert-enable-mode-line-display)
  1523. ;; Open the `mu4e' dashboard.
  1524. (dotfiles/leader
  1525. "m" '(mu4e :which-key "Mail"))
  1526. #+END_SRC
  1527. ** Projectile
  1528. #+NAME: emacs-projectile-package
  1529. #+BEGIN_SRC nix
  1530. epkgs.projectile
  1531. #+END_SRC
  1532. Projectile[fn:59] is a project interaction library for GNU/Emacs[fn:2]. Its goal is to provide a nice set of features operating on a project level, without introducing external dependencies.
  1533. #+NAME: emacs-projectile-elisp
  1534. #+BEGIN_SRC emacs-lisp
  1535. ;; Configure the `projectile-project-search-path'.
  1536. (setq projectile-project-search-path '("~/.local/source"))
  1537. (projectile-mode +1)
  1538. #+END_SRC
  1539. ** LSP Mode
  1540. #+NAME: emacs-lsp-package
  1541. #+BEGIN_SRC nix
  1542. epkgs.lsp-mode
  1543. epkgs.lsp-ui
  1544. #+END_SRC
  1545. The Language Server Protocol (LSP)[fn:60] defines the protocol used between an Editor or IDE, and a language server that provides features like:
  1546. + Auto Complete
  1547. + Go To Defintion
  1548. + Find All References
  1549. #+NAME: emacs-lsp-elisp
  1550. #+BEGIN_SRC emacs-lisp
  1551. ;; Configure `lsp-mode'.
  1552. (setq lsp-idle-delay 0.5
  1553. lsp-prefer-flymake t)
  1554. ;; Configure `lsp-ui'.
  1555. (setq lsp-ui-doc-position 'at-point
  1556. lsp-ui-doc-delay 0.5)
  1557. #+END_SRC
  1558. ** Company Mode
  1559. #+NAME: emacs-company-package
  1560. #+BEGIN_SRC nix
  1561. epkgs.company
  1562. #+END_SRC
  1563. Company[fn:61] is a text completion framework for GNU/Emacs[fn:2]. The name stands for =Complete Anything=. It uses pluggable back-ends and front-ends to retieve and display completion candidates.
  1564. #+NAME: emacs-company-elisp
  1565. #+BEGIN_SRC emacs-lisp
  1566. ;; Configure `company-mode'.
  1567. (setq company-backend 'company-capf
  1568. lsp-completion-provider :capf)
  1569. ;; Enable it globally.
  1570. (global-company-mode +1)
  1571. #+END_SRC
  1572. ** Go Mode
  1573. #+NAME: emacs-golang-package
  1574. #+BEGIN_SRC nix
  1575. epkgs.go-mode
  1576. #+END_SRC
  1577. Go Mode[fn:62] is a major mode for editing Golang[fn:14] source code in GNU/Emacs[fn:2].
  1578. #+NAME: emacs-golang-elisp
  1579. #+BEGIN_SRC emacs-lisp
  1580. ;; Configure `go-mode' to work with `lsp-mode'.
  1581. (defun dotfiles/go-hook ()
  1582. (add-hook 'before-save-hook #'lsp-format-buffer t t)
  1583. (add-hook 'before-save-hook #'lsp-organize-imports t t))
  1584. ;; Configure a custom `before-save-hook'.
  1585. (add-hook 'go-mode-hook #'dotfiles/go-hook)
  1586. #+END_SRC
  1587. ** Python Mode
  1588. #+NAME: emacs-python-package
  1589. #+BEGIN_SRC nix
  1590. epkgs.pretty-mode
  1591. #+END_SRC
  1592. The built in Python Mode[fn:63] has a nice feature set for working with Python[fn:18] code in GNU/Emacs[fn:2]. It is complimented with the addition of an LSP[fn:60] server. These tools are included in the Development Shell[fn:13] for Python[fn:18].
  1593. #+NAME: emacs-python-elisp
  1594. #+BEGIN_SRC emacs-lisp
  1595. ;; Configure `pretty-mode' to work with `python-mode'.
  1596. (add-hook 'python-mode-hook
  1597. (lambda ()
  1598. (turn-on-pretty-mode)))
  1599. #+END_SRC
  1600. ** PlantUML
  1601. #+NAME: emacs-plantuml-extras
  1602. #+BEGIN_SRC nix
  1603. pkgs.plantuml
  1604. #+END_SRC
  1605. PlantUML[fn:64] is an open-source tool allowing users to create diagrams from a plain-text language. Besides various UML diagrams, PlantUML[fn:64] has support for various other software developmented related formats, as well as visualizations of =JSON= and =YAML= files.
  1606. #+NAME: emacs-plantuml-package
  1607. #+BEGIN_SRC nix
  1608. epkgs.plantuml-mode
  1609. #+END_SRC
  1610. PlantUML Mode[fn:65] is a major mode for editing PlantUML[fn:64] sources in GNU/Emacs[fn:2].
  1611. #+NAME: emacs-plantuml-elisp
  1612. #+BEGIN_SRC emacs-lisp
  1613. ;; Configure `plantuml-mode'.
  1614. (setq plantuml-default-exec-mode 'executable)
  1615. #+END_SRC
  1616. ** Swiper
  1617. #+NAME: emacs-swiper-package
  1618. #+BEGIN_SRC nix
  1619. epkgs.ivy
  1620. epkgs.counsel
  1621. epkgs.ivy-rich
  1622. epkgs.ivy-posframe
  1623. epkgs.ivy-prescient
  1624. #+END_SRC
  1625. Ivy (Swiper)[fn:66] is a generic completion mechanism for GNU/Emacs[fn:2]. 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.
  1626. #+NAME: emacs-swiper-elisp
  1627. #+BEGIN_SRC emacs-lisp
  1628. ;; Configure `ivy'.
  1629. (setq counsel-linux-app-format-function
  1630. #'counsel-linux-app-format-function-name-only)
  1631. (ivy-mode +1)
  1632. (counsel-mode +1)
  1633. ;; Configure `ivy-rich'.
  1634. (ivy-rich-mode +1)
  1635. ;; Configure `ivy-posframe'.
  1636. (setq ivy-posframe-parameters '((parent-frame nil))
  1637. ivy-posframe-display-functions-alist '((t . ivy-posframe-display)))
  1638. (ivy-posframe-mode +1)
  1639. ;; Configure `ivy-prescient'.
  1640. (setq ivy-prescient-enable-filtering nil)
  1641. (ivy-prescient-mode +1)
  1642. #+END_SRC
  1643. ** Transparency
  1644. It's possible to control the frame opacity in GNU/Emacs[fn:2]. Unlike other transparency hacks, it's not merely showing the desktop background image, but is true transparency -- you can se other windows behind the Emacs[fn:2] window.
  1645. #+NAME: emacs-transparency-elisp
  1646. #+BEGIN_SRC emacs-lisp
  1647. ;; Configure the default frame transparency.
  1648. (set-frame-parameter (selected-frame) 'alpha '(95 . 95))
  1649. (add-to-list 'default-frame-alist '(alpha . (95 . 95)))
  1650. #+END_SRC
  1651. ** Doom Themes
  1652. #+NAME: emacs-doom-themes-package
  1653. #+BEGIN_SRC nix
  1654. epkgs.doom-themes
  1655. #+END_SRC
  1656. Doom Themes[fn:67] is a theme megapack for GNU/Emacs[fn:2], inspired by community favourites.
  1657. #+NAME: emacs-doom-themes-elisp
  1658. #+BEGIN_SRC emacs-lisp
  1659. ;; Include modern themes from `doom-themes'.
  1660. (setq doom-themes-enable-bold t
  1661. doom-themes-enable-italic t)
  1662. ;; Load the `doom-moonlight' theme.
  1663. (load-theme 'doom-moonlight t)
  1664. (doom-modeline-mode +1)
  1665. ;; Load a new theme with <SPC> t t.
  1666. (dotfiles/leader
  1667. "tt" '(counsel-load-theme :which-key "Theme"))
  1668. #+END_SRC
  1669. ** Doom Modeline
  1670. #+NAME: emacs-doom-modeline-package
  1671. #+BEGIN_SRC nix
  1672. epkgs.doom-modeline
  1673. #+END_SRC
  1674. Doom Modeline[fn:68] is a fancy and fast modeline inspired by minimalism design. It's integrated into Centaur Emacs, Doom Emacs, and Spacemacs.
  1675. #+NAME: emacs-doom-modeline-elisp
  1676. #+BEGIN_SRC emacs-lisp
  1677. ;; Add the `doom-modeline' after initialization.
  1678. (add-hook 'after-init-hook 'doom-modeline-mode)
  1679. (setq doom-modeline-height 16
  1680. doom-modeline-icon t)
  1681. #+END_SRC
  1682. * Footnotes
  1683. [fn:1] https://gnu.org
  1684. [fn:2] https://gnu.org/software/emacs/
  1685. [fn:3] https://literateprogramming.com/knuthweb.pdf
  1686. [fn:4] https://nixos.org/manual/nixos/stable
  1687. [fn:5] https://nixos.org/manual/nix/stable
  1688. [fn:6] https://nixos.org/manual/nixpkgs/stable
  1689. [fn:7] https://github.com/nix-community/home-manager
  1690. [fn:8] https://github.com/nix-community/emacs-overlay
  1691. [fn:9] https://github.com/nixos/nixos-hardware
  1692. [fn:10] https://qemu.org
  1693. [fn:11] https://github.com/ch11ng/exwm
  1694. [fn:12] https://evil.readthedocs.io/en/latest/overview.html
  1695. [fn:13] https://nixos.org/manual/nix/unstable/command-ref/nix-shell.html
  1696. [fn:14] https://golang.org
  1697. [fn:15] https://grpc.io
  1698. [fn:16] https://iso.org/standard/74528.html
  1699. [fn:17] https://en.wikipedia.org/wiki/C++
  1700. [fn:18] https://python.org
  1701. [fn:19] https://x.org/wiki/
  1702. [fn:20] https://wayland.freedesktop.org
  1703. [fn:21] https://nixos.wiki/wiki/Flakes
  1704. [fn:22] https://nix-community.cachix.org
  1705. [fn:23] https://en.wikipedia.org/wiki/Firefox
  1706. [fn:24] https://moonlight-stream.org
  1707. [fn:25] https://teamviewer.com
  1708. [fn:26] https://git-scm.com
  1709. [fn:27] https://emacswiki.org/emacs/LearnEmacsLisp
  1710. [fn:28] https://neovim.io
  1711. [fn:29] https://gtk.org
  1712. [fn:30] https://github.com/nixos/nix-mode
  1713. [fn:31] https://github.com/noctuid/general.el
  1714. [fn:32] https://github.com/justbur/emacs-which-key
  1715. [fn:33] https://emacswiki.org/emacs/eww
  1716. [fn:34] https://emacswiki.org/emacs/DiredMode
  1717. [fn:35] https://emacswiki.org/emacs/DiredExtra#Dired_X
  1718. [fn:36] https://github.com/domtronn/all-the-icons.el
  1719. [fn:37] https://github.com/iqbalansari/emacs-emojify
  1720. [fn:38] https://gnu.org/software/emacs/manual/html_mono/eshell.html
  1721. [fn:39] https://github.com/akermu/emacs-libvterm
  1722. [fn:40] https://github.com/neovim/libvterm
  1723. [fn:41] https://magit.vc
  1724. [fn:42] https://github.com/skeeto/elfeed
  1725. [fn:43] https://orgmode.org
  1726. [fn:44] https://github.com/org-roam/org-roam
  1727. [fn:45] https://zettelkasten.de
  1728. [fn:46] https://github.com/org-roam/org-roam-server
  1729. [fn:47] https://orgmode.org/worg/org-contrib/org-drill.html
  1730. [fn:48] https://marcinkoziej/org-pomodoro
  1731. [fn:49] https://en.wikipedia.org/wiki/Pomodoro_Technique
  1732. [fn:50] https://github.com/bnbeckwith/writegood-mode
  1733. [fn:51] https://aspell.net
  1734. [fn:52] https://gohugo.io
  1735. [fn:53] https://oxhugo.scripter.co
  1736. [fn:54] https://chrishayward.xyz/posts/
  1737. [fn:55] https://chrishayward.xyz/notes/
  1738. [fn:56] https://revealjs.com
  1739. [fn:57] https://github.com/hexmode/ox-reveal
  1740. [fn:58] https://password-store.org
  1741. [fn:59] https://projectile.mx
  1742. [fn:60] https://microsoft.github.io/language-server-protocol
  1743. [fn:61] https://company-mode.github.io
  1744. [fn:62] https://emacswiki.org/emacs/GoMode
  1745. [fn:63] https://emacswiki.org/emacs/PythonProgrammingInEmacs
  1746. [fn:64] https://plantuml.com
  1747. [fn:65] https://github.com/skuro/plantuml-mode
  1748. [fn:66] https://github.com/abo-abo/swiper
  1749. [fn:67] https://github.com/hlissner/emacs-doom-themes
  1750. [fn:68] https://github.com/seagle0128/doom-modeline
  1751. [fn:69] https://laptopmedia.com/laptop-specs/acer-nitro-5-an515-53-2