nix-community / emacs-overlay

Bleeding edge emacs overlay [maintainer=@adisbladis]
503 stars 165 forks source link

Provide tangled .el file from Org configs #106

Open jhenahan opened 3 years ago

jhenahan commented 3 years ago

While striving for an ever more turnkey system deployment, I ran into the issue of "how do I tell Emacs to tangle my Org config whenever I change it when Nix sets mtime to epoch 0?". I settled on a home-manager activation script to symlink my Org file into ~/.emacs.d for now, but I thought it'd be cool to expose an attribute or something off of an emacsWithPackagesFromUsePackage (or maybe just a totally separate function, I dunno) to hold the tangled config for direct symlinking (maybe even byte compile it if there's a sane way to do that).

I'm probably gonna play around and see if I can cobble something together out of fromElisp, so this is more of an interest check and a call for anyone who's been down this road before to spill their secrets or tell me that this is a terrible idea. :D

terlar commented 3 years ago

If you want some inspiration I do this in my config: https://github.com/terlar/emacs-config/blob/master/default.nix#L11-L27

  1. I tangle the org file which results in a init.el and a early-init.el.
  2. I also generate package-quickstart.
  3. Then everything is byte-compiled via the derivation trivialBuild.
adisbladis commented 3 years ago

I would like to take this even further and embed the config in the Emacs closure regardless of tangling. I'd be very happy if someone made a PR for that.

lambdadog commented 3 years ago

@adisbladis Unfortunately this is a somewhat complex problem with emacs. I've gone through several iterations of my emacsWithConfig function and pored through lisp/startup.el plenty and it doesn't paint a great picture.

This is the list of options I've found:

lambdadog commented 3 years ago

There's also the option of setting HOME prior to loading emacs but IMO that's a very unhappy solution since a lot of things would be set using the HOME variable during load that would need to be reset, even more than user-emacs-directory with XDG_CONFIG_HOME.

Anything further would require patching emacs, which I admit I've considered once or twice, but I don't think would tell a happy story about integrating software with nix. It might be an undertaking I consider at some point down the line though regardless.