lol
fork

Configure Feed

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

at 24.11-pre 138 lines 5.0 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, openssl, jq, callPackage, with-gce ? false }: 11 12let 13 pythonEnv = python.withPackages (p: with p; [ 14 cffi 15 cryptography 16 pyopenssl 17 crcmod 18 numpy 19 ] ++ lib.optional (with-gce) google-compute-engine); 20 21 data = import ./data.nix { }; 22 sources = system: 23 data.googleCloudSdkPkgs.${system} or (throw "Unsupported system: ${system}"); 24 25 components = callPackage ./components.nix { 26 snapshotPath = ./components.json; 27 }; 28 29 withExtraComponents = callPackage ./withExtraComponents.nix { inherit components; }; 30 31in stdenv.mkDerivation rec { 32 pname = "google-cloud-sdk"; 33 inherit (data) version; 34 35 src = fetchurl (sources stdenv.hostPlatform.system); 36 37 buildInputs = [ python ]; 38 39 nativeBuildInputs = [ jq makeWrapper ]; 40 41 patches = [ 42 # For kubectl configs, don't store the absolute path of the `gcloud` binary as it can be garbage-collected 43 ./gcloud-path.patch 44 # Disable checking for updates for the package 45 ./gsutil-disable-updates.patch 46 ]; 47 48 installPhase = '' 49 runHook preInstall 50 51 mkdir -p $out/google-cloud-sdk 52 if [ -d .install/platform/bundledpythonunix ]; then 53 rm -r .install/platform/bundledpythonunix 54 fi 55 cp -R * .install $out/google-cloud-sdk/ 56 57 mkdir -p $out/google-cloud-sdk/lib/surface/{alpha,beta} 58 cp ${./alpha__init__.py} $out/google-cloud-sdk/lib/surface/alpha/__init__.py 59 cp ${./beta__init__.py} $out/google-cloud-sdk/lib/surface/beta/__init__.py 60 61 # create wrappers with correct env 62 for program in gcloud bq gsutil git-credential-gcloud.sh docker-credential-gcloud; do 63 programPath="$out/google-cloud-sdk/bin/$program" 64 binaryPath="$out/bin/$program" 65 wrapProgram "$programPath" \ 66 --set CLOUDSDK_PYTHON "${pythonEnv}/bin/python" \ 67 --prefix PYTHONPATH : "${pythonEnv}/${python.sitePackages}" \ 68 --prefix PATH : "${openssl.bin}/bin" 69 70 mkdir -p $out/bin 71 ln -s $programPath $binaryPath 72 done 73 74 # disable component updater and update check 75 substituteInPlace $out/google-cloud-sdk/lib/googlecloudsdk/core/config.json \ 76 --replace-fail "\"disable_updater\": false" "\"disable_updater\": true" 77 echo " 78 [component_manager] 79 disable_update_check = true" >> $out/google-cloud-sdk/properties 80 81 # setup bash completion 82 mkdir -p $out/share/bash-completion/completions 83 mv $out/google-cloud-sdk/completion.bash.inc $out/share/bash-completion/completions/gcloud 84 ln -s $out/share/bash-completion/completions/gcloud $out/share/bash-completion/completions/gsutil 85 86 # setup zsh completion 87 mkdir -p $out/share/zsh/site-functions 88 mv $out/google-cloud-sdk/completion.zsh.inc $out/share/zsh/site-functions/_gcloud 89 ln -s $out/share/zsh/site-functions/_gcloud $out/share/zsh/site-functions/_gsutil 90 # zsh doesn't load completions from $FPATH without #compdef as the first line 91 sed -i '1 i #compdef gcloud' $out/share/zsh/site-functions/_gcloud 92 93 # This directory contains compiled mac binaries. We used crcmod from 94 # nixpkgs instead. 95 rm -r $out/google-cloud-sdk/platform/gsutil/third_party/crcmod \ 96 $out/google-cloud-sdk/platform/gsutil/third_party/crcmod_osx 97 98 # remove tests and test data 99 find $out -name tests -type d -exec rm -rf '{}' + 100 rm $out/google-cloud-sdk/platform/gsutil/gslib/commands/test.py 101 102 # compact all the JSON 103 find $out -name \*.json | while read path; do 104 jq -c . $path > $path.min 105 mv $path.min $path 106 done 107 108 runHook postInstall 109 ''; 110 111 doInstallCheck = true; 112 installCheckPhase = '' 113 # Avoid trying to write logs to homeless-shelter 114 export HOME=$(mktemp -d) 115 $out/bin/gcloud version --format json | jq '."Google Cloud SDK"' | grep "${version}" 116 ''; 117 118 passthru = { 119 inherit components withExtraComponents; 120 updateScript = ./update.sh; 121 }; 122 123 meta = with lib; { 124 description = "Tools for the google cloud platform"; 125 longDescription = "The Google Cloud SDK for GCE hosts. Used by `google-cloud-sdk` only on GCE guests."; 126 sourceProvenance = with sourceTypes; [ 127 fromSource 128 binaryNativeCode # anthoscli and possibly more 129 ]; 130 # This package contains vendored dependencies. All have free licenses. 131 license = licenses.free; 132 homepage = "https://cloud.google.com/sdk/"; 133 changelog = "https://cloud.google.com/sdk/docs/release-notes"; 134 maintainers = with maintainers; [ iammrinal0 marcusramberg pradyuman stephenmw zimbatm ]; 135 platforms = builtins.attrNames data.googleCloudSdkPkgs; 136 mainProgram = "gcloud"; 137 }; 138}