From 11970ee1d6719554406916b65ade61536a1b996a Mon Sep 17 00:00:00 2001 From: Alyssa Ross Date: Mon, 6 Jan 2020 22:49:28 +0000 Subject: [PATCH 1/5] buildRubyGem: strip by default I'm not sure why this was disabled, but it looks like a pretty harmless way to bring down closure size and remove references to compilers and stuff. --- pkgs/development/ruby-modules/gem/default.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkgs/development/ruby-modules/gem/default.nix b/pkgs/development/ruby-modules/gem/default.nix index af38160a5fa..03f8b10aacc 100644 --- a/pkgs/development/ruby-modules/gem/default.nix +++ b/pkgs/development/ruby-modules/gem/default.nix @@ -39,7 +39,7 @@ lib.makeOverridable ( , meta ? {} , patches ? [] , gemPath ? [] -, dontStrip ? true +, dontStrip ? false # Assume we don't have to build unless strictly necessary (e.g. the source is a # git checkout). # If you need to apply patches, make sure to set `dontBuild = false`; From ec8293fbfe9288720f2096c47b80c3509750869e Mon Sep 17 00:00:00 2001 From: Alyssa Ross Date: Mon, 6 Jan 2020 22:56:16 +0000 Subject: [PATCH 2/5] buildRubyGem: remove more bloat files --- pkgs/development/ruby-modules/gem/default.nix | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/pkgs/development/ruby-modules/gem/default.nix b/pkgs/development/ruby-modules/gem/default.nix index 03f8b10aacc..158d5891ec3 100644 --- a/pkgs/development/ruby-modules/gem/default.nix +++ b/pkgs/development/ruby-modules/gem/default.nix @@ -205,8 +205,11 @@ stdenv.mkDerivation ((builtins.removeAttrs attrs ["source"]) // { $gempkg $gemFlags -- $buildFlags # looks like useless files which break build repeatability and consume space - rm -fv $out/${ruby.gemPath}/doc/*/*/created.rid || true - rm -fv $out/${ruby.gemPath}/gems/*/ext/*/mkmf.log || true + pushd $out/${ruby.gemPath} + rm -fv doc/*/*/created.rid || true + rm -fv {gems/*/ext/*,extensions/*/*/*}/{mkmf.log,gem_make.out} || true + rm -fvr cache + popd # write out metadata and binstubs spec=$(echo $out/${ruby.gemPath}/specifications/*.gemspec) From 163618988f89a64ece3d7d17ef8cc50fa55a357d Mon Sep 17 00:00:00 2001 From: Alyssa Ross Date: Mon, 6 Jan 2020 22:59:57 +0000 Subject: [PATCH 3/5] ruby: remove references to CC by default This makes RbConfig["CC"] return an invalid path, but I hope nothing is depending on that anyway... --- pkgs/development/interpreters/ruby/default.nix | 2 +- pkgs/top-level/all-packages.nix | 2 -- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/pkgs/development/interpreters/ruby/default.nix b/pkgs/development/interpreters/ruby/default.nix index 58ccf5ae9b4..8b8e7ccc8bb 100644 --- a/pkgs/development/interpreters/ruby/default.nix +++ b/pkgs/development/interpreters/ruby/default.nix @@ -49,7 +49,7 @@ let # puts a reference to the C compiler in the binary. # This might be required by some gems at runtime, # but we allow to strip it out for smaller closure size. - , removeReferencesTo, removeReferenceToCC ? false + , removeReferencesTo, removeReferenceToCC ? true , autoreconfHook, bison, autoconf , buildEnv, bundler, bundix , libiconv, libobjc, libunwind, Foundation diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 6f7011fc874..a28d39feaec 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -9409,8 +9409,6 @@ in docSupport = false; yamlSupport = false; fiddleSupport = false; - # remove gcc from runtime closure - removeReferenceToCC = true; }; ruby = ruby_2_6; From fbe4716bd516587e5f294873e66c33a68225255a Mon Sep 17 00:00:00 2001 From: Alyssa Ross Date: Mon, 6 Jan 2020 23:02:58 +0000 Subject: [PATCH 4/5] defaultGemConfig: reduce mathematical closure size ext/ isn't needed once the extensions have been built, contains references to a bunch of huge dependencies, and contains megabytes of tests. --- pkgs/development/ruby-modules/gem-config/default.nix | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/pkgs/development/ruby-modules/gem-config/default.nix b/pkgs/development/ruby-modules/gem-config/default.nix index c1eb82c5fa8..4d7ddf549c3 100644 --- a/pkgs/development/ruby-modules/gem-config/default.nix +++ b/pkgs/development/ruby-modules/gem-config/default.nix @@ -315,6 +315,14 @@ in # The ruby build script takes care of this dontUseCmakeConfigure = true; + postInstall = '' + # Reduce output size by a lot, and remove some unnecessary references. + # The ext directory should only be required at build time, so + # can be deleted now. + rm -r $out/${ruby.gemPath}/gems/mathematical-${attrs.version}/ext \ + $out/${ruby.gemPath}/extensions/*/*/mathematical-${attrs.version}/gem_make.out + ''; + # For some reason 'mathematical.so' is missing cairo and glib in its RPATH, add them explicitly here postFixup = lib.optionalString stdenv.isLinux '' soPath="$out/${ruby.gemPath}/gems/mathematical-${attrs.version}/lib/mathematical/mathematical.so" From 1ac11cc1c1858af1cef725d68cacf7102366e588 Mon Sep 17 00:00:00 2001 From: Alyssa Ross Date: Mon, 6 Jan 2020 23:06:59 +0000 Subject: [PATCH 5/5] defaultGemConfig: remove asciidoctor-diagram JARs (Except on JRuby, where these are presumably important.) --- pkgs/development/ruby-modules/gem-config/default.nix | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/pkgs/development/ruby-modules/gem-config/default.nix b/pkgs/development/ruby-modules/gem-config/default.nix index 4d7ddf549c3..088bcedf6de 100644 --- a/pkgs/development/ruby-modules/gem-config/default.nix +++ b/pkgs/development/ruby-modules/gem-config/default.nix @@ -39,6 +39,15 @@ let in { + asciidoctor-diagram = { version, ruby, ... }: { + postInstall = '' + # Delete vendored JAR files unless using JRuby. + if ruby -e 'exit(RUBY_PLATFORM != "java")'; then + rm -v $out/${ruby.gemPath}/gems/$gemName-${version}/lib/*.jar + fi + ''; + }; + atk = attrs: { dependencies = attrs.dependencies ++ [ "gobject-introspection" ]; nativeBuildInputs = [ rake bundler pkgconfig ];