fork/home-manager

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

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

master
2.2 KiB96 linesraw
1{ config, lib, pkgs, ... }:
2
3with lib;
4
5let
6
7  cfg = config.programs.zoxide;
8
9  cfgOptions = concatStringsSep " " cfg.options;
10
11in {
12  meta.maintainers = [ ];
13
14  options.programs.zoxide = {
15    enable = mkEnableOption "zoxide";
16
17    package = mkOption {
18      type = types.package;
19      default = pkgs.zoxide;
20      defaultText = literalExpression "pkgs.zoxide";
21      description = ''
22        Zoxide package to install.
23      '';
24    };
25
26    options = mkOption {
27      type = types.listOf types.str;
28      default = [ ];
29      example = [ "--no-aliases" ];
30      description = ''
31        List of options to pass to zoxide.
32      '';
33    };
34
35    enableBashIntegration = mkOption {
36      default = true;
37      type = types.bool;
38      description = ''
39        Whether to enable Bash integration.
40      '';
41    };
42
43    enableZshIntegration = mkOption {
44      default = true;
45      type = types.bool;
46      description = ''
47        Whether to enable Zsh integration.
48      '';
49    };
50
51    enableFishIntegration = mkOption {
52      default = true;
53      type = types.bool;
54      description = ''
55        Whether to enable Fish integration.
56      '';
57    };
58
59    enableNushellIntegration = mkOption {
60      default = true;
61      type = types.bool;
62      description = ''
63        Whether to enable Nushell integration.
64      '';
65    };
66  };
67
68  config = mkIf cfg.enable {
69    home.packages = [ cfg.package ];
70
71    programs.bash.initExtra = mkIf cfg.enableBashIntegration ''
72      eval "$(${cfg.package}/bin/zoxide init bash ${cfgOptions})"
73    '';
74
75    programs.zsh.initExtra = mkIf cfg.enableZshIntegration ''
76      eval "$(${cfg.package}/bin/zoxide init zsh ${cfgOptions})"
77    '';
78
79    programs.fish.shellInit = mkIf cfg.enableFishIntegration ''
80      ${cfg.package}/bin/zoxide init fish ${cfgOptions} | source
81    '';
82
83    programs.nushell = mkIf cfg.enableNushellIntegration {
84      extraEnv = ''
85        let zoxide_cache = "${config.xdg.cacheHome}/zoxide"
86        if not ($zoxide_cache | path exists) {
87          mkdir $zoxide_cache
88        }
89        ${cfg.package}/bin/zoxide init nushell ${cfgOptions} | save --force ${config.xdg.cacheHome}/zoxide/init.nu
90      '';
91      extraConfig = ''
92        source ${config.xdg.cacheHome}/zoxide/init.nu
93      '';
94    };
95  };
96}