antidote: static file move to /tmp

Make antidote create static file path with hm hash_id in /tmp.
This commit is contained in:
hitsmaxft 2023-06-27 09:12:51 +08:00 committed by Robert Helgesson
parent b66af0ac66
commit 2f78e6fcba
No known key found for this signature in database
GPG key ID: 36BDAA14C2797E89
2 changed files with 18 additions and 14 deletions

View file

@ -8,11 +8,13 @@ let
(optionalString (config.programs.zsh.dotDir != null) (optionalString (config.programs.zsh.dotDir != null)
(config.programs.zsh.dotDir + "/")) + file; (config.programs.zsh.dotDir + "/")) + file;
zPluginStr = with lib; zPluginStr = (pluginNames:
(pluginNames:
optionalString (pluginNames != [ ]) "${concatStrings (map (name: '' optionalString (pluginNames != [ ]) "${concatStrings (map (name: ''
${name} ${name}
'') pluginNames)}"); '') pluginNames)}");
parseHashId = path:
elemAt (builtins.match "/nix/store/([a-zA-Z0-9]+)-.*" path) 0;
in { in {
meta.maintainers = [ maintainers.hitsmaxft ]; meta.maintainers = [ maintainers.hitsmaxft ];
@ -33,20 +35,24 @@ in {
config = mkIf cfg.enable { config = mkIf cfg.enable {
home.packages = [ cfg.package ]; home.packages = [ cfg.package ];
programs.zsh.initExtraBeforeCompInit = let
home.file."${relToDotDir ".zsh_plugins.txt"}".text = zPluginStr cfg.plugins; configFiles = pkgs.runCommand "hm_antidote-files" { } ''
echo "${zPluginStr cfg.plugins}" > $out
### move zsh_plugins.txt '';
programs.zsh.initExtraBeforeCompInit = '' hashId = parseHashId "${configFiles}";
in ''
## home-manager/antidote begin : ## home-manager/antidote begin :
source ${cfg.package}/share/antidote/antidote.zsh source ${cfg.package}/share/antidote/antidote.zsh
${optionalString cfg.useFriendlyNames ${optionalString cfg.useFriendlyNames
"zstyle ':antidote:bundle' use-friendly-names 'yes'"} "zstyle ':antidote:bundle' use-friendly-names 'yes'"}
bundlefile=$HOME/${relToDotDir ".zsh_plugins.txt"}
bundlefile=${configFiles}
zstyle ':antidote:bundle' file $bundlefile zstyle ':antidote:bundle' file $bundlefile
staticfile=$HOME/${relToDotDir ".zsh_plugins.zsh"} staticfile=/tmp/tmp_hm_zsh_plugins.zsh-${hashId}
zstyle ':antidote:static' file $staticfile zstyle ':antidote:static' file $staticfile
antidote load $bundlefile $staticfile antidote load $bundlefile $staticfile
## home-manager/antidote end ## home-manager/antidote end
''; '';
}; };

View file

@ -24,7 +24,5 @@ in {
'antidote load' 'antidote load'
assertFileContains home-files/${relToDotDirCustom}/.zshrc \ assertFileContains home-files/${relToDotDirCustom}/.zshrc \
"zstyle ':antidote:bundle' use-friendly-names 'yes'" "zstyle ':antidote:bundle' use-friendly-names 'yes'"
assertFileContains home-files/${relToDotDirCustom}/.zsh_plugins.txt \
'zsh-users/zsh-autosuggestions'
''; '';
} }