about summary refs log tree commit diff
path: root/modules/common/emacs
diff options
context:
space:
mode:
authorAzat Bahawi <azat@bahawi.net>2023-02-20 02:05:59 +0300
committerAzat Bahawi <azat@bahawi.net>2023-02-20 02:05:59 +0300
commite40f7d991353ad70984afdf67b25c049190c56bd (patch)
tree295a80114cca78952ed6ed562198d997b496faba /modules/common/emacs
parent2023-02-19 (diff)
2023-02-20
Diffstat (limited to 'modules/common/emacs')
-rw-r--r--modules/common/emacs/default.nix29
-rw-r--r--modules/common/emacs/doom/config.el2
2 files changed, 26 insertions, 5 deletions
diff --git a/modules/common/emacs/default.nix b/modules/common/emacs/default.nix
index bc4acdc..268d77d 100644
--- a/modules/common/emacs/default.nix
+++ b/modules/common/emacs/default.nix
@@ -1,8 +1,9 @@
 {
   config,
+  inputs,
   lib,
+  localUsername ? lib.my.username,
   pkgs,
-  pkgsStable,
   this,
   ...
 }:
@@ -12,6 +13,11 @@ in {
   options.nixfiles.modules.emacs.enable = mkEnableOption "GNU Emacs";
 
   config = mkIf cfg.enable {
+    secrets.authinfo = {
+      file = "${inputs.self}/secrets/authinfo";
+      owner = localUsername;
+    };
+
     nixfiles.modules = {
       fonts.enable = true;
       git.client.enable = true;
@@ -114,6 +120,8 @@ in {
                 concatMapStringsSep ":" (x: "${x}/bin") extraBins
               }"))
 
+              (appendq! auth-sources '("${config.secrets.authinfo.path}"))
+
               ;; Font must be set to N+2 because otherwise it looks too small.
               (setq doom-font (font-spec :family "${config.fontScheme.monospaceFont.family}"
                                           :size ${toString (config.fontScheme.monospaceFont.size + 2)})
@@ -139,11 +147,23 @@ in {
             (builtins.readFile ./doom/config.el)
           ];
           onChange = with config.hm.programs; ''
-            if [[ -x "''${XDG_CONFIG_HOME:~/.config}/emacs/bin/doom" ]]; then
+            export DOOMDIR="$HOME/.config/doom"
+            export EMACSDIR="$HOME/.config/emacs"
+
+            if [[ ! -d "$EMACSDIR/.git" ]]; then
+              ${git.package}/bin/git clone --depth=1 --branch=master \
+                "https://github.com/doomemacs/doomemacs" "$EMACSDIR"
+            fi
+
+            if [[ ! -d "$DOOMDIR" ]]; then
+              mkdir -p "$DOOMDIR"
+            fi
+
+            if [[ -x "$EMACSDIR/bin/doom" ]]; then
               oldpath="$PATH"
               export PATH="''${PATH:-/bin}:${emacs.package}/bin:${git.package}/bin"
 
-              "''${XDG_CONFIG_HOME:~/.config}/emacs/bin/doom" sync
+              "$EMACSDIR/bin/doom" sync -e -p --force --verbose
 
               export PATH="$oldpath"
               unset oldpath
@@ -155,8 +175,7 @@ in {
       programs.emacs = {
         enable = true;
         package = pkgs.emacs28; # Pin to avoid surprises.
-        # For some reason latest libvterm is not picked up by Emacs.
-        extraPackages = _: with pkgsStable.emacsPackages; [vterm];
+        extraPackages = p: with p; [vterm];
       };
     };
   };
diff --git a/modules/common/emacs/doom/config.el b/modules/common/emacs/doom/config.el
index 9284e0b..502ca27 100644
--- a/modules/common/emacs/doom/config.el
+++ b/modules/common/emacs/doom/config.el
@@ -84,6 +84,8 @@
 ;;; Nix
 ;;
 
+(setq nix-nixfmt-bin "alejandra")
+
 (after! lsp-mode
   (add-to-list 'lsp-language-id-configuration '(nix-mode . "nix"))
   (lsp-register-client

Consider giving Nix/NixOS a try! <3