Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fishPlugins: create scope and add some plugins #107834

Merged
merged 4 commits into from Jan 5, 2021

Conversation

pacien
Copy link
Contributor

@pacien pacien commented Dec 28, 2020

Motivation for this change

This bootstraps the fishPlugins scope and build tools for packaging plugins for the fish shell.

Two plugin packages are added:

  • fishtape: a TAP-based test runner for Fish, often used to test fish plugins,
  • pure: a pretty, minimal and fast Fish prompt, ported from zsh
Things done
  • Tested using sandboxing (nix.useSandbox on NixOS, or option sandbox in nix.conf on non-NixOS linux)
  • Built on platform(s)
    • NixOS
    • macOS
    • other Linux distributions
  • Tested via one or more NixOS test(s) if existing and applicable for the change (look inside nixos/tests)
  • Tested compilation of all pkgs that depend on this change using nix-shell -p nixpkgs-review --run "nixpkgs-review wip"
  • Tested execution of all binary files (usually in ./result/bin/)
  • Determined the impact on package closure size (by running nix path-info -S before and after)
  • Ensured that relevant documentation is up to date
  • Fits CONTRIBUTING.md.
Poking people

CC'ing the most recent committers on the fish module and package as they might be interested in this PR:

pkgs/top-level/aliases.nix Outdated Show resolved Hide resolved
@rnhmjoj
Copy link
Contributor

rnhmjoj commented Dec 29, 2020

It would be good to add documentation on how to add/use these plugins.
I can't figure how to use them: either with adding fishPlugins.something to environment.systemPackages or a nix-shell fish doesn't seems to find them, even with programs.fish.vendor.config.enable = true.

@pacien
Copy link
Contributor Author

pacien commented Dec 29, 2020

That's strange. This should be enough for the plugin to be detected by fish.

I'm using fish enabled through home-manager's programs.fish.enable and adding the packages to home.packages is enough for them to be detected.

@rnhmjoj
Copy link
Contributor

rnhmjoj commented Dec 29, 2020

I'm using fish enabled through home-manager's programs.fish.enable and adding the packages to home.packages is enough for them to be detected.

Uhm, I don't use home-manager, so I tried:

nix-shell -I nixpkgs=/path/to/nixpkgs --pure -p fish fishPlugins.fish-foreign-env -- run fish

but fenv is not available. Similarly, when I try a NixOS VM with:

nix-build -E '(import ./nixos { 
  configuration = { pkgs,... }: { 
    users.users.root.password = "root";
    programs.fish.enable = true;
    environment.systemPackages = with pkgs; [ fishPlugins.pure fishPlugins.fish-foreign-env ];
  }; }).vm'

@pacien pacien force-pushed the fishPlugins-init branch 2 times, most recently from 6bd678e to 3a68bc4 Compare December 29, 2020 19:04
@pacien
Copy link
Contributor Author

pacien commented Dec 29, 2020

It seems like the fish-foreign-env package was installing the scripts outside of the standard vendor_functions.d directory.
I modified the package (now fishPlugins.foreign-env) and the module accordingly and everything is correctly loaded now.

This is however a breaking change. Should I remove the package alias?

@rnhmjoj
Copy link
Contributor

rnhmjoj commented Dec 30, 2020

This is however a breaking change. Should I remove the package alias?

Uhm, it's likely it was never used outside of the NixOS module.
I'd say to add a note in the release notes but keep the alias.

@pacien
Copy link
Contributor Author

pacien commented Dec 30, 2020

Note added to the release notes and amended.

@rnhmjoj
Copy link
Contributor

rnhmjoj commented Dec 31, 2020

Thank you. I tested the NixOS module and built the manual: looks all good.

Copy link
Contributor

@rnhmjoj rnhmjoj left a comment

Choose a reason for hiding this comment

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

I don't have any other suggestions to make, the changes look good to me.
I'd wait for more fish users/maintainers to comment before merging, though.

Copy link
Member

@cole-h cole-h left a comment

Choose a reason for hiding this comment

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

One small suggestion below, otherwise LGTM. Thanks for this, @pacien! And thanks @rnhmjoj for all your feedback / review.

pkgs/top-level/all-packages.nix Outdated Show resolved Hide resolved
Copy link
Member

@cole-h cole-h left a comment

Choose a reason for hiding this comment

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

Diff LGTM. Thanks!

@pacien
Copy link
Contributor Author

pacien commented Jan 4, 2021

(Rebased to fix merrge conflict.)

@rnhmjoj rnhmjoj merged commit 99bfa4b into NixOS:master Jan 5, 2021
pacien added a commit to pacien/nixpkgs that referenced this pull request Jan 5, 2021
This adds a wrapper for fish which allows creating shells pre-initialised
with some completions, functions, and configuration scripts from given paths
or from fish plugin packages (`pkgs.fishPlugins.*`).

This is especially handy when one wants to try a plugin in an ephemeral shell.

GitHub: see NixOS#107834 (comment)
@abathur
Copy link
Member

abathur commented Jan 7, 2021

@pacien I'm not a fish user so I don't have much insight, but it sounds like this breaking change is sneaking up on some nix-darwin users (LnL7/nix-darwin#269). I would guess it's doing the same for HM users?

@rnhmjoj
Copy link
Contributor

rnhmjoj commented Jan 7, 2021

Yeah, nix-darwin and probably home-manager need to change the foreign-env path as in this diff:
pacien@d94921d#diff-e643907e997ff11fbccddd7dacf176032a320f26f8313eb4b18f435597dca2b0

edit: Yeah, they're already onto it: nix-community/home-manager#1703

@pacien
Copy link
Contributor Author

pacien commented Jan 8, 2021

Should we remove the alias fish-foreign-env -> fishPlugins.foreign-env so that the evaluation fails instead of having runtime breakage? Those packages aren't compatible due to the directory layout changes, so I'm not sure that it made sense to have that alias in the first place.

@cole-h
Copy link
Member

cole-h commented Jan 9, 2021

Yeah, I agree with that.

pacien added a commit to pacien/nixpkgs that referenced this pull request Jan 10, 2021
The fish-foreign-env and the fishPlugins.foreign-env packages aren't
compatible due to changes in directory layout.

It's better to remove the alias so that the evaluation explicitly fails
instead of allowing silent runtime breakage.

GitHub: see NixOS#107834 (comment)
GitHub: see LnL7/nix-darwin#269
GitHub: see nix-community/home-manager#1701
GitHub: see nix-community/home-manager#1702
@pacien pacien mentioned this pull request Jan 10, 2021
10 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants