1
0
Fork 0
mirror of https://github.com/nix-community/home-manager.git synced 2025-11-08 19:46:05 +01:00
home-manager/modules/programs/antidote/default.nix
Austin Horstman 4fca600cb1 treewide: implement auto importing for modules
Reduce maintenance burden and increase efficiency by automatically
importing modules following a specific convention.

Co-authored-by: awwpotato <awwpotato@voidq.com>
Signed-off-by: Austin Horstman <khaneliman12@gmail.com>
2025-06-22 23:58:37 -05:00

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
'');
};
}