1
0
Fork 0
mirror of https://github.com/nix-community/home-manager synced 2024-11-19 17:49:45 +01:00

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

View file

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