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

clean references to unneeded files/packages #94

Merged
merged 1 commit into from
Oct 17, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 27 additions & 1 deletion ruby/package-fn.nix
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
, buildEnv
, bundler
, bundix
, removeReferencesTo
, useRailsExpress ? true
, zlibSupport ? true
, opensslSupport ? true
Expand Down Expand Up @@ -131,8 +132,33 @@ let
${buildRuby} setup.rb
popd
''}
rbConfig=$(find $out/lib/ruby -name rbconfig.rb)

# Remove references to the build environment from the closure
sed -i '/^ CONFIG\["\(BASERUBY\|SHELL\|GREP\|EGREP\|MKDIR_P\|MAKEDIRS\|INSTALL\)"\]/d' $rbConfig

# Remove unnecessary groff reference from runtime closure, since it's big
sed -i '/NROFF/d' $out/lib/ruby/*/*/rbconfig.rb
sed -i '/NROFF/d' $rbConfig

# Get rid of the CC runtime dependency
${removeReferencesTo}/bin/remove-references-to \
-t ${stdenv.cc} \
$out/lib/libruby*
${removeReferencesTo}/bin/remove-references-to \
-t ${stdenv.cc} \
$rbConfig
sed -i '/CC_VERSION_MESSAGE/d' $rbConfig

# Allow to override compiler. This is important for cross compiling as
# we need to set a compiler that is different from the build one.
sed -i 's/CONFIG\["CC"\] = "\(.*\)"/CONFIG["CC"] = if ENV["CC"].nil? || ENV["CC"].empty? then "\1" else ENV["CC"] end/' "$rbConfig"

# Remove unnecessary external intermediate files created by gems
extMakefiles=$(find $out/${self.passthru.gemPath} -name Makefile)
for makefile in $extMakefiles; do
make -C "$(dirname "$makefile")" distclean
done
find "$out/${self.passthru.gemPath}" \( -name gem_make.out -o -name mkmf.log \) -delete

# Bundler tries to create this directory
mkdir -p $out/nix-support
Expand Down