fork/home-manager

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

Sinkerinezplug: Update the path of init.zsh (#3922)27d89b49

master
1.4 KiB70 linesraw
1{ config, lib, pkgs, ... }:
2
3with lib;
4
5let
6
7  cfg = config.programs.zsh.zplug;
8
9  pluginModule = types.submodule ({ config, ... }: {
10    options = {
11      name = mkOption {
12        type = types.str;
13        description = "The name of the plugin.";
14      };
15
16      tags = mkOption {
17        type = types.listOf types.str;
18        default = [ ];
19        description = "The plugin tags.";
20      };
21    };
22
23  });
24
25in {
26  options.programs.zsh.zplug = {
27    enable = mkEnableOption "zplug - a zsh plugin manager";
28
29    plugins = mkOption {
30      default = [ ];
31      type = types.listOf pluginModule;
32      description = "List of zplug plugins.";
33    };
34
35    zplugHome = mkOption {
36      type = types.path;
37      default = "${config.home.homeDirectory}/.zplug";
38      defaultText = "~/.zplug";
39      apply = toString;
40      description = "Path to zplug home directory.";
41    };
42  };
43
44  config = mkIf cfg.enable {
45    home.packages = [ pkgs.zplug ];
46
47    programs.zsh.initExtraBeforeCompInit = ''
48      export ZPLUG_HOME=${cfg.zplugHome}
49
50      source ${pkgs.zplug}/share/zplug/init.zsh
51
52      ${optionalString (cfg.plugins != [ ]) ''
53        ${concatStrings (map (plugin: ''
54          zplug "${plugin.name}"${
55            optionalString (plugin.tags != [ ]) ''
56              ${concatStrings (map (tag: ", ${tag}") plugin.tags)}
57            ''
58          }
59        '') cfg.plugins)}
60      ''}
61
62      if ! zplug check; then
63        zplug install
64      fi
65
66      zplug load
67    '';
68
69  };
70}