From d820aae57b976d2fa935f48f18ac905ca0d5179e Mon Sep 17 00:00:00 2001 From: Alan Pearce Date: Mon, 2 Mar 2020 15:08:44 +0100 Subject: zsh: precompile plugins --- user/settings/zsh.nix | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) (limited to 'user') 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"; -- cgit 1.4.1