summary refs log tree commit diff stats
path: root/user
diff options
context:
space:
mode:
authorAlan Pearce2020-03-02 15:08:44 +0100
committerAlan Pearce2020-03-02 15:08:44 +0100
commitd820aae57b976d2fa935f48f18ac905ca0d5179e (patch)
treeec5f3d2536476cbd40bdccee7c701de912ec345a /user
parentba2104eb17f0727ac69dab9dbde0e6db045199bc (diff)
downloadnixfiles-d820aae57b976d2fa935f48f18ac905ca0d5179e.tar.lz
nixfiles-d820aae57b976d2fa935f48f18ac905ca0d5179e.tar.zst
nixfiles-d820aae57b976d2fa935f48f18ac905ca0d5179e.zip
zsh: precompile plugins
Diffstat (limited to 'user')
-rw-r--r--user/settings/zsh.nix18
1 files changed, 16 insertions, 2 deletions
diff --git a/user/settings/zsh.nix b/user/settings/zsh.nix
index 0f97a227..5d62101a 100644
--- a/user/settings/zsh.nix
+++ b/user/settings/zsh.nix
@@ -4,6 +4,20 @@ let
   inherit (pkgs) stdenv;
   lsOptions = if stdenv.isDarwin then "-p" else "-v --group-directories-first";
   lsIsoDate = if stdenv.isDarwin then "" else "--time-style=long-iso";
+  mkZshPlugin = attrs: {
+    name = attrs.name;
+    src = stdenv.mkDerivation {
+      inherit (attrs) src;
+      name = "zsh-plugin-${attrs.name}";
+      buildInputs = [ pkgs.zsh ];
+      buildPhase = ''
+        zsh -c 'for f in **/*; zcompile "$f"'
+      '';
+      installPhase = ''
+        cp -a $PWD $out/
+      '';
+    };
+  };
 in
 {
   home.packages = with pkgs; [
@@ -40,7 +54,7 @@ in
       ZSH_AUTOSUGGEST_HIGHLIGHT_STYLE = "fg=8";
     };
 
-    plugins = [
+    plugins = (map mkZshPlugin [
       {
         name = "cd-gitroot";
         src = pkgs.fetchFromGitHub {
@@ -112,7 +126,7 @@ in
           sha256 = "1328g3h51478ai25niv9qgf8bjgg3cw98zdqfznrbgw0k3qj66zk";
         };
       }
-    ];
+    ]);
 
     shellAliases = {
       l = "ls ${lsOptions} -Bp";