nixpkgs mirror (for testing) github.com/NixOS/nixpkgs
nix
fork

Configure Feed

Select the types of activity you want to include in your feed.

at release-19.03 88 lines 3.3 kB view raw
1# Make sure that the "with-gce" flag is set when building `google-cloud-sdk` 2# for GCE hosts. This flag prevents "google-compute-engine" from being a 3# default dependency which is undesirable because this package is 4# 5# 1) available only on GNU/Linux (requires `systemd` in particular) 6# 2) intended only for GCE guests (and is useless elsewhere) 7# 3) used by `google-cloud-sdk` only on GCE guests 8# 9 10{ stdenv, lib, fetchurl, makeWrapper, python, cffi, cryptography, pyopenssl, 11 crcmod, google-compute-engine, with-gce ? false }: 12 13let 14 pythonInputs = [ cffi cryptography pyopenssl crcmod ] 15 ++ lib.optional (with-gce) google-compute-engine; 16 pythonPath = lib.makeSearchPath python.sitePackages pythonInputs; 17 18 baseUrl = "https://dl.google.com/dl/cloudsdk/channels/rapid/downloads"; 19 sources = name: system: { 20 x86_64-darwin = { 21 url = "${baseUrl}/${name}-darwin-x86_64.tar.gz"; 22 sha256 = "03ymvfhk8azyvdm6j4pbqx2fsh178kw81yqwkycbhmm6mnyc8yv1"; 23 }; 24 25 x86_64-linux = { 26 url = "${baseUrl}/${name}-linux-x86_64.tar.gz"; 27 sha256 = "1pw4w3v81mp8alm6vxq10242xxwv8rfs59bjxrmy0pfkjgsr4x4v"; 28 }; 29 }.${system}; 30 31in stdenv.mkDerivation rec { 32 name = "google-cloud-sdk-${version}"; 33 version = "222.0.0"; 34 35 src = fetchurl (sources name stdenv.hostPlatform.system); 36 37 buildInputs = [ python makeWrapper ]; 38 39 phases = [ "installPhase" "fixupPhase" ]; 40 41 installPhase = '' 42 mkdir -p "$out" 43 tar -xzf "$src" -C "$out" google-cloud-sdk 44 45 mkdir $out/google-cloud-sdk/lib/surface/alpha 46 cp ${./alpha__init__.py} $out/google-cloud-sdk/lib/surface/alpha/__init__.py 47 48 mkdir $out/google-cloud-sdk/lib/surface/beta 49 cp ${./beta__init__.py} $out/google-cloud-sdk/lib/surface/beta/__init__.py 50 51 # create wrappers with correct env 52 for program in gcloud bq gsutil git-credential-gcloud.sh docker-credential-gcloud; do 53 programPath="$out/google-cloud-sdk/bin/$program" 54 binaryPath="$out/bin/$program" 55 wrapProgram "$programPath" \ 56 --set CLOUDSDK_PYTHON "${python}/bin/python" \ 57 --prefix PYTHONPATH : "${pythonPath}" 58 59 mkdir -p $out/bin 60 ln -s $programPath $binaryPath 61 done 62 63 # disable component updater and update check 64 substituteInPlace $out/google-cloud-sdk/lib/googlecloudsdk/core/config.json \ 65 --replace "\"disable_updater\": false" "\"disable_updater\": true" 66 echo " 67 [component_manager] 68 disable_update_check = true" >> $out/google-cloud-sdk/properties 69 70 # setup bash completion 71 mkdir -p "$out/etc/bash_completion.d/" 72 mv "$out/google-cloud-sdk/completion.bash.inc" "$out/etc/bash_completion.d/gcloud.inc" 73 74 # This directory contains compiled mac binaries. We used crcmod from 75 # nixpkgs instead. 76 rm -r $out/google-cloud-sdk/platform/gsutil/third_party/crcmod 77 ''; 78 79 meta = with stdenv.lib; { 80 description = "Tools for the google cloud platform"; 81 longDescription = "The Google Cloud SDK. This package has the programs: gcloud, gsutil, and bq"; 82 # This package contains vendored dependencies. All have free licenses. 83 license = licenses.free; 84 homepage = "https://cloud.google.com/sdk/"; 85 maintainers = with maintainers; [ stephenmw zimbatm ]; 86 platforms = [ "x86_64-linux" "x86_64-darwin" ]; 87 }; 88}