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.

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