From 32675f47f4eab57869640856b35b6fd2fd3915a0 Mon Sep 17 00:00:00 2001 From: Tom van Dijk <18gatenmaker6@gmail.com> Date: Sat, 28 Jun 2025 01:31:24 +0200 Subject: [PATCH] nushellPlugins.*: add `versionCheckHook` Why for each all at the same time? Because all nushell plugins should respond in the same way with either no arguments passed or with `--help`, which contains their version. Also because when new plugins get added or plugins get updated, problems can be easily spotted because the errors are really loud. (cherry picked from commit 8541ae6c6a08b21b2882452ccaaea490e8ac30b5) --- pkgs/shells/nushell/plugins/default.nix | 50 +++++++++++++++---------- 1 file changed, 31 insertions(+), 19 deletions(-) diff --git a/pkgs/shells/nushell/plugins/default.nix b/pkgs/shells/nushell/plugins/default.nix index 1305cd7183f4..f73b2d43b7d2 100644 --- a/pkgs/shells/nushell/plugins/default.nix +++ b/pkgs/shells/nushell/plugins/default.nix @@ -3,27 +3,39 @@ config, newScope, dbus, + versionCheckHook, }: lib.makeScope newScope ( self: - with self; - { - gstat = callPackage ./gstat.nix { }; - formats = callPackage ./formats.nix { }; - polars = callPackage ./polars.nix { }; - query = callPackage ./query.nix { }; - net = callPackage ./net.nix { }; - units = callPackage ./units.nix { }; - highlight = callPackage ./highlight.nix { }; - dbus = callPackage ./dbus.nix { - inherit dbus; - nushell_plugin_dbus = self.dbus; - }; - skim = callPackage ./skim.nix { }; - semver = callPackage ./semver.nix { }; - } - // lib.optionalAttrs config.allowAliases { - regex = throw "`nu_plugin_regex` is no longer compatible with the current Nushell release."; - } + + lib.mapAttrs + ( + _n: p: + p.overrideAttrs { + doInstallCheck = true; + nativeInstallCheckInputs = [ versionCheckHook ]; + } + ) + ( + with self; + { + gstat = callPackage ./gstat.nix { }; + formats = callPackage ./formats.nix { }; + polars = callPackage ./polars.nix { }; + query = callPackage ./query.nix { }; + net = callPackage ./net.nix { }; + units = callPackage ./units.nix { }; + highlight = callPackage ./highlight.nix { }; + dbus = callPackage ./dbus.nix { + inherit dbus; + nushell_plugin_dbus = self.dbus; + }; + skim = callPackage ./skim.nix { }; + semver = callPackage ./semver.nix { }; + } + // lib.optionalAttrs config.allowAliases { + regex = throw "`nu_plugin_regex` is no longer compatible with the current Nushell release."; + } + ) )