$ show marienz/nix-doom-emacs-unstraightened
nix-doom-emacs-unstraightened is a Nix-based build system for Doom Emacs that bypasses straight.el by using Doom's CLI to export dependencies and then building them with Nix's emacsWithPackages. It provides a flake, overlay, Home Manager module, and a set of Nix expressions to build a fully reproducible Doom Emacs configuration with all dependencies pinned via Nix. The architecture consists of multiple steps: extracting package requirements from Doom via a Elisp script, applying Doom's pins to emacs-overlay packages, handling missing packages with IFD-based dependency detection, generating a Doom profile and profile loader, and finally wrapping the Emacs binary. The project features extensive CI/CD, automated daily flake updates, and a Cachix cache. It demonstrates sophisticated Nix patterns including IFD, fetchTree, structured overrides, and Emacs Lisp scripting within Nix builds.
The LLM identified 6 files worth highlighting for reuse:
The main entry point for building Doom Emacs. It orchestrates the entire build: step 1 runs a Doom script to dump package requirements as JSON, step 2 applies pins and overrides to emacs-overlay packages, step 3 builds emacsWithPackages, step 4 generates the Doom profile and loader, and step 5 creates wrapper scripts. It demonstrates advanced Nix patterns like IFD, lib.foldl' for multiple scope overrides, and conditional fetch method selection.
An Emacs Lisp script run as a Doom CLI command. It loads the user's Doom configuration, enumerates all packages with their recipes and pins, and writes them as JSON (packages.json, builtin-packages.json). It also generates a modified packages.el that marks all packages as :ignore so that Doom does not attempt to fetch them via straight.el. This script is a clean pattern for extracting package metadata from Doom for use by external build systems.
An Emacs Lisp script that generates a Doom profile by initializing package.el, activating all packages, initializing Doom modules, and then calling doom-profile-generate. It also persists package-activated-list to avoid re-activation at startup. This demonstrates how to use Doom's profile API to capture the fully initialized state for fast startup.
Generates the Doom profile loader (early init file) that sets up the profile directory and disables native compilation to avoid recompilation loops. It uses defvar advice to override doom-profile-init-dir and an :after advice on doom-initialize to reset doom-profile-dir. This is a clean workaround for Doom's profile system limitations.
Centralized data file for URLs, pins, and file patterns of packages that are not in nixpkgs/emacs-overlay or require special handling. It defines extraUrls for packages from emacsattic, sourcehut, codeberg, etc., extraPins for packages not pinned by Doom, and extraFiles for :files overrides. This pattern isolates non-standard package configuration, making it easy to maintain and update.
Applies post-pin overrides and patches to specific packages. It conditionally applies patches (e.g., for swift-mode, evil-numbers), sets packageRequires, adds nativeBuildInputs, and overrides build phases. Only applies to packages that have been pinned (checked via passthru.doom-emacs-pinned). This ensures overrides are safe and do not affect unpinned packages.