From c484d6376c1a7a77003a2e1d2350b24a86106112 Mon Sep 17 00:00:00 2001 From: edef Date: Thu, 30 Jan 2020 21:59:33 +0000 Subject: [PATCH 1/4] google-cloud-sdk: remove crcmod_osx as well Both third_party/crcmod_osx and third_party/crcmod are only used in the PYTHONPATH, and we already replace them with dependencies from nixpkgs. --- pkgs/tools/admin/google-cloud-sdk/default.nix | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pkgs/tools/admin/google-cloud-sdk/default.nix b/pkgs/tools/admin/google-cloud-sdk/default.nix index 5bcc25ea9899..959c854d6e75 100644 --- a/pkgs/tools/admin/google-cloud-sdk/default.nix +++ b/pkgs/tools/admin/google-cloud-sdk/default.nix @@ -76,7 +76,8 @@ in stdenv.mkDerivation rec { # This directory contains compiled mac binaries. We used crcmod from # nixpkgs instead. - rm -r $out/google-cloud-sdk/platform/gsutil/third_party/crcmod + rm -r $out/google-cloud-sdk/platform/gsutil/third_party/crcmod \ + $out/google-cloud-sdk/platform/gsutil/third_party/crcmod_osx ''; meta = with stdenv.lib; { From dbaafbbf73ef5aeb2fa7d5aea73bb32b9d78e4f3 Mon Sep 17 00:00:00 2001 From: edef Date: Fri, 31 Jan 2020 08:43:23 +0000 Subject: [PATCH 2/4] google-cloud-sdk: remove tests directories This reduces output size by 4.5 MiB. --- pkgs/tools/admin/google-cloud-sdk/default.nix | 3 +++ 1 file changed, 3 insertions(+) diff --git a/pkgs/tools/admin/google-cloud-sdk/default.nix b/pkgs/tools/admin/google-cloud-sdk/default.nix index 959c854d6e75..fccd3d12acf4 100644 --- a/pkgs/tools/admin/google-cloud-sdk/default.nix +++ b/pkgs/tools/admin/google-cloud-sdk/default.nix @@ -78,6 +78,9 @@ in stdenv.mkDerivation rec { # nixpkgs instead. rm -r $out/google-cloud-sdk/platform/gsutil/third_party/crcmod \ $out/google-cloud-sdk/platform/gsutil/third_party/crcmod_osx + + # remove tests and test data + find $out -name tests -type d -exec rm -rf '{}' + ''; meta = with stdenv.lib; { From b7641eaa5a689decfd3fc2c0e74d475eb20bbd64 Mon Sep 17 00:00:00 2001 From: edef Date: Fri, 31 Jan 2020 08:53:02 +0000 Subject: [PATCH 3/4] google-cloud-sdk: compact all the JSON This reduces output size by 20 MiB. --- pkgs/tools/admin/google-cloud-sdk/default.nix | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/pkgs/tools/admin/google-cloud-sdk/default.nix b/pkgs/tools/admin/google-cloud-sdk/default.nix index fccd3d12acf4..1a19d92984e1 100644 --- a/pkgs/tools/admin/google-cloud-sdk/default.nix +++ b/pkgs/tools/admin/google-cloud-sdk/default.nix @@ -7,7 +7,7 @@ # 3) used by `google-cloud-sdk` only on GCE guests # -{ stdenv, lib, fetchurl, makeWrapper, python, openssl, with-gce ? false }: +{ stdenv, lib, fetchurl, makeWrapper, python, openssl, jq, with-gce ? false }: let pythonEnv = python.withPackages (p: with p; [ @@ -38,6 +38,8 @@ in stdenv.mkDerivation rec { buildInputs = [ python makeWrapper ]; + nativeBuildInputs = [ jq ]; + patches = [ ./gcloud-path.patch ]; @@ -81,6 +83,12 @@ in stdenv.mkDerivation rec { # remove tests and test data find $out -name tests -type d -exec rm -rf '{}' + + + # compact all the JSON + find $out -name \*.json | while read path; do + jq -c . $path > $path.min + mv $path.min $path + done ''; meta = with stdenv.lib; { From 6ceebc441c43c0fd0ef5c61058c1c8ec3b93bc02 Mon Sep 17 00:00:00 2001 From: edef Date: Fri, 31 Jan 2020 08:57:26 +0000 Subject: [PATCH 4/4] google-cloud-sdk: strip the Cython gRPC library This reduces output size by 21 MiB. --- pkgs/tools/admin/google-cloud-sdk/default.nix | 3 +++ 1 file changed, 3 insertions(+) diff --git a/pkgs/tools/admin/google-cloud-sdk/default.nix b/pkgs/tools/admin/google-cloud-sdk/default.nix index 1a19d92984e1..07a81a5c5254 100644 --- a/pkgs/tools/admin/google-cloud-sdk/default.nix +++ b/pkgs/tools/admin/google-cloud-sdk/default.nix @@ -89,6 +89,9 @@ in stdenv.mkDerivation rec { jq -c . $path > $path.min mv $path.min $path done + + # strip the Cython gRPC library + strip $out/google-cloud-sdk/lib/third_party/grpc/_cython/cygrpc.so ''; meta = with stdenv.lib; {