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
Add rubyMinimal #75566
Add rubyMinimal #75566
Conversation
${removeReferencesTo}/bin/remove-references-to \ | ||
-t ${stdenv.cc} \ | ||
$out/lib/libruby.so.* | ||
''} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could this be done every time? sounds interesting to remove it if we can
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this break jit compiling?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
$ nix-shell -p ruby --run 'ruby -e "puts RbConfig::CONFIG['configure_args']"'
'--prefix=/nix/store/b3lhi1wlia02vyd94jk56bm3kvgf1yc0-ruby-2.6.5' '--bindir=/nix/store/b3lhi1wlia02vyd94jk56bm3kvgf1yc0-ruby-2.6.5/bin' '--sbindir=/nix/store/b3lhi1wlia02vyd94jk56bm3kvgf1yc0-ruby-2.6.5/sbin' '--includedir=/nix/store/b3lhi1wlia02vyd94jk56bm3kvgf1yc0-ruby-2.6.5/include' '--oldincludedir=/nix/store/b3lhi1wlia02vyd94jk56bm3kvgf1yc0-ruby-2.6.5/include' '--mandir=/nix/store/b3lhi1wlia02vyd94jk56bm3kvgf1yc0-ruby-2.6.5/share/man' '--infodir=/nix/store/b3lhi1wlia02vyd94jk56bm3kvgf1yc0-ruby-2.6.5/share/info' '--docdir=/nix/store/b3lhi1wlia02vyd94jk56bm3kvgf1yc0-ruby-2.6.5/share/doc/' '--libdir=/nix/store/b3lhi1wlia02vyd94jk56bm3kvgf1yc0-ruby-2.6.5/lib' '--libexecdir=/nix/store/b3lhi1wlia02vyd94jk56bm3kvgf1yc0-ruby-2.6.5/libexec' '--localedir=/nix/store/b3lhi1wlia02vyd94jk56bm3kvgf1yc0-ruby-2.6.5/share/locale' '--enable-shared' '--enable-pthread' 'CC=gcc' 'CXX=g++'
Dunno which gems need it at runtime, I wouldn’t risk it by default.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any gem that does need this at runtime probably wouldn’t work on a pure Nix system anyway, so I’d be happy disabling this across the board.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Won’t do it in this PR, but feel free to open another one for the proper ruby
package. :)
Though of course it would break systems which might be using that.
@@ -9312,6 +9312,20 @@ in | |||
ruby_2_5 | |||
ruby_2_6; | |||
|
|||
rubyMinimal = ruby.override { | |||
useRailsExpress = false; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why would you strip this one? It's just a small patchset.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can enable it by default, I have no idea about what any of these options do to be honest 😅.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
railsExpress is a patchset on top of ruby that was developed by some rails developer to make things run faster. It doesn't affect the closure size but creates a non-vanilla version of ruby. Might as well use the vanilla ruby for the minimal version.
useRailsExpress = false; | ||
rubygemsSupport = false; | ||
zlibSupport = false; | ||
opensslSupport = false; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What are you using ruby for that does not support HTTPS/HTTP with deflate support?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It’s about the minimal runtime closure, not so much about supporting openssl.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But if http clients are a thing most small ruby scripts would like to use, we should enable it.
For example the home-manager service activation script doesn’t need SSL.
Btw this is only a staging PR because of the whitespace change m( |
@Mic92 Feel free to propose a set of options we should enable by default even for |
Here’s a short breakdown:
|
I use gems a lot in small scripts -- how big a difference does
Rubygems make? I imagine it's pretty tiny.
Also, how big a difference does OpenSSL make? I'm torn here, but
leaning towards keeping it because I think ever user of rubyMinimal will
have at least one other package that uses OpenSSL anyway.
|
That doesn’t necessarily hold on restricted systems or on CI systems which get redeployed on every run.
Then let’s enable gems |
05912b0
to
2866ada
Compare
Okay, from my side this is ready to merge. Should we push it to staging or is master fine? |
> I think ever user of rubyMinimal will have at least one other package
> that uses OpenSSL anyway.
That doesn’t necessarily hold on restricted systems or on CI systems
which get redeployed on every run.
Do the machines you want to use this on otherwise have OpenSSL
installed?
|
I don’t know, I also don’t know whether they have necessarily the same version of openssl that would come with rubyMinimal (projects are usually pinned to a wholly different pin of nixpkgs than the system closure). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since it's just an addition, I am fine with not resolving the smaller details. There are some open questions which can be resolved later in time.
Reduces the runtime closure by ~200MB if enabled.
2866ada
to
b53c260
Compare
Okay, I rebased and got rid of the space changes in the ruby script, so no mass rebuild required. Merging. |
Well, once I figure out the build failure … |
b53c260
to
e3aa2be
Compare
Similar to `gitMinimal` or `pythonMinimal`, this is useful for scripts which don’t use anything but the standard library and want a small footprint.
e3aa2be
to
c3babde
Compare
For small scripts that don’t need the full interpreter with all dependencies (especially runtime dependencies)
Things done
sandbox
innix.conf
on non-NixOS linux)nix-shell -p nix-review --run "nix-review wip"
./result/bin/
)nix path-info -S
before and after)Notify maintainers
cc @