From 295d90e22d557ccc3049dc92460b82f372cd3892 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miko=C5=82aj=20Lercher?= Date: Tue, 25 Nov 2025 14:04:20 +0100 Subject: [PATCH] nix-index: add nushell integration (#8211) https://github.com/nix-community/nix-index?tab=readme-ov-file#usage-as-a-command-not-found-replacement --- modules/misc/news/2025/11/2025-11-25_11-33-50.nix | 12 ++++++++++++ modules/programs/nix-index.nix | 6 ++++++ tests/modules/programs/nix-index/integrations.nix | 7 +++++++ 3 files changed, 25 insertions(+) create mode 100644 modules/misc/news/2025/11/2025-11-25_11-33-50.nix diff --git a/modules/misc/news/2025/11/2025-11-25_11-33-50.nix b/modules/misc/news/2025/11/2025-11-25_11-33-50.nix new file mode 100644 index 000000000..1ce2a8ac3 --- /dev/null +++ b/modules/misc/news/2025/11/2025-11-25_11-33-50.nix @@ -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; + ''; +} diff --git a/modules/programs/nix-index.nix b/modules/programs/nix-index.nix index 82a49debd..f52522f32 100644 --- a/modules/programs/nix-index.nix +++ b/modules/programs/nix-index.nix @@ -23,6 +23,8 @@ in enableFishIntegration = lib.hm.shell.mkFishIntegrationOption { inherit config; }; enableZshIntegration = lib.hm.shell.mkZshIntegrationOption { inherit config; }; + + enableNushellIntegration = lib.hm.shell.mkNushellIntegrationOption { inherit config; }; }; config = lib.mkIf cfg.enable { @@ -65,5 +67,9 @@ in ${wrapper} $argv 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" + ); }; } diff --git a/tests/modules/programs/nix-index/integrations.nix b/tests/modules/programs/nix-index/integrations.nix index 67b819031..d8211e283 100644 --- a/tests/modules/programs/nix-index/integrations.nix +++ b/tests/modules/programs/nix-index/integrations.nix @@ -11,6 +11,7 @@ in programs.bash.enable = true; programs.fish.enable = true; programs.zsh.enable = true; + programs.nushell.enable = true; # Needed to avoid error with dummy fish package. xdg.dataFile."fish/home-manager_generated_completions".source = lib.mkForce ( @@ -36,5 +37,11 @@ in assertFileExists home-files/.config/fish/config.fish assertFileRegex \ 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)' ''; }