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.

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