Skip to content

nushell: enable automatic plugins registration#254250

Open
viraptor wants to merge 1 commit intoNixOS:masterfrom
viraptor:nushell-plus-plugins
Open

nushell: enable automatic plugins registration#254250
viraptor wants to merge 1 commit intoNixOS:masterfrom
viraptor:nushell-plus-plugins

Conversation

@viraptor
Copy link
Copy Markdown
Contributor

@viraptor viraptor commented Sep 9, 2023

Description of changes

Nushell requires explicit plugin registration which ends up saved in a specific file. This doesn't work great in the nixpkgs model, so as a workaround, create a wrapper package which prepends a nushell flag for the plugin configuration. The configuration is generated at build time.

Pros: included plugins work
Cons: can't register extra plugins at runtime (unless you remove plugins from the arguments or override --plugin-config)

Things done

  • Built on platform(s)
    • x86_64-linux
    • aarch64-linux
    • x86_64-darwin
    • aarch64-darwin
  • For non-Linux: Is sandbox = true set in nix.conf? (See Nix manual)
  • 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/)
  • 23.11 Release Notes (or backporting 23.05 Release notes)
    • (Package updates) Added a release notes entry if the change is major or breaking
    • (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.

Nushell requires explicit plugin registration which ends up saved in a
specific file. This doesn't work great in the nixpkgs model, so as a
workaround, create a wrapper package which prepends a nushell flag for
the plugin configuration. The configuration is generated at build time.

Pros: included plugins work
Cons: can't register extra plugins at runtime
@viraptor viraptor requested a review from happysalada September 9, 2023 14:27
@viraptor
Copy link
Copy Markdown
Contributor Author

viraptor commented Sep 9, 2023

@happysalada What do you think about this approach? An alternative is to add a nushell.withPlugins through passthru like here: viraptor@de0ff85

@happysalada
Copy link
Copy Markdown
Contributor

using home-manager, you can do something like

  extraConfig = ''
    register ${pkgs.nushellPlugins.query}/bin/nu_plugin_query
  '';

if that is unrelated to the problem you are describing, could you give an example of your problem ?
(the above is how I register the plugin I use).

@ofborg ofborg bot requested review from Br1ght0ne, JohnTitor and marsam September 9, 2023 15:15
@ofborg ofborg bot added 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. labels Sep 9, 2023
@viraptor
Copy link
Copy Markdown
Contributor Author

viraptor commented Sep 9, 2023

I'm mostly interested in keeping the versions consistent. You can only use homemanager config for your main/default shell, but when you're trying to develop something and juggle versions (or even run two different ones at the same time) that falls apart, because you need two different configs.

@happysalada
Copy link
Copy Markdown
Contributor

I'm still not sure I see your use case. Could we add some kind of comment as to why this was added (above the section), just for our future selves.

However it doesn't affect anyone if they don't use the plugins array.

let me get just another set of eyes on this one.
@marsam I think you are using nushell. If you can have a look when you have a moment.

@nyabinary
Copy link
Copy Markdown
Contributor

Is this ready to merge?

@viraptor
Copy link
Copy Markdown
Contributor Author

I'm still not sure I see your use case.

I started with previous version of nushell. Now after an update, I get:

   ╭─[/Users/viraptor/Library/Application Support/nushell/plugin.nu:1:1]
 1 │ register /nix/store/7bly0jm9hjd288qf2ghrnv4xlpdis9kn-nushell_plugin_formats-0.84.0/bin/nu_plugin_formats  {
   · ────┬───
   ·     ╰── unable to deserialize signature: missing field `val` at line 142 column 9
 2 │   "sig": {
   ╰────

Even though the new plugins are installed.
If I switch between versions, the extraConfig part will not help - it will still point to only one version of the plugins, not the version-specific config.

@wegank wegank added the 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md label Mar 19, 2024
@haras-unicorn
Copy link
Copy Markdown
Contributor

a good use case for me is that i can put this in a flake repo when i have scripts that depend on a plugin

@stale stale bot removed the 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md label Jun 20, 2024
@wegank wegank added the 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md label Jul 4, 2024
@wegank wegank added the 2.status: merge conflict This PR has merge conflicts with the target branch label Sep 27, 2024
@stale stale bot removed the 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md label Sep 27, 2024
@wegank wegank added the 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md label Jan 2, 2025
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 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md 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.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants