diff --git a/nixos/doc/manual/release-notes/rl-2505.section.md b/nixos/doc/manual/release-notes/rl-2505.section.md index 80ab576b438c..4ebf4f30bd63 100644 --- a/nixos/doc/manual/release-notes/rl-2505.section.md +++ b/nixos/doc/manual/release-notes/rl-2505.section.md @@ -150,6 +150,8 @@ - [duckdns](https://www.duckdns.org), free dynamic DNS. Available with [services.duckdns](options.html#opt-services.duckdns.enable) +- [Zoxide](https://github.com/ajeetdsouza/zoxide), a smarter cd command, inspired by z and autojump. Available as [programs.zoxide](options.html#opt-programs.zoxide.enable) + - [victorialogs][https://docs.victoriametrics.com/victorialogs/], log database from VictoriaMetrics. Available as [services.victorialogs](#opt-services.victorialogs.enable) - [gokapi](https://github.com/Forceu/Gokapi), Lightweight selfhosted Firefox Send alternative without public upload. AWS S3 supported. Available with [services.gokapi](options.html#opt-services.gokapi.enable) diff --git a/nixos/modules/module-list.nix b/nixos/modules/module-list.nix index 902503335169..05ade64f3f4b 100644 --- a/nixos/modules/module-list.nix +++ b/nixos/modules/module-list.nix @@ -353,6 +353,7 @@ ./programs/ydotool.nix ./programs/yubikey-touch-detector.nix ./programs/zmap.nix + ./programs/zoxide.nix ./programs/zsh/oh-my-zsh.nix ./programs/zsh/zsh-autoenv.nix ./programs/zsh/zsh-autosuggestions.nix diff --git a/nixos/modules/programs/zoxide.nix b/nixos/modules/programs/zoxide.nix new file mode 100644 index 000000000000..de85259d0100 --- /dev/null +++ b/nixos/modules/programs/zoxide.nix @@ -0,0 +1,72 @@ +{ + config, + lib, + pkgs, + ... +}: +let + inherit (lib.options) mkEnableOption mkPackageOption mkOption; + inherit (lib.modules) mkIf; + inherit (lib.meta) getExe; + inherit (lib.types) listOf str; + inherit (lib.strings) concatStringsSep; + + cfg = config.programs.zoxide; + + cfgFlags = concatStringsSep " " cfg.flags; + +in +{ + options.programs.zoxide = { + enable = mkEnableOption "zoxide, a smarter cd command that learns your habits"; + package = mkPackageOption pkgs "zoxide" { }; + + enableBashIntegration = mkEnableOption "Bash integration" // { + default = true; + }; + enableZshIntegration = mkEnableOption "Zsh integration" // { + default = true; + }; + enableFishIntegration = mkEnableOption "Fish integration" // { + default = true; + }; + enableXonshIntegration = mkEnableOption "Xonsh integration" // { + default = true; + }; + + flags = mkOption { + type = listOf str; + default = [ ]; + example = [ + "--no-cmd" + "--cmd j" + ]; + description = '' + List of flags for zoxide init + ''; + }; + + }; + + config = mkIf cfg.enable { + environment.systemPackages = [ cfg.package ]; + + programs = { + zsh.interactiveShellInit = mkIf cfg.enableZshIntegration '' + eval "$(${getExe cfg.package} init zsh ${cfgFlags} )" + ''; + bash.interactiveShellInit = mkIf cfg.enableBashIntegration '' + eval "$(${getExe cfg.package} init bash ${cfgFlags} )" + ''; + fish.interactiveShellInit = mkIf cfg.enableFishIntegration '' + ${getExe cfg.package} init fish ${cfgFlags} | source + ''; + xonsh.config = '' + execx($(${getExe cfg.package} init xonsh ${cfgFlags}), 'exec', __xonsh__.ctx, filename='zoxide') + ''; + }; + + }; + + meta.maintainers = with lib.maintainers; [ heisfer ]; +}