emacs: only rebuild straight-env when necessary

This commit is contained in:
Jez Cope 2023-07-08 21:32:08 +01:00
parent fcfc3e6a25
commit 34d9818d18
2 changed files with 35 additions and 1 deletions

View File

@ -10,9 +10,41 @@ let
doom = "~/.emacs.d/bin/doom";
};
in {
programs.doom-emacs = {
programs.doom-emacs = rec {
enable = true;
doomPrivateDir = pkgs.callPackage ./doom.d { };
# Only init/packages so we only rebuild when those change.
doomPackageDir = let
filteredPath = builtins.path {
path = doomPrivateDir;
name = "doom-private-dir-filtered";
filter = path: type:
# builtins.elem (baseNameOf path) [ "init.el" "packages.el" "modules" ];
let
relPath =
lib.removePrefix (toString doomPrivateDir + "/") (toString path);
regexes = [ "init.el" "packages.el" "modules(/.*)?" ];
in lib.any (re: builtins.match re relPath != null) regexes;
};
in pkgs.linkFarm "doom-packages-dir" [
{
name = "init.el";
path = "${filteredPath}/init.el";
}
{
name = "packages.el";
path = "${filteredPath}/packages.el";
}
{
name = "modules";
path = "${filteredPath}/modules";
}
{
name = "config.el";
path = pkgs.emptyFile;
}
];
};
home.packages = with pkgs;

View File

@ -65,3 +65,5 @@
(package! monky)
(package! writefreely)
(package! mastodon)