Installing Doom Emacs on NixOS

Versions of this question have been asked before, but I haven’t seen a definitive answer (that I’m capable of adapting). I’ve recently switched to NixOS, and can’t seem to install Doom the Nix way. I’ve had to install imperatively, like in the manual.

My NixOS config is basically identical to that in here. I already have my Doom config in a repo on Github, and I’m not trying to manage the modules/packages themselves through nix, just get NixOS to install doom and apply my config. How do I create a new package/overlay to do this? Does anyone have some experience here? I’d rather not use the nix-doom-emacs project as it’s pretty behind.

Doom’s configuration is already declarative and, as far as I can tell, takes some ideas from NixOS (just a guess: hlissner is a NixOS user with some useful configs). When I last checked out the api for v3’s profiles it was a bit buggy, but I think this is going to be an amazing feature for any who is a declarative junky.

You can check out GitHub - nix-community/nix-doom-emacs: doom-emacs packaged for Nix [maintainers=@ckiee,@thiagokokada] if you really want to give it a shot, but there are a few downsides to including an emacs config in your NixOS files (in addition to the broken nix-doom-emacs repo).

An alternative: I rolled out my own vanilla framework just using emacs-overlay (GitHub - nix-community/emacs-overlay: Bleeding edge emacs overlay [maintainer=@adisbladis]) using the emacsWithPackagesFromUsePackage function. This is pretty straightforward (and a good way to learn nix), but it can be a bit of a time sink and is strictly for a vanilla-emacs setup.

There are various other ways you can nixify an emacs config: putting .config/doom/* in a home-manager home.file submodule; having a repo dedicated to an emacs wrapper that leverages the --init-directory= flag; using the home-manager creator’s emacs module for vanilla emacs). That said, now I just use the standard doom configuration. Each nixos-rebuild takes up >30s, which is not very fun to sit through if all you want to do is fix a typo in your emacs config! Nix does a few things well, but it’s no panacea.