From 8541ae6c6a08b21b2882452ccaaea490e8ac30b5 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. --- pkgs/shells/nushell/plugins/default.nix | 52 +++++++++++++++---------- 1 file changed, 32 insertions(+), 20 deletions(-) diff --git a/pkgs/shells/nushell/plugins/default.nix b/pkgs/shells/nushell/plugins/default.nix index d689e49b43e1..065c7786d976 100644 --- a/pkgs/shells/nushell/plugins/default.nix +++ b/pkgs/shells/nushell/plugins/default.nix @@ -3,28 +3,40 @@ 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 { }; - hcl = callPackage ./hcl.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 { }; + hcl = callPackage ./hcl.nix { }; + } + // lib.optionalAttrs config.allowAliases { + regex = throw "`nu_plugin_regex` is no longer compatible with the current Nushell release."; + } + ) )