Open znewman01 opened 2 years ago
So.. I already take this approach in my private config but it's a bad solution since it needs to build Doom twice and the literate
module automatically tangles config.org
to config.el
when saving so this is not really a problem. Or, if that module is broken, upstream's problem to fix.
The thing that most bothers me about this is that I now have to commit both config.org
and config.el
to my NixOS repo.
IMO your hack would be worth including in nix-doom-emacs
. I'll probably borrow it :)
Since doomPrivateDir
can be set to a Nix derivation, i solved this by creating a derivation that tangles my config.org
, and use that in my home.nix
.
In my doom.d
folder, there is a default.nix
with the following contents:
{ version ? "dev", lib, stdenv, emacs }:
stdenv.mkDerivation {
pname = "emacs-config";
inherit version;
src = lib.sourceByRegex ./. [ "config.org" "init.el" ];
buildInputs = [emacs];
buildPhase = ''
cp $src/* .
# Tangle org files
emacs --batch -Q \
-l org \
config.org \
-f org-babel-tangle
'';
dontUnpack = true;
installPhase = ''
install -D -t $out *.el
'';
}
nix-doom-emacs
gets called like this:
doom-emacs = pkgs.callPackage (builtins.fetchTarball {
url =
"https://github.com/nix-community/nix-doom-emacs/archive/master.tar.gz";
}) {
doomPrivateDir = pkgs.callPackage ./doom.d {};
};
Doom gets build only once, and config.org
remains the single source of truth.
Note that literate
module of doom tangles all code blocks by default, while standard Org-babel will only tangle those with :tangle yes
set. This can be solved by adding
#+PROPERTY: header-args:emacs-lisp :tangle yes
to the header of your config
Since
doomPrivateDir
can be set to a Nix derivation, i solved this by creating a derivation that tangles myconfig.org
, and use that in myhome.nix
. In mydoom.d
folder, there is adefault.nix
with the following contents:{ version ? "dev", lib, stdenv, emacs }: stdenv.mkDerivation { pname = "emacs-config"; inherit version; src = lib.sourceByRegex ./. [ "config.org" "init.el" ]; buildInputs = [emacs]; buildPhase = '' cp $src/* . # Tangle org files emacs --batch -Q \ -l org \ config.org \ -f org-babel-tangle ''; dontUnpack = true; installPhase = '' install -D -t $out *.el ''; }
nix-doom-emacs
gets called like this:doom-emacs = pkgs.callPackage (builtins.fetchTarball { url = "https://github.com/nix-community/nix-doom-emacs/archive/master.tar.gz"; }) { doomPrivateDir = pkgs.callPackage ./doom.d {}; };
Doom gets build only once, and
config.org
remains the single source of truth.Note that
literate
module of doom tangles all code blocks by default, while standard Org-babel will only tangle those with:tangle yes
set. This can be solved by adding#+PROPERTY: header-args:emacs-lisp :tangle yes
to the header of your config
Works really well. Thanks
Copied from https://github.com/vlaci/nix-doom-emacs/issues/9