Only sync doom when config changes

This commit is contained in:
2024-07-28 17:00:03 -07:00
parent f7b2f7b59a
commit 1400e79f19

View File

@@ -1,6 +1,14 @@
{ config, lib, pkgs, ... }: { config, lib, pkgs, ... }:
{ let
doomSync = (let
emacs = pkgs.emacs;
git = pkgs.git;
in ''
export PATH=${emacs}/bin:${git}/bin:$PATH
${config.xdg.configHome}/emacs/bin/doom sync -u -j $((`nproc`/4*3))
'');
in {
home.packages = [ home.packages = [
pkgs.emacs-all-the-icons-fonts pkgs.emacs-all-the-icons-fonts
pkgs.fontconfig pkgs.fontconfig
@@ -21,20 +29,24 @@
".config/emacs" = { ".config/emacs" = {
source = fetchGit { source = fetchGit {
url = "https://github.com/doomemacs/doomemacs.git"; url = "https://github.com/doomemacs/doomemacs.git";
# When updating me, remember to run `doom sync`
rev = "36e7aaa619342eff61b1daf3ac664f94d5272db7"; rev = "36e7aaa619342eff61b1daf3ac664f94d5272db7";
}; };
# We need to use recursive mode here or else doom fails to sync for
# some reason related to the permissions on the synced path. I'm not
# quite sure of everything that's going on here.
recursive = true; recursive = true;
# Because `recursive = true` will cause this to sync every single
# activation, we turn this off here.
#
# There's probably a way we could do better detection of this within
# our onChange shell?
#
# onChange = doomSync;
}; };
}; };
home.activation.doomSync = lib.hm.dag.entryAfter [ "writeBoundary" ] (let
emacs = pkgs.emacs;
git = pkgs.git;
in ''
export PATH=${emacs}/bin:${git}/bin:$PATH
${config.xdg.configHome}/emacs/bin/doom sync -u -j $((`nproc`/4*3))
'');
home.sessionVariables = { home.sessionVariables = {
DOOMLOCALDIR = "${config.xdg.dataHome}/doom"; DOOMLOCALDIR = "${config.xdg.dataHome}/doom";
EDITOR = "emacs -nw"; EDITOR = "emacs -nw";
@@ -49,5 +61,9 @@
package = pkgs.emacs; package = pkgs.emacs;
}; };
xdg.configFile."doom".source = ./doom; xdg.configFile."doom" = {
source = ./doom;
# Sync doom if we updated the config
onChange = doomSync;
};
} }