diff --git a/pkgs/shells/nushell/default.nix b/pkgs/shells/nushell/default.nix index d87d842be08c3..3b2b6d24bad3a 100644 --- a/pkgs/shells/nushell/default.nix +++ b/pkgs/shells/nushell/default.nix @@ -19,6 +19,8 @@ , testers , nushell , nix-update-script +, makeBinaryWrapper +, plugins ? [] }: let @@ -38,7 +40,7 @@ rustPlatform.buildRustPackage { cargoHash = "sha256-NtTCuTWbGTrGKF7ulm3Bfal/WuBtPEX7QvHoOyKY1V8="; - nativeBuildInputs = [ pkg-config ] + nativeBuildInputs = [ pkg-config makeBinaryWrapper ] ++ lib.optionals (withDefaultFeatures && stdenv.isLinux) [ python3 ] ++ lib.optionals stdenv.isDarwin [ rustPlatform.bindgenHook ]; @@ -59,6 +61,20 @@ rustPlatform.buildRustPackage { runHook postCheck ''; + postInstall = lib.optional (plugins != []) ( + let + pluginRegistryPath = "$out/share/nushell/plugins.nu"; + pluginRegistrations = (map (p: ''$out/bin/nu --plugin-config ${pluginRegistryPath} -c "register ${p}/bin/${p.meta.mainProgram}"'') plugins); + in + '' + mkdir -p "$(dirname ${pluginRegistryPath})" + touch ${pluginRegistryPath} + ${builtins.concatStringsSep "\n" pluginRegistrations} + wrapProgram $out/bin/nu \ + --add-flags --plugin-config \ + --add-flags "${pluginRegistryPath}" + ''); + passthru = { shellPath = "/bin/nu"; tests.version = testers.testVersion { diff --git a/pkgs/shells/nushell/plugins/formats.nix b/pkgs/shells/nushell/plugins/formats.nix index bc63789633a23..14ea900b865fe 100644 --- a/pkgs/shells/nushell/plugins/formats.nix +++ b/pkgs/shells/nushell/plugins/formats.nix @@ -25,5 +25,6 @@ rustPlatform.buildRustPackage { license = licenses.mpl20; maintainers = with maintainers; [ viraptor ]; platforms = with platforms; all; + mainProgram = "nu_plugin_formats"; }; } diff --git a/pkgs/shells/nushell/plugins/gstat.nix b/pkgs/shells/nushell/plugins/gstat.nix index 39af12a6a9350..6906d3876f7f3 100644 --- a/pkgs/shells/nushell/plugins/gstat.nix +++ b/pkgs/shells/nushell/plugins/gstat.nix @@ -25,5 +25,6 @@ rustPlatform.buildRustPackage { license = licenses.mpl20; maintainers = with maintainers; [ mrkkrp ]; platforms = with platforms; all; + mainProgram = "nu_plugin_gstat"; }; } diff --git a/pkgs/shells/nushell/plugins/query.nix b/pkgs/shells/nushell/plugins/query.nix index 0988d4f80bb78..39f057b96a78a 100644 --- a/pkgs/shells/nushell/plugins/query.nix +++ b/pkgs/shells/nushell/plugins/query.nix @@ -32,5 +32,6 @@ rustPlatform.buildRustPackage { license = licenses.mpl20; maintainers = with maintainers; [ happysalada ]; platforms = with platforms; all; + mainProgram = "nu_plugin_query"; }; } diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index c498c4bf3498b..6ddbbdd314ec9 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -28507,6 +28507,7 @@ with pkgs; nushell = darwin.apple_sdk_11_0.callPackage ../shells/nushell { inherit (darwin.apple_sdk_11_0) Libsystem; inherit (darwin.apple_sdk_11_0.frameworks) AppKit Security; + plugins = with nushellPlugins; [ formats gstat query ]; }; nushellFull = nushell.override { additionalFeatures = p: p ++ ["dataframe" "extra"]; };