fork/home-manager

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

Mario Rodastreewide: remove marsam as maintainer (#4136)a4817894

master
2.3 KiB101 linesraw
1{ config, lib, pkgs, ... }:
2
3with lib;
4let
5
6  cfg = config.programs.mcfly;
7
8in {
9  meta.maintainers = [ ];
10
11  imports = [
12    (mkChangedOptionModule # \
13      [ "programs" "mcfly" "enableFuzzySearch" ] # \
14      [ "programs" "mcfly" "fuzzySearchFactor" ] # \
15      (config:
16        let
17          value =
18            getAttrFromPath [ "programs" "mcfly" "enableFuzzySearch" ] config;
19        in if value then 2 else 0))
20  ];
21
22  options.programs.mcfly = {
23    enable = mkEnableOption "mcfly";
24
25    keyScheme = mkOption {
26      type = types.enum [ "emacs" "vim" ];
27      default = "emacs";
28      description = ''
29        Key scheme to use.
30      '';
31    };
32
33    enableLightTheme = mkOption {
34      default = false;
35      type = types.bool;
36      description = ''
37        Whether to enable light mode theme.
38      '';
39    };
40
41    fuzzySearchFactor = mkOption {
42      default = 0;
43      type = types.ints.unsigned;
44      description = ''
45        Whether to enable fuzzy searching.
46        0 is off; higher numbers weight toward shorter matches.
47        Values in the 2-5 range get good results so far.
48      '';
49    };
50
51    enableBashIntegration = mkOption {
52      default = true;
53      type = types.bool;
54      description = ''
55        Whether to enable Bash integration.
56      '';
57    };
58
59    enableZshIntegration = mkOption {
60      default = true;
61      type = types.bool;
62      description = ''
63        Whether to enable Zsh integration.
64      '';
65    };
66
67    enableFishIntegration = mkOption {
68      default = true;
69      type = types.bool;
70      description = ''
71        Whether to enable Fish integration.
72      '';
73    };
74  };
75
76  config = mkIf cfg.enable (mkMerge [
77    {
78      home.packages = [ pkgs.mcfly ];
79
80      programs.bash.initExtra = mkIf cfg.enableBashIntegration ''
81        eval "$(${pkgs.mcfly}/bin/mcfly init bash)"
82      '';
83
84      programs.zsh.initExtra = mkIf cfg.enableZshIntegration ''
85        eval "$(${pkgs.mcfly}/bin/mcfly init zsh)"
86      '';
87
88      programs.fish.shellInit = mkIf cfg.enableFishIntegration ''
89        ${pkgs.mcfly}/bin/mcfly init fish | source
90      '';
91
92      home.sessionVariables.MCFLY_KEY_SCHEME = cfg.keyScheme;
93    }
94
95    (mkIf cfg.enableLightTheme { home.sessionVariables.MCFLY_LIGHT = "TRUE"; })
96
97    (mkIf (cfg.fuzzySearchFactor > 0) {
98      home.sessionVariables.MCFLY_FUZZY = cfg.fuzzySearchFactor;
99    })
100  ]);
101}