97 lines
2.4 KiB
Nix
97 lines
2.4 KiB
Nix
{
|
|
config,
|
|
lib,
|
|
pkgs,
|
|
...
|
|
}:
|
|
with lib; let
|
|
cfg = config.programs.elvish;
|
|
in {
|
|
options.programs.elvish = {
|
|
enable = mkEnableOption "Elvish, a friendly interactive shell and an expressive programming";
|
|
|
|
defaultFromBash = mkOption {
|
|
type = types.bool;
|
|
default = false;
|
|
description = ''
|
|
Launch automatically when an interactive Bash shell is started
|
|
'';
|
|
};
|
|
|
|
zoxide = mkOption {
|
|
type = types.bool;
|
|
default = false;
|
|
description = ''
|
|
Enable zoxide smart directory switcher
|
|
'';
|
|
};
|
|
|
|
starship = mkOption {
|
|
type = types.bool;
|
|
default = false;
|
|
description = ''
|
|
Use the starship prompt
|
|
'';
|
|
};
|
|
|
|
direnv = mkOption {
|
|
type = types.bool;
|
|
default = false;
|
|
description = ''
|
|
Enable direnv integration for elvish
|
|
'';
|
|
};
|
|
|
|
package = mkOption {
|
|
type = types.package;
|
|
default = pkgs.elvish;
|
|
defaultText = literalExpression "pkgs.elvish";
|
|
description = ''
|
|
The elvish package to install. May be used to change the version.
|
|
'';
|
|
};
|
|
|
|
initExtra = mkOption {
|
|
type = types.lines;
|
|
default = "";
|
|
description = ''
|
|
Elvish code called during interactive elvish shell
|
|
initialisation.
|
|
'';
|
|
};
|
|
};
|
|
|
|
config = mkIf cfg.enable {
|
|
home.packages = [cfg.package];
|
|
|
|
# programs.man.generateCaches = mkDefault true;
|
|
|
|
xdg.configFile."elvish/rc.elv".text = cfg.initExtra;
|
|
|
|
programs.bash.enable = mkIf cfg.defaultFromBash true;
|
|
programs.bash.initExtra = mkIf cfg.defaultFromBash ''
|
|
exec elvish
|
|
'';
|
|
|
|
programs.starship.enableBashIntegration = mkIf cfg.defaultFromBash false;
|
|
|
|
programs.starship.enable = mkIf cfg.starship true;
|
|
programs.zoxide.enable = mkIf cfg.zoxide true;
|
|
programs.direnv.enable = mkIf cfg.direnv true;
|
|
|
|
programs.elvish.initExtra = mkMerge [
|
|
(mkIf cfg.starship ''
|
|
if (and (not-eq $E:TERM "dumb") (or (not (has-env "INSIDE_EMACS")) (eq $E:INSIDE_EMACS "vterm"))) {
|
|
eval (${config.home.profileDirectory}/bin/starship init elvish)
|
|
}
|
|
'')
|
|
(mkIf cfg.zoxide ''
|
|
eval (${config.programs.zoxide.package}/bin/zoxide init elvish | slurp)
|
|
'')
|
|
(mkIf cfg.direnv ''
|
|
eval (${pkgs.direnv}/bin/direnv hook elvish | ${pkgs.gnused}/bin/sed 's/except/catch/' | slurp)
|
|
'')
|
|
];
|
|
};
|
|
}
|