arroyo/arroyo-emacs.org

208 lines
7.5 KiB
Org Mode

:PROPERTIES:
:ID: arroyo/emacs
:ROAM_ALIASES: "Arroyo Emacs"
:END:
#+TITLE: Arroyo Emacs Generator
#+PROPERTY: header-args :mkdirp yes
#+PROPERTY: header-args:emacs-lisp :tangle arroyo-emacs.el
#+AUTO_TANGLE: t
#+filetags: :Project:Arroyo:Development:
#+ARCOLOGY_KEY: cce/arroyo/emacs
#+ARCOLOGY_ALLOW_CRAWL: t
Arroyo developed out of a system originally designed to assemble an Emacs =init.el=, and now it has some super-powers. The Arroyo Emacs configuration is pretty opinionated as it's a system designed to work around [[id:cce/evil_mode][Evil Mode]] and [[id:cce/exwm][EXWM]].
Arroyo Emacs configuration is designed to work closely with the Arroyo Home Manager generator, nearly all system dependencies are installed through Home Manager, and certain submodules may require the use of Home Manager. No Arroyo Emacs features should require running NixOS though, and I'd like to maintain that as much as possible since getting Nix running everywhere is much more feasible than running NixOS everywhere.
Users of the Arroyo Home Manager generator will have access to features available in [[id:nix_community_emacs_overlay][nix-community/emacs-overlay]] like:
- the =native-compile= feature
- Native GTK with Wayland support (though Wayland is not supported by impotant parts of Arroyo like the [[id:cce/exwm][EXWM]] system)
- When using =use-package=, packages will be downloaded and (natively!) compiled in the deploy phase rather than on Emacs startup
* Arroyo Emacs =init.el= generator
:PROPERTIES:
:ID: arroyo/emacs/init.el
:END:
=arroyo-emacs-generate-init= can be called interactively[fn:1:that is, by pressing =Alt-x= / =M-x= and then typing the name of the command; [[id:modern_interface_terms][Modern Interface Terms]]] to assemble an =init.el= file which will have the dependencies ordered in such a way as to allow the user to user Emacs.
#+ARROYO_MODULE_WANTS: arcology-django/interfaces.org
#+begin_src emacs-lisp :results none -r
(defcustom arroyo-emacs-init-location (expand-file-name "~/arroyo-nix/files/init.el")
"Where `arroyo-emacs-generate-init' writes the amalgamated init file."
:group 'arroyo
:type 'string)
(defun arroyo-emacs-generate-init ()
(interactive)
(arroyo-generate-imports "emacs" nil arroyo-emacs-init-location nil)
(find-file arroyo-emacs-init-location))
#+end_src
The interactive function is more or less as it says on the tin -- it uses the Arcology stuff to write the =init.el= to a local directory for the [[id:20211130T215142.470274][arroyo-flood]].
* [[id:arroyo/home-manager][Arroyo Home Manager]] support for customized Emacs package
:PROPERTIES:
:ID: 3018859a-940b-4096-a083-133f361e312c
:ROAM_ALIASES: "Emacs Nix Package"
:END:
This [[id:c75d20e6-8888-4c5a-ac97-5997e2f1c711][Nix]] [[id:cce/home-manager][home-manager]] import installs [[id:cce/emacs][Emacs]] with my generated =init.el= file included, packages installed, and custom overrides included. The versions come out of my [[id:cce/version_pins][Nix Version Pins]].
The Emacs package uses, currently 28.0.90 which supports native compilation -- the [[https://www.emacswiki.org/emacs/GccEmacs][so-called GccEmacs]] and the packages from the =init.el=, natively compiled and ready to go. This is overlayed in to [[id:c75d20e6-8888-4c5a-ac97-5997e2f1c711][nixpkgs]] using [[id:20221021T115008.329657][Arroyo Nix Support]]
#+begin_src nix :tangle ~/arroyo-nix/pkgs/emacs.nix :noweb yes -r
{ pkgs, lib ? pkgs.lib, ... }:
let
versions = import ../versions.nix {};
in pkgs.emacsWithPackagesFromUsePackage {
package = pkgs.emacs-unstable;
# package = pkgs.emacsGit.override {#
# treeSitterPlugins = with pkgs.tree-sitter-grammars; [
# tree-sitter-eex
# tree-sitter-elisp
# tree-sitter-elixir
# tree-sitter-fennel
# tree-sitter-haskell
# tree-sitter-html
# tree-sitter-lua
# tree-sitter-markdown
# tree-sitter-nix
# tree-sitter-scheme
# tree-sitter-sql
# # builtins, mostly
# tree-sitter-bash
# tree-sitter-c
# tree-sitter-cmake
# tree-sitter-cpp
# tree-sitter-css
# tree-sitter-dockerfile
# tree-sitter-go
# tree-sitter-gomod
# tree-sitter-java
# tree-sitter-javascript
# tree-sitter-json
# tree-sitter-python
# tree-sitter-ruby
# tree-sitter-rust
# tree-sitter-toml
# tree-sitter-yaml
# ];
# };
config = <<arroyo-emacs-init-location()>>;
alwaysEnsure = true;
override = epkgs: epkgs // rec {
<<generate_epkg_overrides()>>
};
extraEmacsPackages = epkgs: [
epkgs.consult-org-roam
];
}
#+end_src
#+ARROYO_HOME_MODULE: hm/emacs.nix
#+ARROYO_NIXOS_MODULE: nixos/emacs.nix
#+ARROYO_SYSTEM_EXCLUDE: waterboy
#+begin_src nix :tangle ~/arroyo-nix/nixos/emacs.nix
let emacsOverlay = (import ../versions.nix {}).emacsOverlay null;
in {
nixpkgs.overlays = [
(import emacsOverlay)
];
}
#+end_src
#+begin_src nix :tangle ~/arroyo-nix/hm/emacs.nix :noweb yes -r
{ config, pkgs, lib, ...}:
let
myEmacs = pkgs.myEmacs; # loads via overlay
in
{
home.file.".emacs.d/init.el".source = <<arroyo-emacs-init-location()>>;
programs.info.enable = true;
services.emacs = {
enable = false;
package = myEmacs;
};
programs.emacs = {
enable = true;
package = myEmacs;
};
}
#+end_src
Enable [[roam:ccache]] for =emacsGcc= builds in [[id:cce/my_nixos_configuration][My NixOS configuration]]
,#+ARROYO_NIXOS_MODULE: nixos/ccache.nix
#+begin_src nix :tangle ~/arroyo-nix/nixos/ccache.nix
{ ... }:
{
programs.ccache = {
packageNames = ["emacs-unstable"];
};
nix.extraOptions = ''
extra-sandbox-paths = /nix/var/cache/ccache
'';
}
#+end_src
** [[id:cce/literate_programming][Literate Programming]] helpers
I want to be able to construct a [[id:cce/home-manager][home-manager]] import dynamically which can be used to install with =emacs-overlay= functionality. I also want it to be able to inject arbitrary =packageOverrides= in to it via references in stored in documents' =ARROYO_HOME_EPKGS= property keyword.
#+begin_src emacs-lisp :results none
(defun arroyo-epkg-overrides (&optional role)
(arroyo-generate-imports "epkgs" role nil nil))
#+end_src
=arroyo-epkg-overrides= can be used to insert any overridden elisp package in to the registry for =use-package= to install, including things with patches or personal forks. yummy. apply a =ARROYO_HOME_EPKGS= [[id:e050ed03-044f-4a48-912d-72579bef9a26][keyword]] to the page to include it here.
#+NAME: generate_epkg_overrides
#+begin_src emacs-lisp :tangle nil
(arroyo-epkg-overrides)
#+end_src
=arroyo-emacs-init-location= above is simply the [[id:arroyo/emacs][Arroyo Emacs]]-managed =init.el=:
#+NAME: arroyo-emacs-init-location
#+begin_src emacs-lisp :tangle no
; arroyo-emacs-init-location
"<arroyo/files/init.el>"
#+end_src
** NEXT fix ccache support
** DONE reenable ccache
SCHEDULED: <2021-09-22 Wed>
:LOGBOOK:
- State "DONE" from "NEXT" [2021-10-05 Tue 19:34]
- Note taken on [2021-10-05 Tue 19:33] \\
This doesn't even work lul.
:END:
https://github.com/NixOS/nixpkgs/pull/137936
** NEXT how to automate epkg tangling, etc.
can use [[id:cce/org-roam][org-roam]]'s [[id:20211203T142617.812313][Arcology.Roam.File]] to know whether a file has been updated and tangle it as part of the dynamic-home-manager dynamic-nixops etc... those things will check a cache to see if the files have changed, and tangle them and then this file if so?
** DONE need a reverse of =ARROYO_MODULE_WANTS= for specifying "wanted-by"s
:LOGBOOK:
- State "DONE" from "NEXT" [2021-08-24 Tue 19:12]
:END:
#+begin_src emacs-lisp
(provide 'arroyo-emacs)
#+end_src