1
0
Fork 0
mirror of https://github.com/nix-community/home-manager synced 2024-11-14 15:19:45 +01:00

[Backport release-22.11] starship: add nushell integration #3701 (#3697)

* starship: add nushell integration support

(cherry picked from commit 7ae7250df8)

* starship: fix nushell integration

Overwrite starship/init.nu if already exists, since this is a cache
file for sourcing in `init.nu`.

(cherry picked from commit 646ac0ad17)

* starship: re-add ion integration

which was apparently mistakenly removed in commit 7ae7250

(cherry picked from commit a62e4c88d7)

* starship: Use mkEnableOption (#3701)

---------

Co-authored-by: Philipp Mildenberger <philipp@mildenberger.me>
Co-authored-by: Aidan Gauland <aidalgol@users.noreply.github.com>
Co-authored-by: Marcel Transier <34482842+marceltransier@users.noreply.github.com>
This commit is contained in:
Lord-Valen 2023-03-08 09:24:16 -05:00 committed by GitHub
parent 07b0b43a92
commit b0be47978d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -58,36 +58,24 @@ in {
'';
};
enableBashIntegration = mkOption {
enableBashIntegration = mkEnableOption "Bash integration" // {
default = true;
type = types.bool;
description = ''
Whether to enable Bash integration.
'';
};
enableZshIntegration = mkOption {
enableZshIntegration = mkEnableOption "Zsh integration" // {
default = true;
type = types.bool;
description = ''
Whether to enable Zsh integration.
'';
};
enableFishIntegration = mkOption {
enableFishIntegration = mkEnableOption "Fish integration" // {
default = true;
type = types.bool;
description = ''
Whether to enable Fish integration.
'';
};
enableIonIntegration = mkOption {
enableIonIntegration = mkEnableOption "Ion integration" // {
default = true;
};
enableNushellIntegration = mkEnableOption "Nushell integration" // {
default = true;
type = types.bool;
description = ''
Whether to enable Ion integration.
'';
};
};
@ -121,5 +109,22 @@ in {
eval $(${starshipCmd} init ion)
end
'';
programs.nushell = mkIf cfg.enableNushellIntegration {
# Unfortunately nushell doesn't allow conditionally sourcing nor
# conditionally setting (global) environment variables, which is why the
# check for terminal compatibility (as seen above for the other shells) is
# not done here.
extraEnv = ''
let starship_cache = "${config.xdg.cacheHome}/starship"
if not ($starship_cache | path exists) {
mkdir $starship_cache
}
${starshipCmd} init nu | save --force ${config.xdg.cacheHome}/starship/init.nu
'';
extraConfig = ''
source ${config.xdg.cacheHome}/starship/init.nu
'';
};
};
}