1
0
Fork 0
mirror of https://github.com/nix-community/home-manager.git synced 2025-03-18 14:28:15 +00:00
home-manager/modules/programs/zoxide.nix
carschandler f8bb0ba6de
zoxide: update mkOrder to place bash configuration at end of bashrc (#6572)
I updated my flake a few weeks back and `zoxide` has been giving me an error recently:

```
zoxide: detected a possible configuration issue.
Please ensure that zoxide is initialized right at the end of your shell configuration file (usually ~/.bashrc).

If the issue persists, consider filing an issue at:
https://github.com/ajeetdsouza/zoxide/issues

Disable this message by setting _ZO_DOCTOR=0.
```

To be fair, I haven't noticed any issues with `zoxide` apart from this error message.

The `zoxide` eval statement in my `.bashrc` is not "right at the end" of the file as mentioned in the message which isn't surprising given that it is given a `mkOrder 150`. In my own config, I increased this to `2000` (to ensure it comes after any `mkAfter`s which are `mkOrder 1500` to ensure it happens at the end of the script. After doing so, it appears at the end of my `bashrc` and I no longer get the error message.
2025-03-09 22:50:41 -05:00

77 lines
1.9 KiB
Nix

{ config, lib, pkgs, ... }:
with lib;
let
cfg = config.programs.zoxide;
cfgOptions = concatStringsSep " " cfg.options;
in {
meta.maintainers = [ ];
options.programs.zoxide = {
enable = mkEnableOption "zoxide";
package = mkOption {
type = types.package;
default = pkgs.zoxide;
defaultText = literalExpression "pkgs.zoxide";
description = ''
Zoxide package to install.
'';
};
options = mkOption {
type = types.listOf types.str;
default = [ ];
example = [ "--no-cmd" ];
description = ''
List of options to pass to zoxide init.
'';
};
enableBashIntegration =
lib.hm.shell.mkBashIntegrationOption { inherit config; };
enableFishIntegration =
lib.hm.shell.mkFishIntegrationOption { inherit config; };
enableNushellIntegration =
lib.hm.shell.mkNushellIntegrationOption { inherit config; };
enableZshIntegration =
lib.hm.shell.mkZshIntegrationOption { inherit config; };
};
config = mkIf cfg.enable {
home.packages = [ cfg.package ];
programs.bash.initExtra = mkIf cfg.enableBashIntegration (mkOrder 2000 ''
eval "$(${cfg.package}/bin/zoxide init bash ${cfgOptions})"
'');
programs.zsh.initExtra = mkIf cfg.enableZshIntegration ''
eval "$(${cfg.package}/bin/zoxide init zsh ${cfgOptions})"
'';
programs.fish.interactiveShellInit = mkIf cfg.enableFishIntegration ''
${cfg.package}/bin/zoxide init fish ${cfgOptions} | source
'';
programs.nushell = mkIf cfg.enableNushellIntegration {
extraEnv = ''
let zoxide_cache = "${config.xdg.cacheHome}/zoxide"
if not ($zoxide_cache | path exists) {
mkdir $zoxide_cache
}
${cfg.package}/bin/zoxide init nushell ${cfgOptions} |
save --force ${config.xdg.cacheHome}/zoxide/init.nu
'';
extraConfig = ''
source ${config.xdg.cacheHome}/zoxide/init.nu
'';
};
};
}