From f5ce1684fa8146295e690c2264061902719d7190 Mon Sep 17 00:00:00 2001 From: Timon Schelling Date: Wed, 2 Jul 2025 16:39:46 +0000 Subject: [PATCH] nushellPlugins.*: replace version checks With `versionCheckHook` plugins are not allowed to have a `-unstable` suffix unless the executable also reports it in that way. `versionCheck` allows plugin version to have a `-unstable` suffix without expecting the plugin to report it that way. --- pkgs/shells/nushell/plugins/default.nix | 46 +++++++++++++------------ 1 file changed, 24 insertions(+), 22 deletions(-) diff --git a/pkgs/shells/nushell/plugins/default.nix b/pkgs/shells/nushell/plugins/default.nix index df15b6aadd151..365ab2c5e337f 100644 --- a/pkgs/shells/nushell/plugins/default.nix +++ b/pkgs/shells/nushell/plugins/default.nix @@ -2,10 +2,10 @@ lib, config, newScope, - dbus, - versionCheckHook, - nushell, runCommand, + nushell, + testers, + dbus, }: lib.makeScope newScope ( @@ -13,34 +13,36 @@ lib.makeScope newScope ( lib.mapAttrs ( - _n: p: - let - # add two checks: - # - `versionCheckhook`, checks wether it's a binary that is able to - # display its own version - # - A check which loads the plugin into the current version of nushell, - # to detect incompatibilities (plugins are compiled for very specific - # versions of nushell). If this fails, either update the plugin or mark - # as broken. - withChecks = p.overrideAttrs ( - final: _prev: { - doInstallCheck = true; - nativeInstallCheckInputs = [ versionCheckHook ]; + _n: package: - passthru.tests.loadCheck = + # add two checks: + # - A check which loads the plugin into the current version of nushell, + # to detect incompatibilities (plugins are compiled for very specific + # versions of nushell). If this fails, either update the plugin or mark + # as broken. + # - `versionCheck`, checks wether it's a binary that is able to + # display its own version. Suffix `-unstable-*` is ignored. + package.overrideAttrs ( + final: _prev: { + passthru.tests = { + loadCheck = let nu = lib.getExe nushell; - plugin = lib.getExe withChecks; + plugin = lib.getExe package; in runCommand "test-load-${final.pname}" { } '' touch $out ${nu} -n -c "plugin add --plugin-config $out ${plugin}" ${nu} -n -c "plugin use --plugin-config $out ${plugin}" ''; - } - ); - in - withChecks + versionCheck = testers.testVersion { + inherit package; + command = "${lib.getExe package} --help"; + version = lib.head (lib.splitString "-unstable" final.version); + }; + }; + } + ) ) ( with self;