From 1839cd60882242d3ac530e57077b2ffe20c12e13 Mon Sep 17 00:00:00 2001 From: Tom van Dijk <18gatenmaker6@gmail.com> Date: Sat, 28 Jun 2025 14:54:39 +0200 Subject: [PATCH] nushellPlugins.*: add load check to all (cherry picked from commit 4e681f2a04ae1c99dc71a7122d1790bb4c9f0cab) --- pkgs/shells/nushell/plugins/dbus.nix | 17 +------------ pkgs/shells/nushell/plugins/default.nix | 34 +++++++++++++++++++++---- pkgs/shells/nushell/plugins/skim.nix | 17 +------------ 3 files changed, 31 insertions(+), 37 deletions(-) diff --git a/pkgs/shells/nushell/plugins/dbus.nix b/pkgs/shells/nushell/plugins/dbus.nix index 8e7e33ca47f0..8b37fad33a8e 100644 --- a/pkgs/shells/nushell/plugins/dbus.nix +++ b/pkgs/shells/nushell/plugins/dbus.nix @@ -1,14 +1,11 @@ { stdenv, - runCommand, lib, rustPlatform, pkg-config, nix-update-script, fetchFromGitHub, dbus, - nushell, - nushell_plugin_dbus, }: rustPlatform.buildRustPackage (finalAttrs: { @@ -27,19 +24,7 @@ rustPlatform.buildRustPackage (finalAttrs: { nativeBuildInputs = [ pkg-config ] ++ lib.optionals stdenv.cc.isClang [ rustPlatform.bindgenHook ]; buildInputs = [ dbus ]; - passthru = { - updateScript = nix-update-script { }; - tests.check = - let - nu = lib.getExe nushell; - plugin = lib.getExe nushell_plugin_dbus; - in - runCommand "${finalAttrs.pname}-test" { } '' - touch $out - ${nu} -n -c "plugin add --plugin-config $out ${plugin}" - ${nu} -n -c "plugin use --plugin-config $out dbus" - ''; - }; + passthru.updateScript = nix-update-script { }; meta = { description = "Nushell plugin for communicating with D-Bus"; diff --git a/pkgs/shells/nushell/plugins/default.nix b/pkgs/shells/nushell/plugins/default.nix index f73b2d43b7d2..e629cb044802 100644 --- a/pkgs/shells/nushell/plugins/default.nix +++ b/pkgs/shells/nushell/plugins/default.nix @@ -4,6 +4,8 @@ newScope, dbus, versionCheckHook, + nushell, + runCommand, }: lib.makeScope newScope ( @@ -12,10 +14,33 @@ lib.makeScope newScope ( lib.mapAttrs ( _n: p: - p.overrideAttrs { - doInstallCheck = true; - nativeInstallCheckInputs = [ versionCheckHook ]; - } + 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 ]; + + passthru.tests.loadCheck = + let + nu = lib.getExe nushell; + plugin = lib.getExe withChecks; + 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 ) ( with self; @@ -29,7 +54,6 @@ lib.makeScope newScope ( highlight = callPackage ./highlight.nix { }; dbus = callPackage ./dbus.nix { inherit dbus; - nushell_plugin_dbus = self.dbus; }; skim = callPackage ./skim.nix { }; semver = callPackage ./semver.nix { }; diff --git a/pkgs/shells/nushell/plugins/skim.nix b/pkgs/shells/nushell/plugins/skim.nix index e66c78353274..4ec3b423028b 100644 --- a/pkgs/shells/nushell/plugins/skim.nix +++ b/pkgs/shells/nushell/plugins/skim.nix @@ -1,12 +1,9 @@ { stdenv, - runCommand, lib, rustPlatform, nix-update-script, fetchFromGitHub, - nushell, - skim, }: rustPlatform.buildRustPackage (finalAttrs: { @@ -24,19 +21,7 @@ rustPlatform.buildRustPackage (finalAttrs: { nativeBuildInputs = lib.optionals stdenv.cc.isClang [ rustPlatform.bindgenHook ]; - passthru = { - updateScript = nix-update-script { }; - tests.check = - let - nu = lib.getExe nushell; - plugin = lib.getExe skim; - in - runCommand "${finalAttrs.pname}-test" { } '' - touch $out - ${nu} -n -c "plugin add --plugin-config $out ${plugin}" - ${nu} -n -c "plugin use --plugin-config $out skim" - ''; - }; + passthru.updateScript = nix-update-script { }; meta = { description = "A nushell plugin that adds integrates the skim fuzzy finder";