mirror of
https://github.com/nix-community/home-manager.git
synced 2025-11-08 11:36:05 +01:00
Some files don't need nesting and can be root level again to reduce conflicts with other PRs. Signed-off-by: Austin Horstman <khaneliman12@gmail.com>
65 lines
1.7 KiB
Nix
65 lines
1.7 KiB
Nix
{
|
|
config,
|
|
lib,
|
|
pkgs,
|
|
...
|
|
}:
|
|
let
|
|
cfg = config.programs.zsh.antidote;
|
|
|
|
zPluginStr = (
|
|
pluginNames:
|
|
lib.optionalString (pluginNames != [ ])
|
|
"${lib.concatStrings (
|
|
map (name: ''
|
|
${name}
|
|
'') pluginNames
|
|
)}"
|
|
);
|
|
|
|
parseHashId = path: lib.elemAt (builtins.match "${builtins.storeDir}/([a-zA-Z0-9]+)-.*" path) 0;
|
|
in
|
|
{
|
|
meta.maintainers = [ lib.maintainers.hitsmaxft ];
|
|
|
|
options.programs.zsh.antidote = {
|
|
enable = lib.mkEnableOption "antidote - a zsh plugin manager";
|
|
|
|
plugins = lib.mkOption {
|
|
type = lib.types.listOf lib.types.str;
|
|
default = [ ];
|
|
example = [ "zsh-users/zsh-autosuggestions" ];
|
|
description = "List of antidote plugins.";
|
|
};
|
|
|
|
useFriendlyNames = lib.mkEnableOption "friendly names";
|
|
|
|
package = lib.mkPackageOption pkgs "antidote" { nullable = true; };
|
|
};
|
|
|
|
config = lib.mkIf cfg.enable {
|
|
home.packages = lib.mkIf (cfg.package != null) [ cfg.package ];
|
|
|
|
programs.zsh.initContent =
|
|
let
|
|
configFiles = pkgs.runCommand "hm_antidote-files" { } ''
|
|
echo "${zPluginStr cfg.plugins}" > $out
|
|
'';
|
|
hashId = parseHashId "${configFiles}";
|
|
in
|
|
(lib.mkOrder 550 ''
|
|
## home-manager/antidote begin :
|
|
source ${cfg.package}/share/antidote/antidote.zsh
|
|
${lib.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
|
|
'');
|
|
};
|
|
}
|