Skip to content

Conversation

@dtomvan
Copy link
Contributor

@dtomvan dtomvan commented Jun 28, 2025

This PR modernizes the 12 existing nushell plugins in the repo. I noticed a lot of copy-pasting has been done, with a lot of the same problems in it, so I did all of it in one go.

The new packages should be functionally equivalent, because all I did was reformat/rearrange things.

Summary:

  • Did some trivial stuff like use finalAttrs and remove with lib;
  • Removed useCargoFetchVendor
  • Some packages had weird testing/workspace practices. Replaced those with buildAndtestSubdir, checkFlags etc. instead of a manual checkPhase
  • Renamed nushell_plugin_* -> nu_plugin_* to reflect the main binary name (for versionCheckHook and consistency because there were already files with nu_plugin_* as pname)
  • Removed meta.platforms.all
  • Removed references to pname
  • Added versionCheckHook to all of them
  • Added a check that tries to load the plugin to all of them

I did all of it manually, which is error-prone but I didn't think it was worth automating.

Things done

  • Built on platform(s)
    • x86_64-linux
    • aarch64-linux
    • x86_64-darwin
    • aarch64-darwin
  • For non-Linux: Is sandboxing enabled in nix.conf? (See Nix manual)
    • sandbox = relaxed
    • sandbox = true
  • Tested, as applicable:
  • Tested compilation of all packages that depend on this change using nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD". Note: all changes have to be committed, also see nixpkgs-review usage
  • Tested basic functionality of all binary files (usually in ./result/bin/)
  • Nixpkgs 25.11 Release Notes (or backporting 24.11 and 25.05 Nixpkgs Release notes)
    • (Package updates) Added a release notes entry if the change is major or breaking
  • NixOS 25.11 Release Notes (or backporting 24.11 and 25.05 NixOS Release notes)
    • (Module updates) Added a release notes entry if the change is significant
    • (Module addition) Added a release notes entry if adding a new NixOS module
  • Fits CONTRIBUTING.md, pkgs/README.md, maintainers/README.md and other contributing documentation in corresponding paths.

Add a 👍 reaction to pull requests you find important.

@nixpkgs-ci nixpkgs-ci bot added 10.rebuild-linux: 11-100 This PR causes between 11 and 100 packages to rebuild on Linux. 10.rebuild-darwin: 1-10 This PR causes between 1 and 10 packages to rebuild on Darwin. labels Jun 28, 2025
@dtomvan
Copy link
Contributor Author

dtomvan commented Jun 28, 2025

I hope that, when I undraft this, I don't ping like ~20 people. I am afraid that's what has to happen if you refactor 12 packages as once. I am sorry in advance if this causes anybody any trouble.

@dtomvan
Copy link
Contributor Author

dtomvan commented Jun 28, 2025

nixpkgs-review result

Generated using nixpkgs-review.

Command: nixpkgs-review pr 420675
Commit: f3a980217d854abd10161f9c6525724e43d6da44


x86_64-linux

✅ 11 packages built:
  • nushellPlugins.dbus
  • nushellPlugins.formats
  • nushellPlugins.gstat
  • nushellPlugins.hcl
  • nushellPlugins.highlight
  • nushellPlugins.net
  • nushellPlugins.polars
  • nushellPlugins.query
  • nushellPlugins.semver
  • nushellPlugins.skim
  • nushellPlugins.units

@dtomvan dtomvan marked this pull request as ready for review June 28, 2025 02:31
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this needed? Upstream might add tests in the future which will then be ignored until someone stumbles upon on this line.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can test, but i seem to remember that yes it is needed.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just following https://github.com/NixOS/nixpkgs/blob/d85e3b87ffdc6e879499e54599a9d606b90955ce/doc/languages-frameworks/rust.section.md#disabling-package-tests-disabling-package-tests here:

If no tests exist -- the checkPhase should be explicitly disabled to skip unnecessary build steps to speed up the build

@aftix
Copy link
Contributor

aftix commented Jun 28, 2025

I never added the smoke test to every plugin since I couldn't decide where to put it, but I think making a local install check hook would be good.

Copy link
Member

@mgttlinger mgttlinger left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me

@nixpkgs-ci nixpkgs-ci bot added 12.approvals: 1 This PR was reviewed and approved by one person. 12.approved-by: package-maintainer This PR was reviewed and approved by a maintainer listed in any of the changed packages. labels Jun 28, 2025
Copy link
Contributor

@happysalada happysalada left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I dont think the changes here are very controversial, im thinking of merging this in 24h. Happy to delay, if anyone needs time, just post a message.

@happysalada
Copy link
Contributor

Oh minor thing actually, there are 59 commits, could you squash then into one commit per package ? I dont think we need that granularity for those changes.

@nixpkgs-ci nixpkgs-ci bot added 12.approvals: 2 This PR was reviewed and approved by two persons. and removed 12.approvals: 1 This PR was reviewed and approved by one person. labels Jun 28, 2025
@dtomvan
Copy link
Contributor Author

dtomvan commented Jun 28, 2025

I thought of doing that. But I was hoping this granularity would allow for an easier review process (before and after this merge)

Also, each remove lib.platforms.all commit has an explanation next to it, or is it all clear on its own why I did what I did?

@dtomvan dtomvan force-pushed the nushell-refactor branch from f3a9802 to e067c17 Compare June 28, 2025 12:43
@dtomvan
Copy link
Contributor Author

dtomvan commented Jun 28, 2025

I've kept the old version of the branch around, so I can revert it back if anyone objects to the suggestion by @happysalada

