mirror of
https://github.com/nix-community/home-manager.git
synced 2026-01-12 01:59:37 +08:00
nix-index: add nushell integration (#8211)
https://github.com/nix-community/nix-index?tab=readme-ov-file#usage-as-a-command-not-found-replacement
This commit is contained in:
12
modules/misc/news/2025/11/2025-11-25_11-33-50.nix
Normal file
12
modules/misc/news/2025/11/2025-11-25_11-33-50.nix
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
{ config, ... }:
|
||||||
|
|
||||||
|
{
|
||||||
|
time = "2025-11-25T11:33:50+00:00";
|
||||||
|
condition = config.programs.nix-index.enable && config.programs.nushell.enable;
|
||||||
|
message = ''
|
||||||
|
The nix-index module now adds a command-not-found handler to Nushell by default.
|
||||||
|
|
||||||
|
This can be disabled:
|
||||||
|
programs.nix-index.enableNushellIntegration = false;
|
||||||
|
'';
|
||||||
|
}
|
||||||
@@ -23,6 +23,8 @@ in
|
|||||||
enableFishIntegration = lib.hm.shell.mkFishIntegrationOption { inherit config; };
|
enableFishIntegration = lib.hm.shell.mkFishIntegrationOption { inherit config; };
|
||||||
|
|
||||||
enableZshIntegration = lib.hm.shell.mkZshIntegrationOption { inherit config; };
|
enableZshIntegration = lib.hm.shell.mkZshIntegrationOption { inherit config; };
|
||||||
|
|
||||||
|
enableNushellIntegration = lib.hm.shell.mkNushellIntegrationOption { inherit config; };
|
||||||
};
|
};
|
||||||
|
|
||||||
config = lib.mkIf cfg.enable {
|
config = lib.mkIf cfg.enable {
|
||||||
@@ -65,5 +67,9 @@ in
|
|||||||
${wrapper} $argv
|
${wrapper} $argv
|
||||||
end
|
end
|
||||||
'';
|
'';
|
||||||
|
|
||||||
|
programs.nushell.settings.hooks.command_not_found = lib.mkIf cfg.enableNushellIntegration (
|
||||||
|
lib.hm.nushell.mkNushellInline "source ${cfg.package}/etc/profile.d/command-not-found.nu"
|
||||||
|
);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ in
|
|||||||
programs.bash.enable = true;
|
programs.bash.enable = true;
|
||||||
programs.fish.enable = true;
|
programs.fish.enable = true;
|
||||||
programs.zsh.enable = true;
|
programs.zsh.enable = true;
|
||||||
|
programs.nushell.enable = true;
|
||||||
|
|
||||||
# Needed to avoid error with dummy fish package.
|
# Needed to avoid error with dummy fish package.
|
||||||
xdg.dataFile."fish/home-manager_generated_completions".source = lib.mkForce (
|
xdg.dataFile."fish/home-manager_generated_completions".source = lib.mkForce (
|
||||||
@@ -36,5 +37,11 @@ in
|
|||||||
assertFileExists home-files/.config/fish/config.fish
|
assertFileExists home-files/.config/fish/config.fish
|
||||||
assertFileRegex \
|
assertFileRegex \
|
||||||
home-files/.config/fish/config.fish '${fishRegex}'
|
home-files/.config/fish/config.fish '${fishRegex}'
|
||||||
|
|
||||||
|
# Nushell integration
|
||||||
|
assertFileExists home-files/.config/nushell/config.nu
|
||||||
|
assertFileContains \
|
||||||
|
home-files/.config/nushell/config.nu \
|
||||||
|
'$env.config.hooks.command_not_found = (source @nix-index@/etc/profile.d/command-not-found.nu)'
|
||||||
'';
|
'';
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user