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.

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