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.

2837 lines
81 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
3 years ago
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
  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. #+ATTR_ORG: :width 420px
  15. #+ATTR_HTML: :width 420px
  16. #+ATTR_LATEX: :width 420px
  17. [[./docs/images/desktop-example.png]]
  18. Built for Life, Liberty, and the Open Road.
  19. + 100% Immutable
  20. + 100% Declarative
  21. + 100% Reproducible
  22. * Introduction
  23. 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.
  24. #+NAME: file-warning
  25. #+BEGIN_SRC text
  26. This file is controlled by /etc/dotfiles/README.org
  27. #+END_SRC
  28. ** Getting Started
  29. 1) Download the latest version of NixOS https://nixos.org/download.html
  30. 2) Partition drives and mount the file system https://nixos.org/manual/nixos/stable/#sec-installation-partitioning
  31. 3) Clone the project to =/mnt/etc/dotfiles= ~git clone git@git.chrishayward.xyz:chris/dotfiles /mnt/etc/dotfiles~
  32. 4) Load the default shell environment ~nix-shell /mnt/etc/dotfiles~
  33. 5) Install the default system ~sudo nixos-install --flake /mnt/etc/dotfiles#nixos~
  34. 6) Reboot and login, start a graphical system with ~startx~
  35. ** Making Changes
  36. 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:
  37. + boot :: Build the new configuration and make it the boot default, without activation
  38. + test :: Build and activate the new configuration, without adding it to the boot menu
  39. + switch :: Build and activate the new configuration, making it the new boot default
  40. + build :: Build the new configuration, without activation, nor adding it to the boot menu
  41. + build-vm :: Build a script that starts a virtual machine with the desired configuration
  42. #+BEGIN_SRC shell
  43. # Build and activate a new configuration.
  44. sudo nixos-rebuild switch --flake $FLAKE#$HOSTNAME
  45. #+END_SRC
  46. 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.
  47. #+BEGIN_SRC shell
  48. # Rollback to the previous generation.
  49. sudo nixos-rebuild switch --rollback
  50. #+END_SRC
  51. ** Docker Container
  52. 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.
  53. #+BEGIN_SRC conf :tangle Dockerfile
  54. # Derive from the official image.
  55. FROM nixos/nix
  56. # Add the unstable channel.
  57. RUN nix-channel --add https://nixos.org/channels/nixpkgs-unstable nixpkgs
  58. RUN nix-channel --update
  59. # Setup the default environment.
  60. WORKDIR /etc/dotfiles
  61. COPY . .
  62. # Load the default system shell.
  63. RUN nix-shell /etc/dotfiles
  64. #+END_SRC
  65. * Operating System
  66. 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.
  67. #+BEGIN_SRC nix :noweb yes :tangle flake.nix
  68. # <<file-warning>>
  69. {
  70. description = "<<description>>";
  71. inputs = {
  72. <<os-nixpkgs>>
  73. <<os-home-manager>>
  74. <<os-emacs-overlay>>
  75. <<os-nixos-hardware>>
  76. <<os-nix-on-droid>>
  77. };
  78. outputs = inputs @ { self, nixpkgs, nixpkgs-unstable, ... }: {
  79. nixosConfigurations = {
  80. <<host-default>>
  81. <<host-acernitro>>
  82. <<host-raspberry>>
  83. <<host-homecloud>>
  84. <<host-zero-one>>
  85. <<host-zero-two>>
  86. <<host-android>>
  87. };
  88. };
  89. }
  90. #+END_SRC
  91. ** Nixpkgs
  92. 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:
  93. 1) The current stable release
  94. 2) The Unstable branch following the latest development
  95. #+NAME: os-nixpkgs
  96. #+BEGIN_SRC nix
  97. nixpkgs.url = "nixpkgs/nixos-unstable";
  98. nixpkgs-unstable.url = "nixpkgs/master";
  99. #+END_SRC
  100. ** Home Manager
  101. 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.
  102. #+NAME: os-home-manager
  103. #+BEGIN_SRC nix
  104. home-manager.url = "github:nix-community/home-manager";
  105. home-manager.inputs.nixpkgs.follows = "nixpkgs";
  106. #+END_SRC
  107. ** Emacs Overlay
  108. 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.
  109. #+NAME: os-emacs-overlay
  110. #+BEGIN_SRC nix
  111. emacs-overlay.url = "github:nix-community/emacs-overlay";
  112. #+END_SRC
  113. ** NixOS Hardware
  114. 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.
  115. #+NAME: os-nixos-hardware
  116. #+BEGIN_SRC nix
  117. nixos-hardware.url = "github:nixos/nixos-hardware";
  118. #+END_SRC
  119. ** Nix On Droid
  120. Nix On Droid[fn:10] is a deployment of the Nix[fn:5] Package Manager on Android, in a single-click installable package. It does not require =root=, user namespace support, or disabling SELinux, but relies on =proot=. It has no relation to the Termux distribution.
  121. #+NAME: os-nix-on-droid
  122. #+BEGIN_SRC nix
  123. nix-on-droid.url = "github:t184256/nix-on-droid/master";
  124. nix-on-droid.inputs.nixpkgs.follows = "nixpkgs";
  125. #+END_SRC
  126. * Development Shells
  127. The command ~nix-shell~[fn:11] 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.
  128. Import this shell with ~nix-shell /etc/dotfiles/shell.nix~.
  129. #+BEGIN_SRC nix :noweb yes :tangle shell.nix
  130. # <<file-warning>>
  131. { pkgs ? import <nixpkgs> { } }:
  132. with pkgs;
  133. let
  134. nixBin = writeShellScriptBin "nix" ''
  135. ${nixFlakes}/bin/nix --option experimental-features "nix-command flakes" "$@"
  136. '';
  137. in mkShell {
  138. buildInputs = [
  139. git
  140. ];
  141. shellHook = ''
  142. export FLAKE="$(pwd)"
  143. export PATH="$FLAKE/bin:${nixBin}/bin:$PATH"
  144. '';
  145. }
  146. #+END_SRC
  147. ** Go
  148. Go[fn:12] 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.
  149. Import this shell with ~nix-shell /etc/dotfiles/shells/go.nix~
  150. #+BEGIN_SRC nix :noweb yes :tangle shells/go.nix
  151. # <<file-warning>>
  152. { pkgs ? import <nixpkgs> { } }:
  153. with pkgs;
  154. mkShell {
  155. buildInputs = [
  156. go
  157. gopls
  158. ];
  159. shellHook = ''
  160. export GO111MODULE=on
  161. export GOPATH=$XDG_DATA_HOME/go
  162. export PATH=$GOPATH/bin:$PATH
  163. '';
  164. }
  165. #+END_SRC
  166. ** Rust
  167. Rust[fn:13] 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[fn:13] achieves memory safety /without/ garbage collection, and reference counting is optional.
  168. Import this shell with ~nix-shell /etc/dotfiles/shells/rust.nix~.
  169. #+BEGIN_SRC nix :noweb yes :tangle shells/rust.nix
  170. # <<file-warning>>
  171. { pkgs ? import <nixpkgs> { } }:
  172. with pkgs;
  173. mkShell {
  174. buildInputs = [
  175. rustup
  176. ];
  177. shellHook = ''
  178. export RUSTUP_HOME="$XDG_DATA_HOME/rustup"
  179. export CARGO_HOME="$XDG_DATA_HOME/cargo"
  180. export PATH="$CARGO_HOME/bin:$PATH"
  181. '';
  182. }
  183. #+END_SRC
  184. ** Node
  185. Node.js[fn:14] 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. Node.js[fn:14] lets developers user JavaScript to write command line tools, and for server-side scripting to produce dynamic web page content.
  186. Import this shell with ~nix-shell /etc/dotfiles/shells/node.nix~.
  187. #+BEGIN_SRC nix :noweb yes :tangle shells/node.nix
  188. # <<file-warning>>
  189. { pkgs ? import <nixpkgs> { } }:
  190. with pkgs;
  191. mkShell {
  192. buildInputs = [
  193. nodejs
  194. yarn
  195. ];
  196. shellHook = ''
  197. export NPM_CONFIG_TMP="$XDG_RUNTIME_DIR/npm"
  198. export NPM_CONFIG_CACHE="$XDG_CACHE_HOME/npm"
  199. export NPM_CACHE_PREFIX="$XDG_CACHE_HOME/npm"
  200. export PATH="$(yarn global bin):$PATH"
  201. '';
  202. }
  203. #+END_SRC
  204. ** gRPC
  205. 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.
  206. Import this shell with ~nix-shell /etc/dotfiles/shells/grpc.nix~.
  207. #+BEGIN_SRC nix :noweb yes :tangle shells/grpc.nix
  208. # <<file-warning>>
  209. { pkgs ? import <nixpkgs> { } }:
  210. with pkgs;
  211. mkShell {
  212. buildInputs = [
  213. grpc
  214. grpc-tools
  215. grpcui
  216. grpcurl
  217. ];
  218. shellHook = ''
  219. '';
  220. }
  221. #+END_SRC
  222. ** C/C++
  223. 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.
  224. Import this shell with ~nix-shell /etc/dotfiles/shells/cc.nix~.
  225. #+BEGIN_SRC nix :noweb yes :tangle shells/cc.nix
  226. # <<file-warning>>
  227. { pkgs ? import <nixpkgs> { } }:
  228. with pkgs;
  229. mkShell {
  230. buildInputs = [
  231. gdb
  232. ccls
  233. cmake
  234. gnumake
  235. libstdcxx5
  236. gcc-unwrapped
  237. llvmPackages.libcxx
  238. ];
  239. shellHook = ''
  240. '';
  241. }
  242. #+END_SRC
  243. ** Python
  244. 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.
  245. Import this shell with ~nix-shell /etc/dotfiles/shells/python.nix~
  246. #+BEGIN_SRC nix :noweb yes :tangle shells/python.nix
  247. # <<file-warning>>
  248. { pkgs ? import <nixpkgs> { } }:
  249. with pkgs;
  250. mkShell {
  251. buildInputs = [
  252. python38Packages.pip
  253. python38Packages.pip-tools
  254. python38Packages.pyls-mypy
  255. python38Packages.pyls-isort
  256. python38Packages.pyls-black
  257. ];
  258. shellHook = ''
  259. '';
  260. }
  261. #+END_SRC
  262. * Host Configurations
  263. 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. It also makes it easier to share common configurations amongst all of the hosts, such as with pre-configured wireless networking:
  264. #+NAME: host-config-wifi
  265. #+BEGIN_SRC nix
  266. networking.wireless.networks.MyWiFi_5C1870.pskRaw =
  267. "409b3c85fef1c5737f284d2f82f20dc6023e41804e862d4fa26265ef8193b326";
  268. #+END_SRC
  269. 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:
  270. #+NAME: host-config-home
  271. #+BEGIN_SRC nix
  272. networking.hosts = {
  273. "192.168.3.105" = [ "gamingpc" ];
  274. # "" = [ "acernitro" ];
  275. "192.168.3.163" = [ "acernitro_" ];
  276. "192.168.3.182" = [ "raspberry" ];
  277. "192.168.3.123" = [ "raspberry_" ];
  278. # "" = [ "homecloud" ];
  279. # "" = [ "homecloud_" ];
  280. # "" = [ "zero-one" ];
  281. # "" = [ "zero-two" ];
  282. # "" = [ "android" ];
  283. };
  284. #+END_SRC
  285. ** Default
  286. The default host, built using QEMU[fn:19], 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:20] as the graphical environment.
  287. #+NAME: host-default
  288. #+BEGIN_SRC nix :noweb yes
  289. nixos = nixpkgs.lib.nixosSystem {
  290. system = "x86_64-linux";
  291. specialArgs = { inherit inputs; };
  292. modules = [
  293. ./hosts/nixos
  294. <<module-x11>>
  295. <<module-ssh>>
  296. <<module-flakes>>
  297. <<module-cachix>>
  298. <<module-home-manager>>
  299. ];
  300. };
  301. #+END_SRC
  302. Deploy this configuration with ~nixos-rebuild switch --flake /etc/dotfiles/#nixos~.
  303. #+BEGIN_SRC nix :noweb yes :tangle hosts/nixos/default.nix
  304. # <<file-warning>>
  305. { ... }:
  306. {
  307. imports = [
  308. ./configuration.nix
  309. ./hardware.nix
  310. ];
  311. }
  312. #+END_SRC
  313. *** Configuration
  314. 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.
  315. #+BEGIN_SRC nix :noweb yes :tangle hosts/nixos/configuration.nix
  316. # <<file-warning>>
  317. { config, pkgs, inputs, ... }:
  318. {
  319. time.timeZone = "America/Toronto";
  320. networking.hostName = "nixos";
  321. networking.useDHCP = false;
  322. networking.firewall.enable = false;
  323. networking.interfaces.ens3.useDHCP = true;
  324. <<host-config-home>>
  325. programs.mtr.enable = true;
  326. programs.fish.enable = true;
  327. programs.gnupg.agent.enable = true;
  328. users.users.chris = {
  329. shell = pkgs.fish;
  330. isNormalUser = true;
  331. extraGroups = [ "wheel" ];
  332. };
  333. }
  334. #+END_SRC
  335. *** Hardware
  336. The file system for this host is a single 24GB QCOW file, a format for disk images used by QEMU[fn:19]. The file can be recreated easily by following the steps listed in the NixOS[fn:4] installation manual, specifically the section on disk formatting.
  337. #+BEGIN_SRC nix :noweb yes :tangle hosts/nixos/hardware.nix
  338. # <<file-warning>>
  339. { config, lib, pkgs, modulesPath, ... }:
  340. {
  341. imports =
  342. [ (modulesPath + "/profiles/qemu-guest.nix")
  343. ];
  344. boot.initrd.availableKernelModules = [ "ata_piix" "floppy" "sd_mod" "sr_mod" ];
  345. boot.initrd.kernelModules = [ ];
  346. boot.kernelModules = [ ];
  347. boot.extraModulePackages = [ ];
  348. boot.loader.grub.enable = true;
  349. boot.loader.grub.version = 2;
  350. boot.loader.grub.device = "/dev/sda";
  351. fileSystems."/" =
  352. { device = "/dev/disk/by-uuid/fddc37ff-a442-41fa-afc4-abf878be7c5a";
  353. fsType = "ext4";
  354. };
  355. swapDevices =
  356. [ { device = "/dev/disk/by-uuid/5fc0e3df-e796-4fe2-8482-c6acaed9d36f"; }
  357. ];
  358. }
  359. #+END_SRC
  360. ** Acernitro
  361. My gaming laptop, the model is an Acer Nitro AN-515-53[fn:21]. 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.
  362. Here are the specs:
  363. | Slot | Component |
  364. |---------+---------------------------------------|
  365. | CPU | Intel Core i5-8300H |
  366. | GPU | NVIDIA GeForce GTX 1050Ti (4GB GDDR5) |
  367. | RAM | 16GB DDR4 |
  368. | Display | 15.6" Full HD (1920 x 1080), IPS |
  369. | Storage | 1000GB HDD |
  370. | Weight | 2.48kg (5.5 lbs) |
  371. #+NAME: host-acernitro
  372. #+BEGIN_SRC nix :noweb yes
  373. acernitro = nixpkgs.lib.nixosSystem {
  374. system = "x86_64-linux";
  375. specialArgs = { inherit inputs; };
  376. modules = [
  377. ./hosts/acernitro
  378. <<module-x11>>
  379. <<module-ssh>>
  380. <<module-flakes>>
  381. <<module-cachix>>
  382. <<module-nvidia>>
  383. <<module-firefox>>
  384. <<module-moonlight>>
  385. <<module-teamviewer>>
  386. <<module-home-manager>>
  387. ];
  388. };
  389. #+END_SRC
  390. Deploy this configuration with ~nixos-rebuild switch --flake /etc/dotfiles/#acernitro~.
  391. #+BEGIN_SRC nix :noweb yes :tangle hosts/acernitro/default.nix
  392. # <<file-warning>>
  393. { ... }:
  394. {
  395. imports = [
  396. ./configuration.nix
  397. ./hardware.nix
  398. ];
  399. }
  400. #+END_SRC
  401. *** Configuration
  402. This configuration is nearly identical to the default, except for a few key differences:
  403. + Enables sound
  404. + Applies the desired hostname
  405. + It adds support for =UEFI= systems
  406. + Enables support for wireless networking
  407. #+BEGIN_SRC nix :noweb yes :tangle hosts/acernitro/configuration.nix
  408. # <<file-warning>>
  409. { config, pkgs, inputs, ... }:
  410. {
  411. time.timeZone = "America/Toronto";
  412. networking.hostName = "acernitro";
  413. networking.firewall.enable = false;
  414. networking.wireless.enable = true;
  415. networking.wireless.userControlled.enable = true;
  416. networking.useDHCP = false;
  417. networking.interfaces.enp6s0f1.useDHCP = true;
  418. networking.interfaces.wlp0s20f3.useDHCP = true;
  419. <<host-config-wifi>>
  420. <<host-config-home>>
  421. services.xserver.dpi = 96;
  422. services.openssh.enable = true;
  423. services.printing.enable = true;
  424. programs.mtr.enable = true;
  425. programs.fish.enable = true;
  426. programs.gnupg.agent.enable = true;
  427. users.users.chris = {
  428. shell = pkgs.fish;
  429. isNormalUser = true;
  430. extraGroups = [ "wheel" ];
  431. };
  432. }
  433. #+END_SRC
  434. *** Hardware
  435. + Enables sound via PulseAudio
  436. + Adds support for the NVIDIA Hybrid GPU
  437. #+BEGIN_SRC nix :noweb yes :tangle hosts/acernitro/hardware.nix
  438. # <<file-warning>>
  439. { config, lib, pkgs, modulesPath, ... }:
  440. {
  441. imports =
  442. [ (modulesPath + "/installer/scan/not-detected.nix")
  443. ];
  444. boot.initrd.availableKernelModules = [ "xhci_pci" "ahci" "usb_storage" "sd_mod" "rtsx_pci_sdmmc" ];
  445. boot.initrd.kernelModules = [ ];
  446. boot.kernelModules = [ "kvm-intel" ];
  447. boot.extraModulePackages = [ ];
  448. boot.loader.systemd-boot.enable = true;
  449. boot.loader.efi.canTouchEfiVariables = true;
  450. sound.enable = true;
  451. hardware.pulseaudio.enable = true;
  452. hardware.pulseaudio.support32Bit = true;
  453. fileSystems."/" =
  454. { device = "/dev/disk/by-uuid/2f548eb9-47ce-4280-950f-9c6d1d162852";
  455. fsType = "ext4";
  456. };
  457. fileSystems."/boot" =
  458. { device = "/dev/disk/by-uuid/5BC3-73F3";
  459. fsType = "vfat";
  460. };
  461. swapDevices =
  462. [ { device = "/dev/disk/by-uuid/bef7bf62-d26f-45b1-a1f8-1227c2f8b26a"; }
  463. ];
  464. powerManagement.cpuFreqGovernor = lib.mkDefault "powersave";
  465. }
  466. #+END_SRC
  467. ** Raspberry
  468. The Raspberry Pi 400[fn:22] is your complete personal computer, built into a compact keyboard. It features a quad-core, 64-bit processor, 4GB of RAM, wireless networking, dual-display output, 4k video playback, as well as a 40-pin GPIO header. It's the most powerful Raspberry Pi computer yet.
  469. #+NAME: host-raspberry
  470. #+BEGIN_SRC nix :noweb yes
  471. raspberry = nixpkgs.lib.nixosSystem {
  472. system = "aarch64-linux";
  473. specialArgs = { inherit inputs; };
  474. modules = [
  475. ./hosts/raspberry
  476. <<module-x11>>
  477. <<module-ssh>>
  478. <<module-flakes>>
  479. <<module-cachix>>
  480. <<module-home-manager>>
  481. ];
  482. };
  483. #+END_SRC
  484. Deploy this configuration with ~sudo nixos-rebuild switch --flake /etc/dotfiles/#raspberry~.
  485. #+BEGIN_SRC nix :noweb yes :tangle hosts/raspberry/default.nix
  486. # <<file-warning>>
  487. { ... }:
  488. {
  489. imports = [
  490. ./configuration.nix
  491. ./hardware.nix
  492. ];
  493. }
  494. #+END_SRC
  495. *** Configuration
  496. #+BEGIN_SRC nix :noweb yes :tangle hosts/raspberry/configuration.nix
  497. # <<file-warning>>
  498. { config, pkgs, ... }:
  499. {
  500. networking.hostName = "raspberry";
  501. networking.firewall.enable = false;
  502. networking.networkmanager.enable = true;
  503. networking.interfaces.eth0.useDHCP = true;
  504. networking.interfaces.wlan0.useDHCP = true;
  505. <<host-config-home>>
  506. environment.systemPackages = [
  507. pkgs.libraspberrypi
  508. pkgs.raspberrypi-eeprom
  509. ];
  510. programs.fish.enable = true;
  511. programs.gnupg.agent.enable = true;
  512. users.users.chris = {
  513. shell = pkgs.fish;
  514. isNormalUser = true;
  515. extraGroups = [ "wheel" ];
  516. };
  517. }
  518. #+END_SRC
  519. *** Hardware
  520. This section is very much a work in progress. I have struggled to get this device to boot according to the NixOS documentation / wiki on the subject. It seems that when running with the vendored kernel there's an issue booting from the SD card. Nevertheless, the issue is avoided by using the standard kernel.
  521. #+BEGIN_SRC nix :noweb yes :tangle hosts/raspberry/hardware.nix
  522. # <<file-warning>>
  523. { config, pkgs, lib, inputs, ... }:
  524. {
  525. # imports = [
  526. # inputs.nixos-hardware.nixosModules.raspberry-pi-4
  527. # ];
  528. # boot.kernelPackages = pkgs.linuxPackages_rpi4;
  529. boot.tmpOnTmpfs = true;
  530. boot.initrd.availableKernelModules = [ "usbhid" "usb_storage" ];
  531. boot.kernelParams = [
  532. "8250.nr_uarts=1"
  533. "console=ttyAMA0,115200"
  534. "console=tty1"
  535. "cma=128M"
  536. ];
  537. boot.loader.grub.enable = false;
  538. boot.loader.generic-extlinux-compatible.enable = true;
  539. boot.loader.raspberryPi = {
  540. enable = true;
  541. version = 4;
  542. firmwareConfig = ''
  543. dtparam=sd_poll_once=on
  544. dtparam=audio=on
  545. '';
  546. };
  547. sound.enable = true;
  548. hardware.pulseaudio.enable = true;
  549. hardware.enableRedistributableFirmware = true;
  550. # hardware.raspberry-pi."4".fkms-3d.enable = true;
  551. fileSystems = {
  552. "/" = {
  553. device = "/dev/disk/by-uuid/44444444-4444-4444-8888-888888888888";
  554. fsType = "ext4";
  555. options = [ "noatime" ];
  556. };
  557. };
  558. powerManagement.cpuFreqGovernor = "ondemand";
  559. }
  560. #+END_SRC
  561. ** TODO Homecloud
  562. The Raspberry Pi Model B-8GB[fn:23] is the latest product in the popular Raspberry Pi range of computers. It offers groundbreaking increases in processor speed, multimedia performance, memory, and connectivity compared to the prior generation. On NixOS[fn:4], the Raspberry Pi family is /only/ supported on the =AArch64= platform, although there is community support for =armv6l= and =armv7l=.
  563. #+NAME: host-homecloud
  564. #+BEGIN_SRC nix :noweb yes
  565. homecloud = nixpkgs.lib.nixosSystem {
  566. system = "aarch64-linux";
  567. specialArgs = { inherit inputs; };
  568. modules = [
  569. ./hosts/homecloud
  570. <<module-ssh>>
  571. <<module-flakes>>
  572. <<module-cachix>>
  573. <<module-docker>>
  574. <<module-jellyfin>>
  575. ];
  576. };
  577. #+END_SRC
  578. Deploy this configuration with ~sudo nixos-rebuild switch --flake /etc/dotfiles/#homecloud~.
  579. #+BEGIN_SRC nix :noweb yes :tangle hosts/homecloud/default.nix
  580. # <<file-warning>
  581. { ... }:
  582. {
  583. imports = [
  584. ./configuration.nix
  585. ./hardware.nix
  586. ];
  587. }
  588. #+END_SRC
  589. *** TODO Configuration
  590. #+BEGIN_SRC nix :noweb yes :tangle hosts/homecloud/configuration.nix
  591. # <<file-warning>>
  592. { # TODO
  593. }
  594. #+END_SRC
  595. *** TODO Hardware
  596. #+BEGIN_SRC nix :noweb yes :tangle hosts/homecloud/hardware.nix
  597. # <<file-warning>>
  598. { # TODO
  599. }
  600. #+END_SRC
  601. ** TODO Zero-One
  602. TODO: Raspberry Pi Zero/Zero WH
  603. #+NAME: host-zero-one
  604. #+BEGIN_SRC nix
  605. zero-one = nixpkgs.lib.nixosSystem {
  606. system = "armv7l-linux";
  607. specialArgs = { inherit inputs; };
  608. modules = [
  609. ./hosts/zero-one
  610. ./modules/ssh.nix
  611. ./modules/flakes.nix
  612. ./modules/cachix.nix
  613. ];
  614. };
  615. #+END_SRC
  616. ** TODO Zero-Two
  617. #+NAME: host-zero-two
  618. #+BEGIN_SRC nix
  619. zero-two = nixpkgs.lib.nixosSystem {
  620. system = "armv7l-linux";
  621. specialArgs = { inherit inputs; };
  622. modules = [
  623. ./hosts/zero-two
  624. ./modules/ssh.nix
  625. ./modules/flakes.nix
  626. ./modules/cachix.nix
  627. ];
  628. };
  629. #+END_SRC
  630. ** TODO Android
  631. This is my Samsung Galaxy S10+[fn:24] running Nix On Droid[fn:10] with the experimental support for Flakes being used to manage the configuration.
  632. #+NAME: host-android
  633. #+BEGIN_SRC nix
  634. android = (inputs.nix-on-droid.lib.aarch64-linux.nix-on-droid {
  635. config = ./hosts/android/nix-on-droid.nix;
  636. }).activationPackage;
  637. #+END_SRC
  638. Build the activation package with ~nix build .#android --impure~, and activate it with =result/activate=.
  639. #+BEGIN_SRC nix :noweb yes :tangle hosts/android/nix-on-droid.nix
  640. # <<file-warning>>
  641. { pkgs, ... }:
  642. {
  643. environment.packages = [
  644. pkgs.git
  645. pkgs.vim
  646. pkgs.pass
  647. pkgs.gnupg
  648. pkgs.openssh
  649. ];
  650. }
  651. #+END_SRC
  652. * Module Definitions
  653. 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.
  654. ** X11
  655. #+NAME: module-x11
  656. #+BEGIN_SRC nix
  657. ./modules/x11.nix
  658. #+END_SRC
  659. X11, or X[fn:25] is the generic name for the X Window System Display Server. All graphical GNU/Linux[fn:1] applications connect to an X-Window[fn:25] (or Wayland[fn:26]) 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.
  660. #+BEGIN_SRC nix :noweb yes :tangle modules/x11.nix
  661. # <<file-warning>>
  662. { config, pkgs, ... }:
  663. {
  664. services.xserver.enable = true;
  665. services.xserver.layout = "us";
  666. services.xserver.libinput.enable = true;
  667. services.xserver.displayManager.startx.enable = true;
  668. environment = {
  669. systemPackages = with pkgs; [
  670. pkgs.sqlite
  671. pkgs.pfetch
  672. pkgs.cmatrix
  673. pkgs.asciiquarium
  674. ];
  675. extraInit = ''
  676. export XAUTHORITY=/tmp/Xauthority
  677. export xserverauthfile=/tmp/xserverauth
  678. [ -e ~/.Xauthority ] && mv -f ~/.Xauthority "$XAUTHORITY"
  679. [ -e ~/.serverauth.* ] && mv -f ~/.serverauth.* "$xserverauthfile"
  680. '';
  681. };
  682. services.picom.enable = true;
  683. services.printing.enable = true;
  684. fonts.fonts = with pkgs; [
  685. iosevka-bin
  686. emacs-all-the-icons-fonts
  687. ];
  688. }
  689. #+END_SRC
  690. ** SSH
  691. #+NAME: module-ssh
  692. #+BEGIN_SRC nix
  693. ./modules/ssh.nix
  694. #+END_SRC
  695. OpenSSH[fn:27] is a suite of secure networking utilities based on the Secure Shell Protocol, which provides a secure channel over an unsecured network in a client-server architecture. OpenSSH[fn:27] started as a fork of the free SSH program; later versions were proprietary software.
  696. Apply some configuration to the default settings:
  697. + Disable logging in as =root=
  698. + Disable password authentication
  699. #+BEGIN_SRC nix :noweb yes :tangle modules/ssh.nix
  700. # <<file-warning>>
  701. { config, pkgs, ... }:
  702. {
  703. services.openssh = {
  704. enable = true;
  705. permitRootLogin = false;
  706. passwordAuthentication = false;
  707. };
  708. }
  709. #+END_SRC
  710. ** Flakes
  711. #+NAME: module-flakes
  712. #+BEGIN_SRC nix
  713. ./modules/flakes.nix
  714. #+END_SRC
  715. Nix Flakes[fn:28] 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:28] 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:28] are not available unless explicitly enabled.
  716. #+BEGIN_SRC nix :noweb yes :tangle modules/flakes.nix
  717. # <<file-warning>>
  718. { config, pkgs, inputs, ... }:
  719. {
  720. nix = {
  721. package = pkgs.nixUnstable;
  722. extraOptions = ''
  723. experimental-features = nix-command flakes
  724. '';
  725. };
  726. nixpkgs = {
  727. config = { allowUnfree = true; };
  728. overlays = [ inputs.emacs-overlay.overlay ];
  729. };
  730. }
  731. #+END_SRC
  732. ** Cachix
  733. #+NAME: module-cachix
  734. #+BEGIN_SRC nix
  735. ./modules/cachix.nix
  736. #+END_SRC
  737. Cachix[fn:29] 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.
  738. #+BEGIN_SRC nix :noweb yes :tangle modules/cachix.nix
  739. # <<file-warning>>
  740. { config, ... }:
  741. {
  742. nix = {
  743. binaryCaches = [
  744. "https://nix-community.cachix.org"
  745. ];
  746. binaryCachePublicKeys = [
  747. "nix-community.cachix.org-1:mB9FSh9qf2dCimDSUo8Zy7bkq5CX+/rkCWyvRCYg3Fs="
  748. ];
  749. };
  750. }
  751. #+END_SRC
  752. ** Docker
  753. #+NAME: module-docker
  754. #+BEGIN_SRC nix
  755. ./modules/docker.nix
  756. #+END_SRC
  757. Docker [fn:30] is a set of platform as a service that uses 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.
  758. #+BEGIN_SRC nix :noweb yes :tangle modules/docker.nix
  759. { config, pkgs, ... }:
  760. {
  761. virtualisation.docker = {
  762. enable = true;
  763. enableOnBoot = true;
  764. autoPrune.enable = true;
  765. };
  766. }
  767. #+END_SRC
  768. ** NVIDIA
  769. #+NAME: module-nvidia
  770. #+BEGIN_SRC nix
  771. ./modules/nvidia.nix
  772. #+END_SRC
  773. #+BEGIN_SRC nix :noweb yes :tangle modules/nvidia.nix
  774. { config, pkgs, ... }:
  775. let
  776. myIntelBusId = "PCI:0:2:0";
  777. myNvidiaBusId = "PCI:1:0:0";
  778. myNvidiaOffload = pkgs.writeShellScriptBin "nvidia-offload" ''
  779. export __NV_PRIME_RENDER_OFFLOAD=1
  780. export __NV_PRIME_RENDER_OFFLOAD_PROVIDER=NVIDIA-G0
  781. export __GLX_VENDOR_LIBRARY_NAME=nvidia
  782. export __VK_LAYER_NV_optimus=NVIDIA_only
  783. exec -a "$0" "$@"
  784. '';
  785. in {
  786. # Add the offload script to the $PATH.
  787. environment.systemPackages = [ myNvidiaOffload ];
  788. # Enable the NVIDIA drivers.
  789. # NOTE: You may need to use either of the commands below:
  790. services.xserver.videoDrivers = [ "nvidia" ];
  791. # services.xserver.videoDrivers = [ "modesetting" "nvidia" ];
  792. # Configure `offload-mode'.
  793. hardware.nvidia.prime = {
  794. offload.enable = true;
  795. intelBusId = myIntelBusId;
  796. nvidiaBusId = myNvidiaBusId;
  797. };
  798. }
  799. #+END_SRC
  800. ** Firefox
  801. #+NAME: module-firefox
  802. #+BEGIN_SRC nix
  803. ./modules/firefox.nix
  804. #+END_SRC
  805. Firefox Browser[fn:31], 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.
  806. #+BEGIN_SRC nix :noweb yes :tangle modules/firefox.nix
  807. # <<file-warning>>
  808. { pkgs, ... }:
  809. {
  810. # NOTE: Use the binary until module is developed.
  811. environment.systemPackages = [
  812. pkgs.firefox-bin
  813. ];
  814. }
  815. #+END_SRC
  816. ** Jellyfin
  817. #+NAME: module-jellyfin
  818. #+BEGIN_SRC nix
  819. ./modules/jellyfin.nix
  820. #+END_SRC
  821. Jellyfin[fn:32] is a suite of multimedia applications designed to organize, manage, and share digital media files to networked devices. It consists of a server application installed on a machine, and another application running as a client on devices such as Smartphones, Tablets, SmartTVs, Streaming Media Players, Game Consoles, or in a Web Browser. It can also serve media to DLNA and Chromecast enabled devices. It's free and open-source software fork of Emby.
  822. #+BEGIN_SRC nix :noweb yes :tangle modules/jellyfin.nix
  823. # <<file-warning>>
  824. { config, pkgs, ... }:
  825. {
  826. services.jellyfin = {
  827. enable = true;
  828. };
  829. }
  830. #+END_SRC
  831. ** Moonlight
  832. #+NAME: module-moonlight
  833. #+BEGIN_SRC nix
  834. ./modules/moonlight.nix
  835. #+END_SRC
  836. Moonlight[fn:33] 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:33] is perfect for gaming on the go (or on GNU/Linux[fn:1]) without sacrificing the graphics and game selection available for the PC.
  837. #+BEGIN_SRC nix :noweb yes :tangle modules/moonlight.nix
  838. # <<file-warning>>
  839. { pkgs, ... }:
  840. {
  841. environment.systemPackages = [
  842. pkgs.moonlight-qt
  843. ];
  844. }
  845. #+END_SRC
  846. ** Teamviewer
  847. #+NAME: module-teamviewer
  848. #+BEGIN_SRC nix
  849. ./modules/teamviewer.nix
  850. #+END_SRC
  851. The Teamviewer[fn:34] remote connectivity cloud platform enables secure remote access to any device, across platforms, from anywhere, anytime. Teamviewer[fn:34] 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.
  852. #+BEGIN_SRC nix :noweb yes :tangle modules/teamviewer.nix
  853. # <<file-warning>>
  854. { pkgs, ... }:
  855. {
  856. # NOTE: Neither of these are working!
  857. # services.teamviewer.enable = true;
  858. # environment.systemPackages = [
  859. # pkgs.teamviewer
  860. # ];
  861. }
  862. #+END_SRC
  863. ** Home Manager
  864. 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.
  865. #+NAME: module-home-manager
  866. #+BEGIN_SRC nix :noweb yes
  867. inputs.home-manager.nixosModules.home-manager {
  868. home-manager.useGlobalPkgs = true;
  869. home-manager.useUserPackages = true;
  870. home-manager.users.chris = {
  871. imports = [
  872. <<module-git>>
  873. <<module-gpg>>
  874. <<module-vim>>
  875. <<module-gtk>>
  876. <<module-emacs>>
  877. ];
  878. };
  879. }
  880. #+END_SRC
  881. *** Git
  882. #+NAME: module-git
  883. #+BEGIN_SRC nix
  884. ./modules/git.nix
  885. #+END_SRC
  886. Git[fn:35] 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.
  887. #+BEGIN_SRC nix :noweb yes :tangle modules/git.nix
  888. # <<file-warning>>
  889. { pkgs, ... }:
  890. {
  891. programs.git = {
  892. enable = true;
  893. userName = "Christopher James Hayward";
  894. userEmail = "chris@chrishayward.xyz";
  895. signing = {
  896. key = "37AB1CB72B741E478CA026D43025DCBD46F81C0F";
  897. signByDefault = true;
  898. };
  899. };
  900. }
  901. #+END_SRC
  902. *** Gpg
  903. #+NAME: module-gpg
  904. #+BEGIN_SRC nix
  905. ./modules/gpg.nix
  906. #+END_SRC
  907. GNU Privacy Guard[fn:36] 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.
  908. #+BEGIN_SRC nix :noweb yes :tangle modules/gpg.nix
  909. # <<file-warning>>
  910. { pkgs, ... }:
  911. {
  912. services.gpg-agent = {
  913. enable = true;
  914. defaultCacheTtl = 1800;
  915. enableSshSupport = true;
  916. pinentryFlavor = "gtk2";
  917. };
  918. }
  919. #+END_SRC
  920. *** Vim
  921. #+NAME: module-vim
  922. #+BEGIN_SRC nix
  923. ./modules/vim.nix
  924. #+END_SRC
  925. Neovim[fn:37] is a project that seeks to aggressively refactor Vim in order to:
  926. + Simplify maintenance and encourage contributions
  927. + Split the work between multiple developers
  928. + Enable advanced UIs without core modification
  929. + Maximize extensibility
  930. #+BEGIN_SRC nix :noweb yes :tangle modules/vim.nix
  931. # <<file-warning>>
  932. { pkgs, ... }:
  933. {
  934. programs.neovim = {
  935. enable = true;
  936. viAlias = true;
  937. vimAlias = true;
  938. vimdiffAlias = true;
  939. extraConfig = ''
  940. set number relativenumber
  941. set nobackup
  942. '';
  943. extraPackages = [
  944. pkgs.nixfmt
  945. ];
  946. plugins = with pkgs.vimPlugins; [
  947. vim-nix
  948. vim-airline
  949. vim-polyglot
  950. ];
  951. };
  952. }
  953. #+END_SRC
  954. *** GTK
  955. #+NAME: module-gtk
  956. #+BEGIN_SRC nix
  957. ./modules/gtk.nix
  958. #+END_SRC
  959. GTK[fn:38] 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:26] and X11[fn:25] windowing systems.
  960. #+BEGIN_SRC nix :noweb yes :tangle modules/gtk.nix
  961. # <<file-warning>>
  962. { pkgs, ... }:
  963. {
  964. home.packages = [
  965. pkgs.arc-theme
  966. pkgs.arc-icon-theme
  967. pkgs.lxappearance
  968. ];
  969. home.file.".gtkrc-2.0" = {
  970. text = ''
  971. gtk-theme-name="Arc-Dark"
  972. gtk-icon-theme-name="Arc"
  973. gtk-font-name="Sans 10"
  974. gtk-cursor-theme-size=0
  975. gtk-toolbar-style=GTK_TOOLBAR_BOTH_HORIZ
  976. gtk-toolbar-icon-size=GTK_ICON_SIZE_LARGE_TOOLBAR
  977. gtk-button-images=0
  978. gtk-menu-images=0
  979. gtk-enable-event-sounds=1
  980. gtk-enable-input-feedback-sounds=1
  981. gtk-xft-antialias=1
  982. gtk-xft-hinting=1
  983. gtk-xft-hintstyle="hintmedium"
  984. '';
  985. };
  986. }
  987. #+END_SRC
  988. * Emacs Configuration
  989. #+NAME: module-emacs
  990. #+BEGIN_SRC nix
  991. ./modules/emacs.nix
  992. #+END_SRC
  993. GNU/Emacs[fn:2] is an extensible, customizable, free/libre text editor -- and more. At its core is an interpreter for Emacs Lisp[fn:36], a dialect of the Lisp programming language with extensions to support text editing. Other features include:
  994. + Highly customizable
  995. + Full Unicopde support
  996. + Content-aware editing modes
  997. + Complete built-in documentation
  998. + Wide range of functionality beyond text editing
  999. #+BEGIN_SRC nix :noweb yes :tangle modules/emacs.nix
  1000. # <<file-warning>>
  1001. { pkgs, ... }:
  1002. let
  1003. myEmacs = pkgs.emacsWithPackagesFromUsePackage {
  1004. config = ../README.org;
  1005. package = <<emacs-native-comp-package>>
  1006. alwaysEnsure = true;
  1007. alwaysTangle = true;
  1008. extraEmacsPackages = epkgs: [
  1009. # Required packages...
  1010. <<emacs-exwm-package>>
  1011. <<emacs-evil-package>>
  1012. <<emacs-general-package>>
  1013. <<emacs-which-key-package>>
  1014. # Optional packages.
  1015. <<emacs-org-package>>
  1016. <<emacs-org-roam-package>>
  1017. <<emacs-org-drill-package>>
  1018. <<emacs-pomodoro-package>>
  1019. <<emacs-writegood-package>>
  1020. <<emacs-hugo-package>>
  1021. <<emacs-reveal-package>>
  1022. <<emacs-pass-package>>
  1023. <<emacs-mu4e-package>>
  1024. <<emacs-dired-package>>
  1025. <<emacs-icons-package>>
  1026. <<emacs-emoji-package>>
  1027. <<emacs-eshell-package>>
  1028. <<emacs-vterm-package>>
  1029. <<emacs-magit-package>>
  1030. <<emacs-fonts-package>>
  1031. <<emacs-elfeed-package>>
  1032. <<emacs-nix-mode-package>>
  1033. <<emacs-projectile-package>>
  1034. <<emacs-lsp-package>>
  1035. <<emacs-company-package>>
  1036. <<emacs-golang-package>>
  1037. <<emacs-python-package>>
  1038. <<emacs-rustic-package>>
  1039. <<emacs-plantuml-package>>
  1040. <<emacs-swiper-package>>
  1041. <<emacs-desktop-package>>
  1042. <<emacs-doom-themes-package>>
  1043. <<emacs-doom-modeline-package>>
  1044. ];
  1045. };
  1046. in {
  1047. home.packages = [
  1048. <<emacs-exwm-extras>>
  1049. <<emacs-hugo-extras>>
  1050. <<emacs-pass-extras>>
  1051. <<emacs-mu4e-extras>>
  1052. <<emacs-aspell-extras>>
  1053. <<emacs-desktop-extras>>
  1054. <<emacs-plantuml-extras>>
  1055. <<emacs-nix-mode-extras>>
  1056. ];
  1057. programs.emacs = {
  1058. enable = true;
  1059. package = myEmacs;
  1060. };
  1061. <<emacs-exwm-config>>
  1062. <<emacs-exwm-xinitrc>>
  1063. <<emacs-mu4e-config>>
  1064. }
  1065. #+END_SRC
  1066. 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.
  1067. #+BEGIN_SRC emacs-lisp :noweb yes :tangle ~/.emacs.d/init.el
  1068. ;; <<file-warning>>
  1069. ;; Required inputs.
  1070. <<emacs-exwm-elisp>>
  1071. <<emacs-evil-elisp>>
  1072. <<emacs-general-elisp>>
  1073. <<emacs-which-key-elisp>>
  1074. ;; Optional inputs.
  1075. <<emacs-org-elisp>>
  1076. <<emacs-org-roam-elisp>>
  1077. <<emacs-org-drill-elisp>>
  1078. <<emacs-org-agenda-elisp>>
  1079. <<emacs-pomodoro-elisp>>
  1080. <<emacs-writegood-elisp>>
  1081. <<emacs-aspell-elisp>>
  1082. <<emacs-eww-elisp>>
  1083. <<emacs-hugo-elisp>>
  1084. <<emacs-reveal-elisp>>
  1085. <<emacs-pass-elisp>>
  1086. <<emacs-erc-elisp>>
  1087. <<emacs-mu4e-elisp>>
  1088. <<emacs-dired-elisp>>
  1089. <<emacs-icons-elisp>>
  1090. <<emacs-emoji-elisp>>
  1091. <<emacs-eshell-elisp>>
  1092. <<emacs-vterm-elisp>>
  1093. <<emacs-magit-elisp>>
  1094. <<emacs-fonts-elisp>>
  1095. <<emacs-elfeed-elisp>>
  1096. <<emacs-projectile-elisp>>
  1097. <<emacs-lsp-elisp>>
  1098. <<emacs-company-elisp>>
  1099. <<emacs-golang-elisp>>
  1100. <<emacs-python-elisp>>
  1101. <<emacs-rustic-elisp>>
  1102. <<emacs-plantuml-elisp>>
  1103. <<emacs-desktop-elisp>>
  1104. ;; User interface.
  1105. <<emacs-swiper-elisp>>
  1106. <<emacs-transparency-elisp>>
  1107. <<emacs-doom-themes-elisp>>
  1108. <<emacs-doom-modeline-elisp>>
  1109. #+END_SRC
  1110. 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=.
  1111. #+BEGIN_SRC emacs-lisp :noweb yes :tangle ~/.emacs.d/early-init.el
  1112. ;; <<file-warning>>
  1113. <<emacs-disable-ui-elisp>>
  1114. <<emacs-native-comp-elisp>>
  1115. <<emacs-backup-files-elisp>>
  1116. <<emacs-shell-commands-elisp>>
  1117. #+END_SRC
  1118. ** Disable UI
  1119. 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.
  1120. #+NAME: emacs-disable-ui-elisp
  1121. #+BEGIN_SRC emacs-lisp
  1122. ;; Disable unwanted UI elements.
  1123. (tooltip-mode -1)
  1124. (menu-bar-mode -1)
  1125. (tool-bar-mode -1)
  1126. (scroll-bar-mode -1)
  1127. ;; Fix the scrolling behaviour.
  1128. (setq scroll-conservatively 101)
  1129. ;; Fix mouse-wheel scrolling behaviour.
  1130. (setq mouse-wheel-follow-mouse t
  1131. mouse-wheel-progressive-speed t
  1132. mouse-wheel-scroll-amount '(3 ((shift) . 3)))
  1133. #+END_SRC
  1134. ** Native Comp
  1135. #+NAME: emacs-native-comp-package
  1136. #+BEGIN_SRC nix
  1137. pkgs.emacsGcc;
  1138. #+END_SRC
  1139. 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.
  1140. #+NAME: emacs-native-comp-elisp
  1141. #+BEGIN_SRC emacs-lisp
  1142. ;; Silence warnings from packages that don't support `native-comp'.
  1143. (setq comp-async-report-warnings-errors nil ;; Emacs 27.2 ...
  1144. native-comp-async-report-warnings-errors nil) ;; Emacs 28+ ...
  1145. #+END_SRC
  1146. ** Backup Files
  1147. 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.
  1148. #+NAME: emacs-backup-files-elisp
  1149. #+BEGIN_SRC emacs-lisp
  1150. ;; Disable unwanted features.
  1151. (setq make-backup-files nil
  1152. create-lockfiles nil)
  1153. #+END_SRC
  1154. ** Shell Commands
  1155. Define some methods for interaction between GNU/Emacs[fn:2], and the systems underyling shell:
  1156. 1) Method to run an external process, launching any application on a new process without interferring with Emacs[fn:2]
  1157. 2) Method to apply commands to the curren call process, effecting the running instance of Emacs[fn:2]
  1158. #+NAME: emacs-shell-commands-elisp
  1159. #+BEGIN_SRC emacs-lisp
  1160. ;; Define a method to run an external process.
  1161. (defun dotfiles/run (cmd)
  1162. "Run an external process."
  1163. (interactive (list (read-shell-command "λ ")))
  1164. (start-process-shell-command cmd nil cmd))
  1165. ;; Define a method to run a background process.
  1166. (defun dotfiles/run-in-background (cmd)
  1167. (let ((command-parts (split-string cmd "[ ]+")))
  1168. (apply #'call-process `(,(car command-parts) nil 0 nil ,@(cdr command-parts)))))
  1169. #+END_SRC
  1170. ** Nix Mode
  1171. #+NAME: emacs-nix-mode-extras
  1172. #+BEGIN_SRC nix
  1173. pkgs.nixfmt
  1174. #+END_SRC
  1175. Nix-mode[fn:39] 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.
  1176. #+NAME: emacs-nix-mode-package
  1177. #+BEGIN_SRC nix
  1178. epkgs.nix-mode
  1179. #+END_SRC
  1180. ** Evil Mode
  1181. Evil[fn:21] is an extensible VI layer for GNU/Emacs[fn:2]. It emulates the main features of Vim[fn:37], turning GNU/Emacs[fn:2] into a modal editor.
  1182. #+NAME: emacs-evil-package
  1183. #+BEGIN_SRC nix
  1184. epkgs.evil
  1185. epkgs.evil-collection
  1186. epkgs.evil-surround
  1187. epkgs.evil-nerd-commenter
  1188. #+END_SRC
  1189. 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:21] is extensible in Emacs Lisp[fn:36].
  1190. #+NAME: emacs-evil-elisp
  1191. #+BEGIN_SRC emacs-lisp
  1192. ;; Enable the Extensible VI Layer for Emacs.
  1193. (setq evil-want-integration t ;; Required for `evil-collection.'
  1194. evil-want-keybinding nil) ;; Same as above.
  1195. (evil-mode +1)
  1196. ;; Configure `evil-collection'.
  1197. (evil-collection-init)
  1198. ;; Configure `evil-surround'.
  1199. (global-evil-surround-mode +1)
  1200. ;; Configure `evil-nerd-commenter'.
  1201. (global-set-key (kbd "M-;") 'evilnc-comment-or-uncomment-lines)
  1202. #+END_SRC
  1203. ** EXWM
  1204. #+NAME: emacs-exwm-package
  1205. #+BEGIN_SRC nix
  1206. epkgs.exwm
  1207. #+END_SRC
  1208. EXWM (Emacs X Window Manager)[fn:20] is a full-featured tiling X window manager for GNU/Emacs[fn:2] built on-top of XELB. It features:
  1209. + Fully keyboard-driven operations
  1210. + Hybrid layout modes (tiling & stacking)
  1211. + Dynamic workspace support
  1212. + ICCM/EWMH compliance
  1213. #+NAME: emacs-exwm-extras
  1214. #+BEGIN_SRC nix
  1215. pkgs.nitrogen
  1216. pkgs.autorandr
  1217. #+END_SRC
  1218. 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:20].
  1219. #+NAME: emacs-exwm-config
  1220. #+BEGIN_SRC nix
  1221. xsession = {
  1222. enable = true;
  1223. windowManager.command = ''
  1224. ${pkgs.nitrogen}/bin/nitrogen --restore
  1225. ${myEmacs}/bin/emacs --daemon -f exwm-enable
  1226. ${myEmacs}/bin/emacsclient -c
  1227. '';
  1228. };
  1229. #+END_SRC
  1230. EXWM[fn:20] 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=.
  1231. #+NAME: emacs-exwm-xinitrc
  1232. #+BEGIN_SRC nix
  1233. home.file.".xinitrc" = {
  1234. text = ''
  1235. exec ./.xsession
  1236. '';
  1237. };
  1238. #+END_SRC
  1239. #+NAME: emacs-exwm-elisp
  1240. #+BEGIN_SRC emacs-lisp
  1241. ;; Configure `exwm'.
  1242. (setq exwm-worspace-show-all-buffers t)
  1243. (setq exwm-input-prefix-keys
  1244. '(?\M-x
  1245. ?\C-g
  1246. ?\C-\ ))
  1247. (setq exwm-input-global-keys
  1248. `(([?\s-r] . exwm-reset)
  1249. ,@(mapcar (lambda (i)
  1250. `(,(kbd (format "s-%d" i)) .
  1251. (lambda ()
  1252. (interactive)
  1253. (exwm-workspace-switch-create ,i))))
  1254. (number-sequence 1 9))))
  1255. ;; Configure `exwm-randr'.
  1256. (require 'exwm-randr)
  1257. (exwm-randr-enable)
  1258. ;; Configure custom hooks.
  1259. (setq display-time-and-date t)
  1260. (add-hook 'exwm-init-hook
  1261. (lambda ()
  1262. (display-battery-mode +1) ;; Display battery info (if available).
  1263. (display-time-mode +1))) ;; Display the time in the modeline.
  1264. ;; Setup buffer display names.
  1265. (add-hook 'exwm-update-class-hook
  1266. (lambda ()
  1267. (exwm-workspace-rename-buffer exwm-class-name))) ;; Use the system class name.
  1268. ;; Configure monitor hot-swapping.
  1269. (add-hook 'exwm-randr-screen-change-hook
  1270. (lambda ()
  1271. (dotfiles/run-in-background "autorandr --change --force"))) ;; Swap to the next screen config.
  1272. #+END_SRC
  1273. ** General
  1274. #+NAME: emacs-general-package
  1275. #+BEGIN_SRC nix
  1276. epkgs.general
  1277. #+END_SRC
  1278. General[fn:40] 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.
  1279. #+NAME: emacs-general-elisp
  1280. #+BEGIN_SRC emacs-lisp
  1281. ;; Use <SPC> as a leader key via `general.el'.
  1282. (general-create-definer dotfiles/leader
  1283. :states '(normal motion)
  1284. :keymaps 'override
  1285. :prefix "SPC"
  1286. :global-prefix "C-SPC")
  1287. ;; Find files with <SPC> <period> ...
  1288. ;; Switch buffers with <SPC> <comma> ...
  1289. (dotfiles/leader
  1290. "." '(find-file :which-key "File")
  1291. "," '(switch-to-buffer :which-key "Buffer")
  1292. "k" '(kill-buffer :which-key "Kill")
  1293. "c" '(kill-buffer-and-window :which-key "Close"))
  1294. ;; Add keybindings for executing shell commands.
  1295. (dotfiles/leader
  1296. "r" '(:ignore t :which-key "Run")
  1297. "rr" '(dotfiles/run :which-key "Run")
  1298. "ra" '(async-shell-command :which-key "Async"))
  1299. ;; Add keybindings for quitting Emacs.
  1300. (dotfiles/leader
  1301. "q" '(:ignore t :which-key "Quit")
  1302. "qq" '(save-buffers-kill-emacs :which-key "Save")
  1303. "qw" '(kill-emacs :which-key "Now")
  1304. "qf" '(delete-frame :which-key "Frame"))
  1305. ;; Add keybindings for toggles / tweaks.
  1306. (dotfiles/leader
  1307. "t" '(:ignore t :which-key "Toggle / Tweak"))
  1308. ;; Add keybindings for working with frames to replace
  1309. ;; the C-x <num> <num> method of bindings, which is awful.
  1310. (dotfiles/leader
  1311. "w" '(:ignore t :which-key "Windows")
  1312. "ww" '(window-swap-states :which-key "Swap")
  1313. "wc" '(delete-window :which-key "Close")
  1314. "wh" '(windmove-left :which-key "Left")
  1315. "wj" '(windmove-down :which-key "Down")
  1316. "wk" '(windmove-up :which-key "Up")
  1317. "wl" '(windmove-right :which-key "Right")
  1318. "ws" '(:ignore t :which-key "Split")
  1319. "wsj" '(split-window-below :which-key "Below")
  1320. "wsl" '(split-window-right :which-key "Right"))
  1321. #+END_SRC
  1322. ** Which Key
  1323. Which-key[fn:41] 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.
  1324. #+NAME: emacs-which-key-package
  1325. #+BEGIN_SRC nix
  1326. epkgs.which-key
  1327. #+END_SRC
  1328. #+NAME: emacs-which-key-elisp
  1329. #+BEGIN_SRC emacs-lisp
  1330. ;; Configure `which-key' to see keyboard bindings in the
  1331. ;; mini-buffer and when using M-x.
  1332. (setq which-key-idle-delay 0.0)
  1333. (which-key-mode +1)
  1334. #+END_SRC
  1335. ** EWW
  1336. The Emacs Web Wowser[fn:42] is a Web browser written in Emacs Lisp[fn:36] based on the ~shr.el~ library. It's my primary browser when it comes to text-based browsing.
  1337. + Use ~eww~ as the default browser
  1338. + Don't use any special fonts or colours
  1339. #+NAME: emacs-eww-elisp
  1340. #+BEGIN_SRC emacs-lisp
  1341. ;; Set `eww' as the default browser.
  1342. (setq browse-url-browser-function 'eww-browse-url)
  1343. ;; Configure the `shr' rendering engine.
  1344. (setq shr-use-fonts nil
  1345. shr-use-colors nil)
  1346. #+END_SRC
  1347. ** ERC
  1348. ERC[fn:43] is a powerful, modular, and extensible IRC client for GNU/Emacs[fn:2]. It's part of the GNU project, and included in Emacs.
  1349. #+NAME: emacs-erc-elisp
  1350. #+BEGIN_SRC emacs-lisp
  1351. ;; Configure `erc'.
  1352. (setq erc-autojoin-channels-alist '(("irc.libera.chat" "#emacs" "#nixos" "#systemcrafters"))
  1353. erc-track-exclude-types '("JOIN" "NICK" "QUIT" "MODE")
  1354. erc-lurker-hide-list '("JOIN" "PART" "QUIT"))
  1355. ;; Connect to IRC via `erc'.
  1356. (defun dotfiles/erc-connect ()
  1357. "Connected to IRC via `erc'."
  1358. (interactive)
  1359. (erc-tls :server "irc.libera.chat"
  1360. :port 6697
  1361. :nick "megaphone"
  1362. :password (password-store-get "megaphone@libera.chat")
  1363. :full-name "Chris Hayward"))
  1364. ;; Configure keybindings.
  1365. (dotfiles/leader
  1366. "i" '(dotfiles/erc-connect :which-key "Chat"))
  1367. #+END_SRC
  1368. ** Dired
  1369. #+NAME: emacs-dired-package
  1370. #+BEGIN_SRC nix
  1371. epkgs.dired-single
  1372. #+END_SRC
  1373. Dired[fn:44] 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:45] provides extra functionality for Dired[fn:44].
  1374. #+NAME: emacs-dired-elisp
  1375. #+BEGIN_SRC emacs-lisp
  1376. ;; Include `dired-x' for the `jump' method.
  1377. (require 'dired-x)
  1378. ;; Configure `dired-single' to support `evil' keys.
  1379. (evil-collection-define-key 'normal 'dired-mode-map
  1380. "h" 'dired-single-up-directory
  1381. "l" 'dired-single-buffer)
  1382. ;; Setup `all-the-icons' and the `dired' extension.
  1383. ;; Configure keybindings for `dired'.
  1384. (dotfiles/leader
  1385. "d" '(dired-jump :which-key "Dired"))
  1386. #+END_SRC
  1387. ** Icons
  1388. #+NAME: emacs-icons-package
  1389. #+BEGIN_SRC nix
  1390. epkgs.all-the-icons
  1391. epkgs.all-the-icons-dired
  1392. #+END_SRC
  1393. All The Icons[fn:46] is a utility package to collect various Icon Fonts and prioritize them within GNU/Emacs[fn:2].
  1394. #+NAME: emacs-icons-elisp
  1395. #+BEGIN_SRC emacs-lisp
  1396. ;; Setup `all-the-icons-dired'.
  1397. (add-hook 'dired-mode-hook 'all-the-icons-dired-mode)
  1398. ;; Display default font ligatures.
  1399. (global-prettify-symbols-mode +1)
  1400. #+END_SRC
  1401. ** Emojis
  1402. #+NAME: emacs-emoji-package
  1403. #+BEGIN_SRC nix
  1404. epkgs.emojify
  1405. #+END_SRC
  1406. Emojify[fn:47] 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.
  1407. #+NAME: emacs-emoji-elisp
  1408. #+BEGIN_SRC emacs-lisp
  1409. ;; Setup `emojify'.
  1410. (add-hook 'after-init-hook 'global-emojify-mode)
  1411. #+END_SRC
  1412. ** EShell
  1413. #+NAME: emacs-eshell-package
  1414. #+BEGIN_SRC nix
  1415. epkgs.eshell-prompt-extras
  1416. #+END_SRC
  1417. EShell [fn:48] is a shell-like command interpreter for GNU/Emacs[fn:2] implemented in Emacs Lisp[fn:36]. 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].
  1418. #+NAME: emacs-eshell-elisp
  1419. #+BEGIN_SRC emacs-lisp
  1420. ;; Configure `eshell'.
  1421. (setq eshell-highlight-prompt nil
  1422. eshell-prefer-lisp-functions nil)
  1423. ;; Configure the lambda prompt.
  1424. (autoload 'epe-theme-lambda "eshell-prompt-extras")
  1425. (setq eshell-prompt-function 'epe-theme-lambda)
  1426. ;; Configure keybindings for `eshell'.
  1427. (dotfiles/leader
  1428. "e" '(eshell :which-key "EShell"))
  1429. #+END_SRC
  1430. ** VTerm
  1431. Emacs Libvterm (VTerm)[fn:49] is a fully-fledged terminal emulator inside GNU/Emacs[fn:2] based on Libvterm[fn:50], a blazing fast C library used in Neovim[fn:37]. As a result of using compiled code (instead of Emacs Lisp[fn:36]), VTerm[fn:49] is capable, fast, and it can seamlessly handle large outputs.
  1432. #+NAME: emacs-vterm-package
  1433. #+BEGIN_SRC nix
  1434. epkgs.vterm
  1435. #+END_SRC
  1436. #+NAME: emacs-vterm-elisp
  1437. #+BEGIN_SRC emacs-lisp
  1438. ;; Add keybindings for interacting with the shell(s).
  1439. (dotfiles/leader
  1440. "v" '(vterm :which-key "VTerm"))
  1441. #+END_SRC
  1442. ** Magit
  1443. Magit[fn:51] is an interface to the Git[fn:35] version control system, implemented as a GNU/Emacs[fn:2] package written in Elisp[fn:36]. It fills the glaring gap between the Git[fn:35] command line interface and various GUIs, letting you perform trivial as well as elaborate version control tasks within a few mnemonic key presses.
  1444. #+NAME: emacs-magit-package
  1445. #+BEGIN_SRC nix
  1446. epkgs.magit
  1447. #+END_SRC
  1448. | Key | Description |
  1449. |-----+--------------------------------------|
  1450. | gg | Check the status of a repository |
  1451. | gc | Clone a remote repository |
  1452. | gf | Fetch the contents of the repository |
  1453. | gp | Pull the remotes of the repository |
  1454. #+NAME: emacs-magit-elisp
  1455. #+BEGIN_SRC emacs-lisp
  1456. ;; Add keybindings for working with `magit'.
  1457. (dotfiles/leader
  1458. "g" '(:ignore t :which-key "Git")
  1459. "gg" '(magit-status :which-key "Status")
  1460. "gc" '(magit-clone :which-key "Clone")
  1461. "gf" '(magit-fetch :which-key "Fetch")
  1462. "gp" '(magit-pull :which-key "Pull"))
  1463. #+END_SRC
  1464. ** Fonts
  1465. #+NAME: emacs-fonts-package
  1466. #+BEGIN_SRC nix
  1467. epkgs.hydra
  1468. #+END_SRC
  1469. #+NAME: emacs-fonts-elisp
  1470. #+BEGIN_SRC emacs-lisp
  1471. ;; Configure the font when running as `emacs-server'.
  1472. (custom-set-faces
  1473. '(default ((t (:inherit nil :height 96 :family "Iosevka")))))
  1474. ;; Set all three of Emacs' font faces.
  1475. ;; NOTE: This only works without `emacs-server'.
  1476. ;; (set-face-attribute 'default nil :font "Iosevka" :height 96)
  1477. ;; (set-face-attribute 'fixed-pitch nil :font "Iosevka" :height 96)
  1478. ;; (set-face-attribute 'variable-pitch nil :font "Iosevka" :height 96)
  1479. ;; Define a `hydra' function for scaling the text interactively.
  1480. (defhydra hydra-text-scale (:timeout 4)
  1481. "Scale text"
  1482. ("j" text-scale-decrease "Decrease")
  1483. ("k" text-scale-increase "Increase")
  1484. ("f" nil "Finished" :exit t))
  1485. ;; Create keybinding for calling the function.
  1486. (dotfiles/leader
  1487. "tf" '(hydra-text-scale/body :which-key "Font"))
  1488. #+END_SRC
  1489. ** Elfeed
  1490. #+NAME: emacs-elfeed-package
  1491. #+BEGIN_SRC nix
  1492. epkgs.elfeed
  1493. #+END_SRC
  1494. Elfeed[fn:52] 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.
  1495. | Key | Command |
  1496. |-----+---------|
  1497. | l | Open |
  1498. | u | Update |
  1499. #+NAME: emacs-elfeed-elisp
  1500. #+BEGIN_SRC emacs-lisp
  1501. ;; Configure `elfeed'.
  1502. (setq elfeed-db-directory (expand-file-name "~/.cache/elfeed"))
  1503. ;; Add custom feeds for `elfeed' to fetch.
  1504. (setq elfeed-feeds (quote
  1505. (("https://hexdsl.co.uk/rss.xml")
  1506. ("https://lukesmith.xyz/rss.xml")
  1507. ("https://friendo.monster/rss.xml")
  1508. ("https://chrishayward.xyz/index.xml")
  1509. ("https://protesilaos.com/codelog.xml"))))
  1510. ;; Add custom keybindings for `elfeed'.
  1511. (dotfiles/leader
  1512. "l" '(:ignore t :which-key "Elfeed")
  1513. "ll" '(elfeed :which-key "Open")
  1514. "lu" '(elfeed-update :which-key "Update"))
  1515. #+END_SRC
  1516. ** Org Mode
  1517. #+NAME: emacs-org-package
  1518. #+BEGIN_SRC nix
  1519. epkgs.org
  1520. #+END_SRC
  1521. Org-mode[fn:53] 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.
  1522. #+NAME: emacs-org-elisp
  1523. #+BEGIN_SRC emacs-lisp
  1524. ;; Configure `org-mode' source blocks.
  1525. (setq org-src-fontify-natively t ;; Make source blocks prettier.
  1526. org-src-tab-acts-natively t ;; Use TAB indents within source blocks.
  1527. org-src-preserve-indentation t) ;; Stop `org-mode' from formatting blocks.
  1528. ;; Add an `org-mode-hook'.
  1529. (add-hook 'org-mode-hook
  1530. (lambda ()
  1531. (org-indent-mode)
  1532. (visual-line-mode)))
  1533. ;; Remove the `Validate XHTML 1.0' message from HTML export.
  1534. (setq org-export-html-validation-link nil
  1535. org-html-validation-link nil)
  1536. ;; TODO: Configure default structure templates.
  1537. ;; (require 'org-tempo)
  1538. ;; Apply custom keybindings.
  1539. (dotfiles/leader
  1540. "o" '(:ignore t :which-key "Org")
  1541. "oe" '(org-export-dispatch :which-key "Export")
  1542. "ot" '(org-babel-tangle :which-key "Tangle")
  1543. "oi" '(org-toggle-inline-images :which-key "Images")
  1544. "of" '(:ignore t :which-key "Footnotes")
  1545. "ofn" '(org-footnote-normalize :which-key "Normalize"))
  1546. #+END_SRC
  1547. ** Org Roam
  1548. #+NAME: emacs-org-roam-package
  1549. #+BEGIN_SRC nix
  1550. epkgs.org-roam
  1551. epkgs.org-roam-server
  1552. #+END_SRC
  1553. Org Roam[fn:54] is a plain-text knowledge management system. It borrows principles from the Zettelkasten method[fn:55], 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:53] for their personal wiki (me). Org Roam Server[fn:56] is a Web application to visualize the Org Roam[fn:54] 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.
  1554. #+NAME: emacs-org-roam-elisp
  1555. #+BEGIN_SRC emacs-lisp
  1556. ;; Setup `org-roam' hooks.
  1557. (add-hook 'after-init-hook
  1558. (lambda ()
  1559. (org-roam-mode)
  1560. (org-roam-server-mode)))
  1561. ;; Configure `org-roam'.
  1562. (setq org-roam-encrypt-files t
  1563. org-roam-directory (expand-file-name "/etc/dotfiles")
  1564. org-roam-capture-templates '()
  1565. org-roam-dailies-capture-templates '())
  1566. ;; Encrypt files with the public key.
  1567. (setq epa-file-select-keys 2
  1568. epa-file-encrypt-to "37AB1CB72B741E478CA026D43025DCBD46F81C0F"
  1569. epa-cache-passphrase-for-symmetric-encryption t)
  1570. ;; Define a new `title-to-slug' function to override the default `org-roam-title-to-slug' function.
  1571. ;; This is done to change the replacement character from "_" to "-".
  1572. (require 'cl-lib)
  1573. (defun dotfiles/title-to-slug (title)
  1574. "Convert TITLE to a filename-suitable slug."
  1575. (cl-flet* ((nonspacing-mark-p (char)
  1576. (eq 'Mn (get-char-code-property char 'general-category)))
  1577. (strip-nonspacing-marks (s)
  1578. (apply #'string (seq-remove #'nonspacing-mark-p
  1579. (ucs-normalize-NFD-string s))))
  1580. (cl-replace (title pair)
  1581. (replace-regexp-in-string (car pair) (cdr pair) title)))
  1582. (let* ((pairs `(("[^[:alnum:][:digit:]]" . "-") ;; Convert anything not alphanumeric.
  1583. ("--*" . "-") ;; Remove sequential dashes.
  1584. ("^-" . "") ;; Remove starting dashes.
  1585. ("-$" . ""))) ;; Remove ending dashes.
  1586. (slug (-reduce-from #'cl-replace (strip-nonspacing-marks title) pairs)))
  1587. (downcase slug))))
  1588. (setq org-roam-title-to-slug-function #'dotfiles/title-to-slug)
  1589. ;; Configure capture templates.
  1590. ;; Standard document.
  1591. (add-to-list 'org-roam-capture-templates
  1592. '("d" "Default" entry (function org-roam-capture--get-point)
  1593. "%?"
  1594. :file-name "docs/${slug}"
  1595. :unnarrowed t
  1596. :head
  1597. "
  1598. ,#+TITLE: ${title}
  1599. ,#+AUTHOR: Christopher James Hayward
  1600. ,#+EMAIL: chris@chrishayward.xyz
  1601. "))
  1602. ;; Course document.
  1603. (add-to-list 'org-roam-capture-templates
  1604. '("c" "Course" plain (function org-roam-capture--get-point)
  1605. "%?"
  1606. :file-name "docs/courses/${slug}"
  1607. :unnarrowed t
  1608. :head
  1609. "
  1610. ,#+TITLE: ${title}
  1611. ,#+SUBTITLE:
  1612. ,#+AUTHOR: Christopher James Hayward
  1613. ,#+EMAIL: chris@chrishayward.xyz
  1614. ,#+OPTIONS: num:nil toc:nil todo:nil tasks:nil tags:nil
  1615. ,#+OPTIONS: skip:nil author:nil email:nil creator:nil timestamp:nil
  1616. "))
  1617. ;; Daily notes.
  1618. (add-to-list 'org-roam-dailies-capture-templates
  1619. '("d" "Default" entry (function org-roam-capture--get-point)
  1620. "* %?"
  1621. :file-name "docs/daily/%<%Y-%m-%d>"
  1622. :head
  1623. "
  1624. ,#+TITLE: %<%Y-%m-%d>
  1625. ,#+AUTHOR: Christopher James Hayward
  1626. ,#+OPTIONS: num:nil toc:nil todo:nil tasks:nil tags:nil
  1627. ,#+OPTIONS: skip:nil author:nil email:nil creator:nil timestamp:nil
  1628. "))
  1629. ;; Apply custom keybindings.
  1630. (dotfiles/leader
  1631. "or" '(:ignore t :which-key "Roam")
  1632. "ori" '(org-roam-insert :which-key "Insert")
  1633. "orf" '(org-roam-find-file :which-key "Find")
  1634. "orc" '(org-roam-capture :which-key "Capture")
  1635. "orb" '(org-roam-buffer-toggle-display :which-key "Buffer"))
  1636. ;; Apply custom keybindings for dailies.
  1637. (dotfiles/leader
  1638. "ord" '(:ignore t :which-key "Dailies")
  1639. "ordd" '(org-roam-dailies-find-date :which-key "Date")
  1640. "ordt" '(org-roam-dailies-find-today :which-key "Today")
  1641. "ordm" '(org-roam-dailies-find-tomorrow :which-key "Tomorrow")
  1642. "ordy" '(org-roam-dailies-find-yesterday :which-key "Yesterday"))
  1643. #+END_SRC
  1644. ** Org Drill
  1645. #+NAME: emacs-org-drill-package
  1646. #+BEGIN_SRC nix
  1647. epkgs.org-drill
  1648. #+END_SRC
  1649. Org Drill[fn:57] is an extension for Org Mode[fn:53] that uses a spaced repition algorithm to conduct interactive /Drill Sessions/ using Org files as sources of facts to be memorized.
  1650. #+NAME: emacs-org-drill-elisp
  1651. #+BEGIN_SRC emacs-lisp
  1652. ;; Configure keybindings for `org-drill'.
  1653. (dotfiles/leader
  1654. "od" '(:ignore t :which-key "Drill")
  1655. "odd" '(org-drill :which-key "Drill")
  1656. "odc" '(org-drill-cram :which-key "Cram")
  1657. "odr" '(org-drill-resume :which-key "Resume"))
  1658. #+END_SRC
  1659. ** Org Agenda
  1660. The way Org Mode[fn:53] 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.
  1661. #+NAME: emacs-org-agenda-elisp
  1662. #+BEGIN_SRC emacs-lisp
  1663. ;; Configure `org-agenda' to use the project files.
  1664. (setq org-agenda-files '("/etc/dotfiles/"
  1665. "/etc/dotfiles/docs/"
  1666. "/etc/dotfiles/docs/courses/"
  1667. "/etc/dotfiles/docs/daily/"
  1668. "/etc/dotfiles/docs/notes/"
  1669. "/etc/dotfiles/docs/posts/"
  1670. "/etc/dotfiles/docs/slides/"))
  1671. ;; Include files encrypted with `gpg'.
  1672. (require 'org)
  1673. (unless (string-match-p "\\.gpg" org-agenda-file-regexp)
  1674. (setq org-agenda-file-regexp
  1675. (replace-regexp-in-string "\\\\\\.org" "\\\\.org\\\\(\\\\.gpg\\\\)?"
  1676. org-agenda-file-regexp)))
  1677. ;; Open an agenda buffer with SPC o a.
  1678. (dotfiles/leader
  1679. "oa" '(org-agenda :which-key "Agenda"))
  1680. #+END_SRC
  1681. ** Org Pomodoro
  1682. #+NAME: emacs-pomodoro-package
  1683. #+BEGIN_SRC nix
  1684. epkgs.org-pomodoro
  1685. #+END_SRC
  1686. Org Pomodoro[fn:58] adds basic support for the Pomodoro Technique[fn:59] 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.
  1687. #+NAME: emacs-pomodoro-elisp
  1688. #+BEGIN_SRC emacs-lisp
  1689. ;; Configure `org-pomodor' with the overtime workflow.
  1690. (setq org-pomodoro-manual-break t
  1691. org-pomodoro-keep-killed-time t)
  1692. ;; Configure keybindings.
  1693. (dotfiles/leader
  1694. "op" '(org-pomodoro :which-key "Pomodoro"))
  1695. #+END_SRC
  1696. ** Writegood Mode
  1697. #+NAME: emacs-writegood-package
  1698. #+BEGIN_SRC nix
  1699. epkgs.writegood-mode
  1700. #+END_SRC
  1701. Writegood Mode[fn:60] is an Emacs[fn:2] minor mode to aid in finding common writing problems. It highlights the text based on the following criteria:
  1702. + Weasel Words
  1703. + Passive Voice
  1704. + Duplicate Words
  1705. #+NAME: emacs-writegood-elisp
  1706. #+BEGIN_SRC emacs-lisp
  1707. ;; Configure `writegood-mode'.
  1708. (dotfiles/leader
  1709. "tg" '(writegood-mode :which-key "Grammar"))
  1710. #+END_SRC
  1711. ** Aspell
  1712. #+NAME: emacs-aspell-extras
  1713. #+BEGIN_SRC nix
  1714. pkgs.aspell
  1715. pkgs.aspellDicts.en
  1716. pkgs.aspellDicts.en-science
  1717. pkgs.aspellDicts.en-computers
  1718. #+END_SRC
  1719. GNU Aspell[fn:61] 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.
  1720. #+NAME: emacs-aspell-elisp
  1721. #+BEGIN_SRC emacs-lisp
  1722. ;; Use `aspell' as a drop-in replacement for `ispell'.
  1723. (setq ispell-program-name "aspell"
  1724. ispell-eextra-args '("--sug-mode=fast"))
  1725. ;; Configure the built-in `flyspell-mode'.
  1726. (dotfiles/leader
  1727. "ts" '(flyspell-mode :which-key "Spelling"))
  1728. #+END_SRC
  1729. ** Hugo
  1730. #+NAME: emacs-hugo-extras
  1731. #+BEGIN_SRC nix
  1732. pkgs.hugo
  1733. #+END_SRC
  1734. Hugo[fn:62] is one of the most popular open-source static site generators.
  1735. #+NAME: emacs-hugo-package
  1736. #+BEGIN_SRC nix
  1737. epkgs.ox-hugo
  1738. #+END_SRC
  1739. Ox-Hugo[fn:63] is an Org-Mode[fn:53] exporter for Hugo[fn:62] compabile markdown. I post nonsense on my Personal Blog[fn:64], and share my notes on various textbooks, articles, and software Here[fn:65].
  1740. #+NAME: emacs-hugo-elisp
  1741. #+BEGIN_SRC emacs-lisp
  1742. ;; Configure `ox-hugo' as an `org-mode-export' backend.
  1743. (require 'ox-hugo)
  1744. ;; Capture templates.
  1745. ;; Personal blog post.
  1746. (add-to-list 'org-roam-capture-templates
  1747. '("p" "Post" plain (function org-roam-capture--get-point)
  1748. "%?"
  1749. :file-name "docs/posts/${slug}"
  1750. :unnarrowed t
  1751. :head
  1752. "
  1753. ,#+TITLE: ${title}
  1754. ,#+AUTHOR: Christopher James Hayward
  1755. ,#+DATE: %<%Y-%m-%d>
  1756. ,#+OPTIONS: num:nil todo:nil tasks:nil
  1757. ,#+EXPORT_FILE_NAME: ${slug}
  1758. ,#+ROAM_KEY: https://chrishayward.xyz/posts/${slug}/
  1759. ,#+HUGO_BASE_DIR: ../
  1760. ,#+HUGO_AUTO_SET_LASTMOD: t
  1761. ,#+HUGO_SECTION: posts
  1762. ,#+HUGO_DRAFT: true
  1763. "))
  1764. ;; Shared notes.
  1765. (add-to-list 'org-roam-capture-templates
  1766. '("n" "Notes" plain (function org-roam-capture--get-point)
  1767. "%?"
  1768. :file-name "docs/notes/${slug}"
  1769. :unnarrowed t
  1770. :head
  1771. "
  1772. ,#+TITLE: ${title}
  1773. ,#+AUTHOR: Christopher James Hayward
  1774. ,#+OPTIONS: num:nil todo:nil tasks:nil
  1775. ,#+EXPORT_FILE_NAME: ${slug}
  1776. ,#+ROAM_KEY: https://chrishayward.xyz/notes/${slug}/
  1777. ,#+HUGO_BASE_DIR: ../
  1778. ,#+HUGO_AUTO_SET_LASTMOD: t
  1779. ,#+HUGO_SECTION: notes
  1780. ,#+HUGO_DRAFT: true
  1781. "))
  1782. #+END_SRC
  1783. ** Reveal
  1784. #+NAME: emacs-reveal-package
  1785. #+BEGIN_SRC nix
  1786. epkgs.ox-reveal
  1787. #+END_SRC
  1788. Reveal.js[fn:66] 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:66] are built on open web technologies. That means anything you can do on the web, you can do in your presentation. Ox Reveal[fn:67] is an Org Mode[fn:53] export backend.
  1789. #+NAME: emacs-reveal-elisp
  1790. #+BEGIN_SRC emacs-lisp
  1791. ;; Configure `ox-reveal' as an `org-mode-export' backend.
  1792. (require 'ox-reveal)
  1793. ;; Don't rely on any local software.
  1794. (setq org-reveal-root "https://cdn.jsdelivr.net/npm/reveal.js")
  1795. ;; Create a capture template.
  1796. (add-to-list 'org-roam-capture-templates
  1797. '("s" "Slides" plain (function org-roam-capture--get-point)
  1798. "%?"
  1799. :file-name "docs/slides/${slug}"
  1800. :unnarrowed t
  1801. :head
  1802. "
  1803. ,#+TITLE: ${title}
  1804. ,#+AUTHOR: Christopher James Hayward
  1805. ,#+EMAIL: chris@chrishayward.xyz
  1806. ,#+REVEAL_ROOT: https://cdn.jsdelivr.net/npm/reveal.js
  1807. ,#+REVEAL_THEME: serif
  1808. ,#+EXPORT_FILE_NAME: ${slug}
  1809. ,#+OPTIONS: reveal_title_slide:nil
  1810. ,#+OPTIONS: num:nil toc:nil todo:nil tasks:nil tags:nil
  1811. ,#+OPTIONS: skip:nil author:nil email:nil creator:nil timestamp:nil
  1812. "))
  1813. #+END_SRC
  1814. ** Passwords
  1815. #+NAME: emacs-pass-extras
  1816. #+BEGIN_SRC nix
  1817. pkgs.pass
  1818. #+END_SRC
  1819. With Pass[fn:68], 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.
  1820. #+NAME: emacs-pass-package
  1821. #+BEGIN_SRC nix
  1822. epkgs.password-store
  1823. #+END_SRC
  1824. Configure keybindings for passwords behind =SPC p=:
  1825. | Key | Description |
  1826. |-----+---------------------|
  1827. | p | Copy a password |
  1828. | r | Rename a password |
  1829. | g | Generate a password |
  1830. #+NAME: emacs-pass-elisp
  1831. #+BEGIN_SRC emacs-lisp
  1832. ;; Set the path to the password store.
  1833. (setq password-store-dir (expand-file-name "~/.password-store"))
  1834. ;; Apply custom keybindings.
  1835. (dotfiles/leader
  1836. "p" '(:ignore t :which-key "Passwords")
  1837. "pp" '(password-store-copy :which-key "Copy")
  1838. "pr" '(password-store-rename :which-key "Rename")
  1839. "pg" '(password-store-generate :which-key "Generate"))
  1840. #+END_SRC
  1841. ** MU4E
  1842. #+NAME: emacs-mu4e-extras
  1843. #+BEGIN_SRC nix
  1844. pkgs.mu
  1845. pkgs.isync
  1846. #+END_SRC
  1847. #+NAME: emacs-mu4e-package
  1848. #+BEGIN_SRC nix
  1849. epkgs.mu4e-alert
  1850. #+END_SRC
  1851. #+NAME: emacs-mu4e-config
  1852. #+BEGIN_SRC nix
  1853. home.file.".mbsyncrc" = {
  1854. text = ''
  1855. IMAPStore xyz-remote
  1856. Host mail.chrishayward.xyz
  1857. User chris@chrishayward.xyz
  1858. PassCmd "pass chrishayward.xyz/chris"
  1859. SSLType IMAPS
  1860. MaildirStore xyz-local
  1861. Path ~/.cache/mail/
  1862. Inbox ~/.cache/mail/inbox
  1863. SubFolders Verbatim
  1864. Channel xyz
  1865. Far :xyz-remote:
  1866. Near :xyz-local:
  1867. Patterns * !Archives
  1868. Create Both
  1869. Expunge Both
  1870. SyncState *
  1871. '';
  1872. };
  1873. #+END_SRC
  1874. #+BEGIN_SRC sh
  1875. mbsync -a
  1876. mu init --maildir="~/.cache/mail" --my-address="chris@chrishayward.xyz"
  1877. mu index
  1878. #+END_SRC
  1879. #+NAME: emacs-mu4e-elisp
  1880. #+BEGIN_SRC emacs-lisp
  1881. ;; Add the `mu4e' shipped with `mu' to the load path.
  1882. (add-to-list 'load-path "/etc/profiles/per-user/chris/share/emacs/site-lisp/mu4e/")
  1883. (require 'mu4e)
  1884. ;; Confiugure `mu4e'.
  1885. (setq mu4e-maildir "~/.cache/mail"
  1886. mu4e-update-interval (* 5 60)
  1887. mu4e-get-mail-command "mbsync -a"
  1888. mu4e-compose-format-flowed t
  1889. mu4e-change-filenames-when-moving t
  1890. mu4e-compose-signature (concat "Chris Hayward\n"
  1891. "chris@chrishayward.xyz"))
  1892. ;; Sign all outbound email with GPG.
  1893. (add-hook 'message-send-hook 'mml-secure-message-sign-pgpmime)
  1894. (setq message-send-mail-function 'smtpmail-send-it
  1895. mml-secure-openpgp-signers '("37AB1CB72B741E478CA026D43025DCBD46F81C0F"))
  1896. ;; Setup `mu4e' accounts.
  1897. (setq mu4e-contexts
  1898. (list
  1899. ;; Main
  1900. ;; chris@chrishayward.xyz
  1901. (make-mu4e-context
  1902. :name "Main"
  1903. :match-func
  1904. (lambda (msg)
  1905. (when msg
  1906. (string-prefix-p "/Main" (mu4e-message-field msg :maildir))))
  1907. :vars
  1908. '((user-full-name . "Christopher James Hayward")
  1909. (user-mail-address . "chris@chrishayward.xyz")
  1910. (smtpmail-smtp-server . "mail.chrishayward.xyz")
  1911. (smtpmail-smtp-service . 587)
  1912. (smtpmail-stream-type . starttls)))))
  1913. ;; Setup `mu4e-alert'.
  1914. (setq mu4e-alert-set-default-style 'libnotify)
  1915. (mu4e-alert-enable-notifications)
  1916. (mu4e-alert-enable-mode-line-display)
  1917. ;; Open the `mu4e' dashboard.
  1918. (dotfiles/leader
  1919. "m" '(mu4e :which-key "Mail"))
  1920. #+END_SRC
  1921. ** Projectile
  1922. #+NAME: emacs-projectile-package
  1923. #+BEGIN_SRC nix
  1924. epkgs.projectile
  1925. #+END_SRC
  1926. Projectile[fn:69] 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.
  1927. #+NAME: emacs-projectile-elisp
  1928. #+BEGIN_SRC emacs-lisp
  1929. ;; Configure the `projectile-project-search-path'.
  1930. (setq projectile-project-search-path '("~/.local/source"))
  1931. (projectile-mode +1)
  1932. #+END_SRC
  1933. ** LSP Mode
  1934. #+NAME: emacs-lsp-package
  1935. #+BEGIN_SRC nix
  1936. epkgs.lsp-mode
  1937. epkgs.lsp-ui
  1938. #+END_SRC
  1939. The Language Server Protocol (LSP)[fn:70] defines the protocol used between an Editor or IDE, and a language server that provides features like:
  1940. + Auto Complete
  1941. + Go To Defintion
  1942. + Find All References
  1943. #+NAME: emacs-lsp-elisp
  1944. #+BEGIN_SRC emacs-lisp
  1945. ;; Configure `lsp-mode'.
  1946. (setq lsp-idle-delay 0.5
  1947. lsp-prefer-flymake t)
  1948. ;; Configure `lsp-ui'.
  1949. (setq lsp-ui-doc-position 'at-point
  1950. lsp-ui-doc-delay 0.5)
  1951. #+END_SRC
  1952. ** CCLS
  1953. #+NAME: emacs-ccls-package
  1954. #+BEGIN_SRC nix
  1955. epkgs.ccls
  1956. #+END_SRC
  1957. Emacs CCLS[fn:71] is a client for CCLS, a C/C++/Objective-C language server supporting multi-million line C++ code bases, powered by libclang.
  1958. #+NAME: emacs-ccls-elisp
  1959. #+BEGIN_SRC emacs-lisp
  1960. ;; Configure `ccls' to work with `lsp-mode'.
  1961. (defun dotfiles/ccls-hook ()
  1962. (require 'ccls)
  1963. (lsp))
  1964. ;; Configure `ccls' mode hooks.
  1965. (add-hook 'c-mode-hook 'dotfiles/ccls-hook)
  1966. (add-hook 'c++-mode-hook 'dotfiles/ccls-hook)
  1967. (add-hook 'objc-mode-hook 'dotfiles/ccls-hook)
  1968. (add-hook 'cuda-mode-hook 'dotfiles/ccls-hook)
  1969. #+END_SRC
  1970. ** Company Mode
  1971. #+NAME: emacs-company-package
  1972. #+BEGIN_SRC nix
  1973. epkgs.company
  1974. #+END_SRC
  1975. Company[fn:72] 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.
  1976. #+NAME: emacs-company-elisp
  1977. #+BEGIN_SRC emacs-lisp
  1978. ;; Configure `company-mode'.
  1979. (setq company-backend 'company-capf
  1980. lsp-completion-provider :capf)
  1981. ;; Enable it globally.
  1982. (global-company-mode +1)
  1983. #+END_SRC
  1984. ** Go Mode
  1985. #+NAME: emacs-golang-package
  1986. #+BEGIN_SRC nix
  1987. epkgs.go-mode
  1988. #+END_SRC
  1989. Go Mode[fn:73] is a major mode for editing Golang[fn:12] source code in GNU/Emacs[fn:2].
  1990. #+NAME: emacs-golang-elisp
  1991. #+BEGIN_SRC emacs-lisp
  1992. ;; Configure `go-mode' to work with `lsp-mode'.
  1993. (defun dotfiles/go-hook ()
  1994. (add-hook 'before-save-hook #'lsp-format-buffer t t)
  1995. (add-hook 'before-save-hook #'lsp-organize-imports t t))
  1996. ;; Configure a custom `before-save-hook'.
  1997. (add-hook 'go-mode-hook #'dotfiles/go-hook)
  1998. #+END_SRC
  1999. ** Rustic
  2000. #+NAME: emacs-rustic-package
  2001. #+BEGIN_SRC nix
  2002. epkgs.rustic
  2003. #+END_SRC
  2004. Rustic[fn:72] is a fork of rust-mode that integrates well with the Language Server Protocol[fn:68]. Include the rust shell before launching GNU/Emacs[fn:2] to use this!
  2005. #+NAME: emacs-rustic-elisp
  2006. #+BEGIN_SRC emacs-lisp
  2007. ;; Configure `rustic' with `lsp-mode'.
  2008. (setq rustic-format-on-save t
  2009. rustic-lsp-server 'rls)
  2010. #+END_SRC
  2011. ** Python Mode
  2012. #+NAME: emacs-python-package
  2013. #+BEGIN_SRC nix
  2014. epkgs.pretty-mode
  2015. #+END_SRC
  2016. The built in Python Mode[fn:74] 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:70] server. These tools are included in the Development Shell[fn:11] for Python[fn:18].
  2017. #+NAME: emacs-python-elisp
  2018. #+BEGIN_SRC emacs-lisp
  2019. ;; Configure `pretty-mode' to work with `python-mode'.
  2020. (add-hook 'python-mode-hook
  2021. (lambda ()
  2022. (turn-on-pretty-mode)))
  2023. #+END_SRC
  2024. ** PlantUML
  2025. #+NAME: emacs-plantuml-extras
  2026. #+BEGIN_SRC nix
  2027. pkgs.plantuml
  2028. #+END_SRC
  2029. PlantUML[fn:75] is an open-source tool allowing users to create diagrams from a plain-text language. Besides various UML diagrams, PlantUML[fn:75] has support for various other software developmented related formats, as well as visualizations of =JSON= and =YAML= files.
  2030. #+NAME: emacs-plantuml-package
  2031. #+BEGIN_SRC nix
  2032. epkgs.plantuml-mode
  2033. #+END_SRC
  2034. PlantUML Mode[fn:76] is a major mode for editing PlantUML[fn:75] sources in GNU/Emacs[fn:2].
  2035. #+NAME: emacs-plantuml-elisp
  2036. #+BEGIN_SRC emacs-lisp
  2037. ;; Configure `plantuml-mode'.
  2038. (add-to-list 'org-src-lang-modes '("plantuml" . plantuml))
  2039. (org-babel-do-load-languages 'org-babel-load-languages '((plantuml . t)))
  2040. (setq plantuml-default-exec-mode 'executable
  2041. org-plantuml-exec-mode 'plantuml)
  2042. #+END_SRC
  2043. ** Swiper
  2044. #+NAME: emacs-swiper-package
  2045. #+BEGIN_SRC nix
  2046. epkgs.ivy
  2047. epkgs.counsel
  2048. epkgs.ivy-rich
  2049. epkgs.ivy-posframe
  2050. epkgs.ivy-prescient
  2051. #+END_SRC
  2052. Ivy (Swiper)[fn:77] 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.
  2053. #+NAME: emacs-swiper-elisp
  2054. #+BEGIN_SRC emacs-lisp
  2055. ;; Configure `ivy'.
  2056. (setq counsel-linux-app-format-function
  2057. #'counsel-linux-app-format-function-name-only)
  2058. (ivy-mode +1)
  2059. (counsel-mode +1)
  2060. ;; Configure `ivy-rich'.
  2061. (ivy-rich-mode +1)
  2062. ;; Configure `ivy-posframe'.
  2063. (setq ivy-posframe-parameters '((parent-frame nil))
  2064. ivy-posframe-display-functions-alist '((t . ivy-posframe-display)))
  2065. (ivy-posframe-mode +1)
  2066. ;; Configure `ivy-prescient'.
  2067. (setq ivy-prescient-enable-filtering nil)
  2068. (ivy-prescient-mode +1)
  2069. #+END_SRC
  2070. ** Transparency
  2071. 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.
  2072. #+NAME: emacs-transparency-elisp
  2073. #+BEGIN_SRC emacs-lisp
  2074. ;; Configure the default frame transparency.
  2075. (set-frame-parameter (selected-frame) 'alpha '(95 . 95))
  2076. (add-to-list 'default-frame-alist '(alpha . (95 . 95)))
  2077. #+END_SRC
  2078. ** Desktop Environment
  2079. #+NAME: emacs-desktop-extras
  2080. #+BEGIN_SRC nix
  2081. pkgs.brightnessctl
  2082. #+END_SRC
  2083. The Desktop Environment[fn:78] package provides commands and a global minor mode for controlling your GNU/Linux[fn:1] desktop from within GNU/Emacs[fn:2].
  2084. #+NAME: emacs-desktop-package
  2085. #+BEGIN_SRC nix
  2086. epkgs.desktop-environment
  2087. #+END_SRC
  2088. 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.
  2089. #+NAME: emacs-desktop-elisp
  2090. #+BEGIN_SRC emacs-lisp
  2091. ;; Configure `desktop-environment'.
  2092. (require 'desktop-environment)
  2093. (desktop-environment-mode +1)
  2094. #+END_SRC
  2095. ** Doom Themes
  2096. #+NAME: emacs-doom-themes-package
  2097. #+BEGIN_SRC nix
  2098. epkgs.doom-themes
  2099. #+END_SRC
  2100. Doom Themes[fn:79] is a theme megapack for GNU/Emacs[fn:2], inspired by community favourites.
  2101. #+NAME: emacs-doom-themes-elisp
  2102. #+BEGIN_SRC emacs-lisp
  2103. ;; Include modern themes from `doom-themes'.
  2104. (setq doom-themes-enable-bold t
  2105. doom-themes-enable-italic t)
  2106. ;; Load the `doom-moonlight' theme.
  2107. (load-theme 'doom-moonlight t)
  2108. (doom-modeline-mode +1)
  2109. ;; Load a new theme with <SPC> t t.
  2110. (dotfiles/leader
  2111. "tt" '(counsel-load-theme :which-key "Theme"))
  2112. #+END_SRC
  2113. ** Doom Modeline
  2114. #+NAME: emacs-doom-modeline-package
  2115. #+BEGIN_SRC nix
  2116. epkgs.doom-modeline
  2117. #+END_SRC
  2118. Doom Modeline[fn:80] is a fancy and fast modeline inspired by minimalism design. It's integrated into Centaur Emacs, Doom Emacs, and Spacemacs.
  2119. #+NAME: emacs-doom-modeline-elisp
  2120. #+BEGIN_SRC emacs-lisp
  2121. ;; Add the `doom-modeline' after initialization.
  2122. (add-hook 'after-init-hook 'doom-modeline-mode)
  2123. (setq doom-modeline-height 16
  2124. doom-modeline-icon t)
  2125. #+END_SRC
  2126. * Footnotes
  2127. [fn:1] https://gnu.org
  2128. [fn:2] https://gnu.org/software/emacs/
  2129. [fn:3] https://literateprogramming.com/knuthweb.pdf
  2130. [fn:4] https://nixos.org/manual/nixos/stable
  2131. [fn:5] https://nixos.org/manual/nix/stable
  2132. [fn:6] https://nixos.org/manual/nixpkgs/stable
  2133. [fn:7] https://github.com/nix-community/home-manager
  2134. [fn:8] https://github.com/nix-community/emacs-overlay
  2135. [fn:9] https://github.com/nixos/nixos-hardware
  2136. [fn:10] https://github.com/t184256/nix-on-droid
  2137. [fn:11] https://nixos.org/manual/nix/unstable/command-ref/nix-shell.html
  2138. [fn:12] https://golang.org
  2139. [fn:13] https://rust-lang.org
  2140. [fn:14] https://nodejs.org
  2141. [fn:15] https://grpc.io
  2142. [fn:16] https://iso.org/standard/74528.html
  2143. [fn:17] https://en.wikipedia.org/wiki/C++/
  2144. [fn:18] https://python.org
  2145. [fn:19] https://qemu.org
  2146. [fn:20] https://github.com/ch11ng/exwm
  2147. [fn:21] https://evil.readthedocs.io/en/latest/overview.html
  2148. [fn:22] https://raspberrypi.org/products/raspberry-pi-400/
  2149. [fn:23] https://www.raspberrypi.org/products/raspberry-pi-4-model-b/
  2150. [fn:24] https://samsung.com/us/mobile/galaxy-s10/buy/
  2151. [fn:25] https://x.org/wiki/
  2152. [fn:26] https://wayland.freedesktop.org
  2153. [fn:27] https://openssh.com
  2154. [fn:28] https://nixos.wiki/wiki/Flakes
  2155. [fn:29] https://nix-community.cachix.org
  2156. [fn:30] https://docker.org
  2157. [fn:31] https://en.wikipedia.org/wiki/Firefox
  2158. [fn:32] https://jellyfin.org
  2159. [fn:33] https://moonlight-stream.org
  2160. [fn:34] https://teamviewer.com
  2161. [fn:35] https://git-scm.com
  2162. [fn:36] https://emacswiki.org/emacs/LearnEmacsLisp
  2163. [fn:37] https://neovim.io
  2164. [fn:38] https://gtk.org
  2165. [fn:39] https://github.com/nixos/nix-mode
  2166. [fn:40] https://github.com/noctuid/general.el
  2167. [fn:41] https://github.com/justbur/emacs-which-key
  2168. [fn:42] https://emacswiki.org/emacs/eww
  2169. [fn:43] https://gnu.org/software/emacs/erc.html
  2170. [fn:44] https://emacswiki.org/emacs/DiredMode
  2171. [fn:45] https://emacswiki.org/emacs/DiredExtra#Dired_X
  2172. [fn:46] https://github.com/domtronn/all-the-icons.el
  2173. [fn:47] https://github.com/iqbalansari/emacs-emojify
  2174. [fn:48] https://gnu.org/software/emacs/manual/html_mono/eshell.html
  2175. [fn:49] https://github.com/akermu/emacs-libvterm
  2176. [fn:50] https://github.com/neovim/libvterm
  2177. [fn:51] https://magit.vc
  2178. [fn:52] https://github.com/skeeto/elfeed
  2179. [fn:53] https://orgmode.org
  2180. [fn:54] https://github.com/org-roam/org-roam
  2181. [fn:55] https://zettelkasten.de
  2182. [fn:56] https://github.com/org-roam/org-roam-server
  2183. [fn:57] https://orgmode.org/worg/org-contrib/org-drill.html
  2184. [fn:58] https://github.com/marcinkoziej/org-pomodoro
  2185. [fn:59] https://en.wikipedia.org/wiki/Pomodoro_Technique
  2186. [fn:60] https://github.com/bnbeckwith/writegood-mode
  2187. [fn:61] https://aspell.net
  2188. [fn:62] https://gohugo.io
  2189. [fn:63] https://oxhugo.scripter.co
  2190. [fn:64] https://chrishayward.xyz/posts/
  2191. [fn:65] https://chrishayward.xyz/notes/
  2192. [fn:66] https://revealjs.com
  2193. [fn:67] https://github.com/hexmode/ox-reveal
  2194. [fn:68] https://password-store.org
  2195. [fn:69] https://projectile.mx
  2196. [fn:70] https://microsoft.github.io/language-server-protocol
  2197. [fn:71] https://github.com/MaskRay/emacs-ccls
  2198. [fn:72] https://company-mode.github.io
  2199. [fn:73] https://emacswiki.org/emacs/GoMode
  2200. [fn:74] https://plantuml.com
  2201. [fn:75] https://github.com/skuro/plantuml-mode
  2202. [fn:76] https://github.com/abo-abo/swiper
  2203. [fn:77] https://github.com/DamienCassou/desktop-environment
  2204. [fn:78] https://github.com/hlissner/emacs-doom-themes
  2205. [fn:79] https://github.com/seagle0128/doom-modeline
  2206. [fn:80] https://laptopmedia.com/laptop-specs/acer-nitro-5-an515-53-2
  2207. [fn:81] https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html