fork/home-manager

git clone https://git.julia.blue/fork/home-manager

Damien Cassouantidote: cleanup unused bindings0962772e

master
1.5 KiB55 linesraw
1{ config, lib, pkgs, ... }:
2
3with lib;
4let
5  cfg = config.programs.zsh.antidote;
6
7  zPluginStr = (pluginNames:
8    optionalString (pluginNames != [ ]) "${concatStrings (map (name: ''
9      ${name}
10    '') pluginNames)}");
11
12  parseHashId = path:
13    elemAt (builtins.match "/nix/store/([a-zA-Z0-9]+)-.*" path) 0;
14in {
15  meta.maintainers = [ maintainers.hitsmaxft ];
16
17  options.programs.zsh.antidote = {
18    enable = mkEnableOption "antidote - a zsh plugin manager";
19
20    plugins = mkOption {
21      type = types.listOf types.str;
22      default = [ ];
23      example = [ "zsh-users/zsh-autosuggestions" ];
24      description = "List of antidote plugins.";
25    };
26
27    useFriendlyNames = mkEnableOption "friendly names";
28
29    package = mkPackageOption pkgs "antidote" { };
30  };
31
32  config = mkIf cfg.enable {
33    home.packages = [ cfg.package ];
34    programs.zsh.initExtraBeforeCompInit = let
35      configFiles = pkgs.runCommand "hm_antidote-files" { } ''
36        echo "${zPluginStr cfg.plugins}" > $out
37      '';
38      hashId = parseHashId "${configFiles}";
39    in ''
40      ## home-manager/antidote begin :
41      source ${cfg.package}/share/antidote/antidote.zsh
42      ${optionalString cfg.useFriendlyNames
43      "zstyle ':antidote:bundle' use-friendly-names 'yes'"}
44
45      bundlefile=${configFiles}
46      zstyle ':antidote:bundle' file $bundlefile
47      staticfile=/tmp/tmp_hm_zsh_plugins.zsh-${hashId}
48      zstyle ':antidote:static' file $staticfile
49
50      antidote load $bundlefile $staticfile
51
52      ## home-manager/antidote end
53    '';
54  };
55}