I am a relatively new NixOS user (~1 month), and I am trying to use Doom Emacs on NixOS. While most of the time it works quite well, I have issues, when I try and check what common problems my config may be encountering by running ~/.emacs.d/bin/doom doctor or doom doctor for short. The error is:
If you’re using home-manager’s user service, for example, Emacs will be started with an empty path, making anything you install using environment.systemPackages unavailable without a bit more tinkering.
In the backtrace you’ve posted, there’s a function called emacsql-sqlite-ensure-binary. That function belongs to the emacsql-sqlite package [1], and it builds C source files included in the package itself [2]. The resulting binary is what is being referred to as the “EmacSQL SQLite binary” in the error message. Including SQLite in environment.systemPackages has no effect because emacsql-sqlite isn’t making use of the official SQLite command.
My preferred method of dealing with packages like emacsql-sqlite that include native C code would be to obtain them from Nixpkgs. Nixpkgs would precompile those C code so that you wouldn’t need to expose C compilers to the global PATH.
Assuming you use configuration.nix to install Emacs, change your configuration to something like the below:
{ config, pkgs, ... }:
let
myEmacs = pkgs.emacsWithPackages (epkgs: with epkgs; [
emacsql-sqlite
]);
in
{
environment.systemPackages = [ myEmacs ];
}
Then, tell Doom Emacs to prefer the Nixpkgs copy of emacsql-sqlite by adding the following to $DOOMDIR/packages.el: