nixos/zoxide: init module

This commit is contained in:
heisfer 2025-03-26 21:29:58 +02:00
parent 45f53191eb
commit 825381d5ed
3 changed files with 75 additions and 0 deletions

View File

@ -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)

View File

@ -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

View File

@ -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 ];
}