1
0
Fork 0
mirror of https://github.com/nix-community/home-manager synced 2024-11-16 08:09:45 +01:00
home-manager/modules/programs/antidote.nix
Graham Bennett 179f6acaf7
antidote: Use builtins.storeDir (#5182)
This allows the module to work for non-/nix stores.
2024-03-27 09:45:49 -06:00

55 lines
1.5 KiB
Nix

{ config, lib, pkgs, ... }:
with lib;
let
cfg = config.programs.zsh.antidote;
zPluginStr = (pluginNames:
optionalString (pluginNames != [ ]) "${concatStrings (map (name: ''
${name}
'') pluginNames)}");
parseHashId = path:
elemAt (builtins.match "${builtins.storeDir}/([a-zA-Z0-9]+)-.*" path) 0;
in {
meta.maintainers = [ maintainers.hitsmaxft ];
options.programs.zsh.antidote = {
enable = mkEnableOption "antidote - a zsh plugin manager";
plugins = mkOption {
type = types.listOf types.str;
default = [ ];
example = [ "zsh-users/zsh-autosuggestions" ];
description = "List of antidote plugins.";
};
useFriendlyNames = mkEnableOption "friendly names";
package = mkPackageOption pkgs "antidote" { };
};
config = mkIf cfg.enable {
home.packages = [ cfg.package ];
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=${configFiles}
zstyle ':antidote:bundle' file $bundlefile
staticfile=/tmp/tmp_hm_zsh_plugins.zsh-${hashId}
zstyle ':antidote:static' file $staticfile
antidote load $bundlefile $staticfile
## home-manager/antidote end
'';
};
}