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

chruby-fish: init at 0.8.2 #94345

Merged
merged 1 commit into from Sep 30, 2020
Merged

Conversation

cohei
Copy link
Contributor

@cohei cohei commented Jul 31, 2020

Motivation for this change

Add chruby-fish to nixpkgs.

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/) no binary files
  • 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.


meta = {
description = "Thin wrapper around chruby to make it work with the Fish shell";
homepage = "https://github.com/JeanMertz/chruby-fish";
Copy link
Member

Choose a reason for hiding this comment

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

Doesn't that means that you should wrap this with chruby?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You mean something like installing both chruby and fish automatically enables chruby-fish? I don't know how to achieve that...

With curent implementation, we can at least use chruby-fish without wrapping by

  1. nix-env --install fish chruby chruby-fish
  2. write some config like here

@cab404
Copy link
Member

cab404 commented Aug 1, 2020 via email

@cohei
Copy link
Contributor Author

cohei commented Aug 2, 2020

That is convenient but not necessary to install chruby-fish. So I attempted to keep dependencies minimum. For example, when someone is using both chruby and chruby-fish for bash and fish respectively, this may avoid trouble.

@cab404
Copy link
Member

cab404 commented Aug 2, 2020

That is convenient but not necessary to install chruby-fish. So I attempted to keep dependencies minimum. For example, when someone is using both chruby and chruby-fish for bash and fish respectively, this may avoid trouble.

ehm, I meant that you can add chruby to chruby-fish path. there will be no chruby in shell path.

@cohei
Copy link
Contributor Author

cohei commented Aug 8, 2020

Like 6039f5e ?

@cab404
Copy link
Member

cab404 commented Aug 8, 2020

Like 6039f5e ?

Nope. Like this: https://github.com/NixOS/nixpkgs/blob/master/pkgs/misc/emulators/mednaffe/default.nix#L21

Add makeWrapper to your buildInputs, and run wrapProgram $out/bin/chruby-fish --set PATH ${chruby}/bin in postInstall phase.

@cohei
Copy link
Contributor Author

cohei commented Aug 9, 2020

Thank you for the example! I'll try.

@cohei
Copy link
Contributor Author

cohei commented Sep 27, 2020

Add makeWrapper to your buildInputs, and run wrapProgram $out/bin/chruby-fish --set PATH ${chruby}/bin in postInstall phase.

chruby-fish's main resources are share/chruby/{chruby,auto}.fish. There is no executable, so it is impossible to do wrapPropram like this.

Is there anything else I can do?

@cab404
Copy link
Member

cab404 commented Sep 28, 2020

Sorry for everything you've already been through to merge the stuff

E.g can do sed -i 's\chruby${chruby}/bin/chruby'.

Initially I thought that's an utility which uses chruby as a dependency, but turns out that's more of a shell extension. So probably you don't even need to do that. I will pull PR in a sec and poke around a bit.

@cab404
Copy link
Member

cab404 commented Sep 28, 2020

Result of nixpkgs-review pr 94345 1

1 package built:
  • chruby-fish

@cab404
Copy link
Member

cab404 commented Sep 28, 2020

I read a bit more. Turns out, chruby is a script itself, and doesn't pull whole ruby with itself)

Although it's totally fine as a package, it still requires CHRUBY_ROOT environment variable. It would be nice to set it inside auto.fish and chruby.fish on patchPhase.

@cab404
Copy link
Member

cab404 commented Sep 28, 2020

diff --git a/pkgs/development/tools/misc/chruby-fish/default.nix b/pkgs/development/tools/misc/chruby-fish/default.nix
index b8acc475204..8e552b4a9a5 100644
--- a/pkgs/development/tools/misc/chruby-fish/default.nix
+++ b/pkgs/development/tools/misc/chruby-fish/default.nix
@@ -1,4 +1,4 @@
-{ stdenv, lib, fetchFromGitHub }:
+{ stdenv, lib, fetchFromGitHub, chruby }:

 stdenv.mkDerivation rec {
   pname = "chruby-fish";
@@ -12,6 +12,11 @@ stdenv.mkDerivation rec {
     sha256 = "15q0ywsn9pcypbpvlq0wb41x4igxm9bsvhg9a05dqw1n437qjhyb";
   };

+  postInstall = ''
+    sed -i -e '1cset CHRUBY_ROOT ${chruby}' $out/share/chruby/auto.fish
+    sed -i -e '1cset CHRUBY_ROOT ${chruby}' $out/share/chruby/chruby.fish
+  '';
+
   installFlags = [ "PREFIX=$(out)" ];

   meta = {

I can't edit your PR, so here's a patch)

@cab404
Copy link
Member

cab404 commented Sep 29, 2020

@cohei ?

@cohei
Copy link
Contributor Author

cohei commented Sep 29, 2020

Never mind! Thanks to the detour, I understand Nix more than before.

@cab404
Copy link
Member

cab404 commented Sep 29, 2020

Also, you can post this PR here, and there will be contributors with merge flag

@cohei
Copy link
Contributor Author

cohei commented Sep 30, 2020

They say

Select an open pull request that is not your own

Could you post it there instead, if you don't mind?

@cab404
Copy link
Member

cab404 commented Sep 30, 2020 via email

@nixos-discourse
Copy link

This pull request has been mentioned on NixOS Discourse. There might be relevant details there:

https://discourse.nixos.org/t/prs-already-reviewed/2617/241

@AndersonTorres AndersonTorres merged commit 7211bbb into NixOS:master Sep 30, 2020
@cohei cohei deleted the init-chruby-fish branch October 1, 2020 02:31
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

4 participants