@dtomvan dtomvan changed the title nushellPlugins.*: refactor nushellPlugins.*: refactor, add checks Jun 28, 2025
@dtomvan

This comment was marked as resolved.

@dtomvan dtomvan force-pushed the nushell-refactor branch from 6809958 to 9d1069b Compare June 28, 2025 14:44
@dtomvan
Copy link
Contributor Author

dtomvan commented Jun 28, 2025

Turns out some of them are broken because they are outdated. Marking them as such. Only found that out because I added the smoke test to all of them. Turns out that's already paying off 😅

@nixpkgs-ci nixpkgs-ci bot removed the 10.rebuild-linux: 11-100 This PR causes between 11 and 100 packages to rebuild on Linux. label Jun 28, 2025
dtomvan added 8 commits June 28, 2025 17:02
Because otherwise:
- The names are inconsistent with the other nushell plugins
- `versionCheckHook` cannot find the binaries without setting a special
  variable
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.
@dtomvan dtomvan force-pushed the nushell-refactor branch from 9d1069b to 1ccdc4d Compare June 28, 2025 15:02
@dtomvan
Copy link
Contributor Author

dtomvan commented Jun 28, 2025

Also, should this get backported to stable (except for marking units and net as broken, since they support the nushell version in 25.05, 0.104.0) so that any plugin updates that might happen could be backported automatically to stable?

@dtomvan dtomvan force-pushed the nushell-refactor branch from 1ccdc4d to 3746764 Compare June 28, 2025 21:21
@nixpkgs-ci nixpkgs-ci bot added 12.approvals: 3+ This PR was reviewed and approved by three or more persons. and removed 12.approvals: 2 This PR was reviewed and approved by two persons. labels Jun 28, 2025
@happysalada happysalada merged commit 67c6a0c into NixOS:master Jun 29, 2025
24 checks passed
@dtomvan dtomvan deleted the nushell-refactor branch June 29, 2025 23:14
@timon-schelling
Copy link
Member

While rebasing #420202 and #420876 I noticed that the check version test fails for plugins with version {version}-unstable-{date} and other similar cases.

Sure, patching the version in Cargo.toml is an option.

substituteInPlace Cargo.toml \
      --replace-fail 'version = "${lib.head (lib.splitString "-" finalAttrs.version)}"' 'version = "${finalAttrs.version}"'

But I don't like patching only to pass that check.

It feels like this pr introduced a "policy" to nushellPlugins that disallows plugins where the version that is defined in the code and the way we name that version in nixpkgs are different.

This will lead to problems when trying to update plugins after a nushell-protocol update.
Some plugins bump nushell-protocol without incrementing the version.
See https://github.com/yybit/nu_plugin_compress/commits/main/
And I think we should not interfere with that decision.
This is a case where {version}-unstable-{date} should be used, in my opinion.

I suggest using a version test that allows this.

@dtomvan
Copy link
Contributor Author

dtomvan commented Jul 2, 2025

You can set dontVersionCheck? I figured it was a good idea to have these things blow up in your face if something might be wrong, but if it doesn't work with your usecase, AFAIK you can turn off the checks I introduced manually. If you set dontVersionCheck you might want to introduce a test with testers.testVersion though. Or is your suggestion to move all of them to testers.testVersion (and split the package version on -unstable- and only use the first part for the check)?

@timon-schelling
Copy link
Member

Maybe like this #421842 yes.

dontVersionCheck etc. would make updating more complex and add extra things to think about for every plugin.

@dtomvan
Copy link
Contributor Author

dtomvan commented Jul 2, 2025

I don't see why, because in theory these plugins can get updated seamlessly by r-ryantm and maintainers wouldn't need to do a lot about it except test and merge the bot PR. Currently I don't see any plugin that has unstableGitUpdater or nix-update-script with --version=branch, so as far as existing plugins are concerned this is a non-issue.

@timon-schelling
Copy link
Member

I don't see why, because in theory these plugins can get updated seamlessly by r-ryantm and maintainers wouldn't need to do a lot about it except test and merge the bot PR. Currently I don't see any plugin that has unstableGitUpdater or nix-update-script with --version=branch, so as far as existing plugins are concerned this is a non-issue.

I thought about plugins where we have something like the following on a regular basis.

nushell 0.105.0 -> 0.106.0 | compatible plugin version 0.1.2 -> 0.1.2-unstable-2022-05-09
nushell 0.106.0 -> 0.107.0 | compatible plugin version 0.1.2-unstable-2022-05-09 -> 0.1.2-unstable-2022-05-31
nushell 0.107.0 -> 0.108.0 | compatible plugin version 0.1.2-unstable-2022-05-31 -> 0.1.3
nushell 0.108.0 -> 0.109.0 | compatible plugin version 0.1.3 -> 0.1.4
nushell 0.109.0 -> 0.110.0 | compatible plugin version 0.1.5 -> 0.1.5
nushell 0.110.0 -> 0.111.0 | compatible plugin version 0.1.5 -> 0.1.5-unstable-2022-07-31
nushell 0.111.0 -> 0.112.0 | compatible plugin version 0.1.5-unstable-2022-07-31 -> 0.2.0
nushell 0.112.0 -> 0.113.0 | compatible plugin version 0.2.0 -> 0.2.0-unstable-2022-08-15

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

10.rebuild-darwin: 1-10 This PR causes between 1 and 10 packages to rebuild on Darwin. 10.rebuild-linux: 1-10 This PR causes between 1 and 10 packages to rebuild on Linux. 12.approvals: 3+ This PR was reviewed and approved by three or more persons. 12.approved-by: package-maintainer This PR was reviewed and approved by a maintainer listed in any of the changed packages.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants