mirror of
https://github.com/nix-community/home-manager.git
synced 2024-12-14 11:57:55 +00:00
df7f29a231
1. Zoxide (v0.9.2) leverages `def-env` in their `zoxide init nushell` output. 2. Since Nushell v0.88, they have removed (previously deprecated) `def-env`: https://www.nushell.sh/blog/2023-12-12-nushell_0_88_0.html#breaking-changes-toc
98 lines
2.3 KiB
Nix
98 lines
2.3 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-aliases" ];
|
|
description = ''
|
|
List of options to pass to zoxide.
|
|
'';
|
|
};
|
|
|
|
enableBashIntegration = mkOption {
|
|
default = true;
|
|
type = types.bool;
|
|
description = ''
|
|
Whether to enable Bash integration.
|
|
'';
|
|
};
|
|
|
|
enableZshIntegration = mkOption {
|
|
default = true;
|
|
type = types.bool;
|
|
description = ''
|
|
Whether to enable Zsh integration.
|
|
'';
|
|
};
|
|
|
|
enableFishIntegration = mkOption {
|
|
default = true;
|
|
type = types.bool;
|
|
description = ''
|
|
Whether to enable Fish integration.
|
|
'';
|
|
};
|
|
|
|
enableNushellIntegration = mkOption {
|
|
default = true;
|
|
type = types.bool;
|
|
description = ''
|
|
Whether to enable Nushell integration.
|
|
'';
|
|
};
|
|
};
|
|
|
|
config = mkIf cfg.enable {
|
|
home.packages = [ cfg.package ];
|
|
|
|
programs.bash.initExtra = mkIf cfg.enableBashIntegration ''
|
|
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} |
|
|
str replace "def-env" "def --env" --all | # https://github.com/ajeetdsouza/zoxide/pull/632
|
|
save --force ${config.xdg.cacheHome}/zoxide/init.nu
|
|
'';
|
|
extraConfig = ''
|
|
source ${config.xdg.cacheHome}/zoxide/init.nu
|
|
'';
|
|
};
|
|
};
|
|
}
|