Skip to content

nushellPlugins.*: automatically patch dependencies to support current nushell version#441173

Draft
timon-schelling wants to merge 2 commits intoNixOS:masterfrom
timon-schelling:nushell-plugins-autopatch-nushell-version
Draft

nushellPlugins.*: automatically patch dependencies to support current nushell version#441173
timon-schelling wants to merge 2 commits intoNixOS:masterfrom
timon-schelling:nushell-plugins-autopatch-nushell-version

Conversation

@timon-schelling
Copy link
Copy Markdown
Member

Things done

  • Built on platform:
    • x86_64-linux
    • aarch64-linux
    • x86_64-darwin
    • aarch64-darwin
  • Tested, as applicable:
  • Ran nixpkgs-review on this PR. See nixpkgs-review usage.
  • Tested basic functionality of all binary files, usually in ./result/bin/.
  • Nixpkgs Release Notes
    • Package update: when the change is major or breaking.
  • NixOS Release Notes
    • Module addition: when adding a new NixOS module.
    • Module update: when the change is significant.
  • Fits CONTRIBUTING.md, pkgs/README.md, maintainers/README.md and other READMEs.

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 Sep 8, 2025
@timon-schelling timon-schelling force-pushed the nushell-plugins-autopatch-nushell-version branch from e3c9044 to 0dce073 Compare September 8, 2025 11:23
@dtomvan dtomvan self-requested a review September 8, 2025 11:40
Copy link
Copy Markdown
Contributor

@dtomvan dtomvan left a comment

Choose a reason for hiding this comment

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

I know it's still a draft, but here's the things I currently find hacky: hope that helps.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Isn't this just prev.name?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

prev.name is not available for some reason.

error: attribute 'name' missing
       at /nix/store/i2srmbli3vkrh11g5islzy5zzm1hxybs-source/pkgs/shells/nushell/plugins/default.nix:27:36:
           26|               (rustPlatform.fetchCargoVendor ({
           27|                 inherit (prev) src name;
             |                                    ^
           28|                 hash = prev.cargoHash;

@timon-schelling
Copy link
Copy Markdown
Member Author

I know it's still a draft, but here's the things I currently find hacky: hope that helps.

Thanks for the comments, just wanted to test if this is possible. Didn't know about cargo-edit etc. could have saved a lot of time. I will address your comments in the next days.

@timon-schelling
Copy link
Copy Markdown
Member Author

nixpkgs-review result

Generated using nixpkgs-review-gha

Command: nixpkgs-review pr 441173
Commit: 0dce073dc2fe0da9ead986e0398efac344a5adae (subsequent changes)
Merge: 24731286f01035a3e776f5c3d67eb46d958101ae

Logs: https://github.com/timon-schelling/run-nixpkgs-review/actions/runs/17549164161


x86_64-linux

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

aarch64-linux

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

@timon-schelling timon-schelling force-pushed the nushell-plugins-autopatch-nushell-version branch from 0dce073 to 6380f3d Compare September 9, 2025 00:46
@timon-schelling
Copy link
Copy Markdown
Member Author

@dtomvan could you take another look?

@timon-schelling timon-schelling force-pushed the nushell-plugins-autopatch-nushell-version branch from 6380f3d to e54a24c Compare September 9, 2025 01:11
@timon-schelling
Copy link
Copy Markdown
Member Author

nixpkgs-review result

Generated using nixpkgs-review-gha

Command: nixpkgs-review pr 441173
Commit: e54a24c7377f4a96c78d3885c9b034f185dc5fb7 (subsequent changes)
Merge: 379c2e9d41aaad0709fed107846c6715f4054645

Logs: https://github.com/timon-schelling/run-nixpkgs-review/actions/runs/17568684242


x86_64-linux

❌ 1 package failed to build:
  • nushellPlugins.net
✅ 11 packages built:
  • nushellPlugins.dbus
  • nushellPlugins.desktop_notifications
  • nushellPlugins.formats
  • nushellPlugins.gstat
  • nushellPlugins.hcl
  • nushellPlugins.highlight
  • nushellPlugins.polars
  • nushellPlugins.query
  • nushellPlugins.semver
  • nushellPlugins.skim
  • nushellPlugins.units

aarch64-linux

❌ 1 package failed to build:
  • nushellPlugins.net
✅ 11 packages built:
  • nushellPlugins.dbus
  • nushellPlugins.desktop_notifications
  • nushellPlugins.formats
  • nushellPlugins.gstat
  • nushellPlugins.hcl
  • nushellPlugins.highlight
  • nushellPlugins.polars
  • nushellPlugins.query
  • nushellPlugins.semver
  • nushellPlugins.skim
  • nushellPlugins.units

@timon-schelling
Copy link
Copy Markdown
Member Author

cargoHash doesn't seem to be stable now. I get 3 different hashes at 3 different times. I suspect that cargo edit isn't deterministic and can lock different downstream crate versions dependent on the time they are fetched.

I'm not sure if the same problem exits with my earlier approach.

Copy link
Copy Markdown
Contributor

@dtomvan dtomvan left a comment

Choose a reason for hiding this comment

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

That's unfortunate. This looks much better to me though.

Comment on lines +67 to +82
postBuild = ''
if ! [ -z "''${NUSHELL_VERSION_UPGRADED}" ]; then
cp Cargo.toml $out/Cargo.toml
fi
'';
})).overrideAttrs
(old: {
buildCommand = old.buildCommand + ''
cp $vendorStaging/Cargo.toml $out/Cargo.toml || true
'';
});

postPatch = ''
cp ${final.cargoDeps}/Cargo.lock ./Cargo.lock
cp ${final.cargoDeps}/Cargo.toml ./Cargo.toml || true
'';
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Why would we have to conditionally copy cargo.toml? In this case it may silently continue after failing to copy Cargo.toml (however that may happen)

if is_compatible nu-plugin "${nushell.version}"; then
echo "nu-plugin is compatible, no patching needed"
else
cargo upgrade -p nu-plugin@${nushell.version} -p nu-protocol@${nushell.version}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

You might be able to pin the exact version with an =-sign before the version. https://docs.rs/semver/latest/semver/enum.Op.html

Also, if you want to debug the reproducibility of this, you can probably use -v and CARGO_LOG=upgrade=trace to figure out what cargo commands it's calling under the hood and what versions it's selecting. cargo itself isn't that deterministic in and of itself though...

@VuiMuich
Copy link
Copy Markdown
Contributor

VuiMuich commented Jan 31, 2026

Is this patch still relevant after nushell plugins becoming merge-bot eligible through #482961?

@nixpkgs-ci nixpkgs-ci bot added the 2.status: merge conflict This PR has merge conflicts with the target branch label Jan 31, 2026
@dtomvan
Copy link
Copy Markdown
Contributor

dtomvan commented Jan 31, 2026

I'd say yes, since some plugins' upstreams are very, very slow with updating. I have two PRs open for 7 months now:

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

Labels

2.status: merge conflict This PR has merge conflicts with the target branch 10.rebuild-darwin: 1-10 This PR causes between 1 and 10 packages to rebuild on Darwin. 10.rebuild-linux: 11-100 This PR causes between 11 and 100 packages to rebuild on Linux.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants