push sheeet
Some checks failed
Periodic Merges (6h) / master → staging-nixos (push) Failing after 12m50s
Periodic Merges (6h) / master → staging-next (push) Failing after 12m54s
Periodic Merges (24h) / merge-base(master,staging) → haskell-updates (push) Failing after 11m54s
Periodic Merges (6h) / staging-next → staging (push) Failing after 12m13s
Periodic Merges (24h) / staging-next-25.05 → staging-25.05 (push) Failing after 13m24s
Periodic Merges (24h) / release-25.05 → staging-next-25.05 (push) Failing after 14m28s

This commit is contained in:
Dark Steveneq
2025-10-09 14:15:47 +02:00
commit 646b892680
49168 changed files with 5897842 additions and 0 deletions

View File

@@ -0,0 +1,23 @@
# Copyright 2013 Google Inc. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""Auth for the Google Cloud SDK.
"""
from googlecloudsdk.calliope import base
@base.ReleaseTracks(base.ReleaseTrack.ALPHA)
class Alpha(base.Group):
"""Alpha versions of gcloud commands."""

View File

@@ -0,0 +1,23 @@
# Copyright 2013 Google Inc. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""Auth for the Google Cloud SDK.
"""
from googlecloudsdk.calliope import base
@base.ReleaseTracks(base.ReleaseTrack.BETA)
class Beta(base.Group):
"""Beta versions of gcloud commands."""

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,191 @@
{
lib,
stdenv,
fetchurl,
system,
snapshotPath,
autoPatchelfHook,
python3,
libxcrypt-legacy,
}:
let
# Mapping from GCS component architecture names to Nix architecture names
arches = {
x86 = "i686";
x86_64 = "x86_64";
arm = "aarch64";
};
# Mapping from GCS component operating systems to Nix operating systems
oses = {
LINUX = "linux";
MACOSX = "darwin";
WINDOWS = "windows";
CYGWIN = "cygwin";
};
# Convert an archicecture + OS to a Nix platform
toNixPlatform =
arch: os:
let
arch' = arches.${arch} or (throw "unsupported architecture '${arch}'");
os' = oses.${os} or (throw "unsupported OS '${os}'");
in
"${arch'}-${os'}";
# All architectures that are supported by GCS
allArches = builtins.attrNames arches;
# A description of all available google-cloud-sdk components.
# It's a JSON file with a list of components, along with some metadata
snapshot = lib.importJSON snapshotPath;
# Generate a snapshot file for a single component. It has the same format as
# `snapshot`, but only contains a single component. These files are
# installed with google-cloud-sdk to let it know which components are
# available.
snapshotFromComponent =
{
component,
revision,
schema_version,
version,
}:
builtins.toJSON {
components = [ component ];
inherit revision schema_version version;
};
# Generate a set of components from a JSON file describing these components
componentsFromSnapshot =
{
components,
revision,
schema_version,
version,
...
}:
lib.fix (
self:
builtins.listToAttrs (
map (component: {
name = component.id;
value = componentFromSnapshot self {
inherit
component
revision
schema_version
version
;
};
}) components
)
);
# Generate a single component from its snapshot, along with a set of
# available dependencies to choose from.
componentFromSnapshot =
# Component derivations that can be used as dependencies
components:
# This component's snapshot
{
component,
revision,
schema_version,
version,
}@attrs:
let
baseUrl = dirOf schema_version.url;
# Architectures supported by this component. Defaults to all available
# architectures.
architectures = builtins.filter (arch: builtins.elem arch (builtins.attrNames arches)) (
lib.attrByPath [ "platform" "architectures" ] allArches component
);
# Operating systems supported by this component
operating_systems = builtins.filter (
os: builtins.elem os (builtins.attrNames oses)
) component.platform.operating_systems;
in
mkComponent {
pname = component.id;
version = component.version.version_string;
src = lib.optionalString (lib.hasAttrByPath [
"data"
"source"
] component) "${baseUrl}/${component.data.source}";
sha256 = lib.attrByPath [ "data" "checksum" ] "" component;
dependencies = map (dep: builtins.getAttr dep components) component.dependencies;
platforms =
if component.platform == { } then
lib.platforms.all
else
builtins.concatMap (arch: map (os: toNixPlatform arch os) operating_systems) architectures;
snapshot = snapshotFromComponent attrs;
};
# Filter out dependencies not supported by current system
filterForSystem = builtins.filter (drv: builtins.elem system drv.meta.platforms);
# Make a google-cloud-sdk component
mkComponent =
{
pname,
version,
# Source tarball, if any
src ? "",
# Checksum for the source tarball, if there is a source
sha256 ? "",
# Other components this one depends on
dependencies ? [ ],
# Short text describing the component
description ? "",
# Platforms supported
platforms ? lib.platforms.all,
# The snapshot corresponding to this component
snapshot,
}:
stdenv.mkDerivation {
inherit pname version snapshot;
src = lib.optionalString (src != "") (fetchurl {
url = src;
inherit sha256;
});
dontUnpack = true;
installPhase = ''
mkdir -p $out/google-cloud-sdk/.install
# If there is a source, unpack it
if [ ! -z "$src" ]; then
tar -xf $src -C $out/google-cloud-sdk/
# If the source has binaries, link them to `$out/bin`
if [ -d "$out/google-cloud-sdk/bin" ]; then
mkdir $out/bin
find $out/google-cloud-sdk/bin/ -type f -exec ln -s {} $out/bin/ \;
fi
fi
# Write the snapshot file to the `.install` folder
cp $snapshotPath $out/google-cloud-sdk/.install/${pname}.snapshot.json
'';
nativeBuildInputs = [
python3
stdenv.cc.cc
]
++ lib.optionals stdenv.hostPlatform.isLinux [
autoPatchelfHook
];
buildInputs = [
libxcrypt-legacy
];
passthru = {
dependencies = filterForSystem dependencies;
};
passAsFile = [ "snapshot" ];
meta = {
inherit description platforms;
};
};
in
componentsFromSnapshot snapshot

View File

@@ -0,0 +1,27 @@
# DO NOT EDIT! This file is generated automatically by update.sh
{ }:
{
version = "537.0.0";
googleCloudSdkPkgs = {
x86_64-linux = {
url = "https://dl.google.com/dl/cloudsdk/channels/rapid/downloads/google-cloud-sdk-537.0.0-linux-x86_64.tar.gz";
sha256 = "08221f1alz5ss5fvqdj30k7c98l15gkzidhgj2fhlw5xwi7dp3cn";
};
x86_64-darwin = {
url = "https://dl.google.com/dl/cloudsdk/channels/rapid/downloads/google-cloud-sdk-537.0.0-darwin-x86_64.tar.gz";
sha256 = "0my8vbdyf4iy7qry8vzhb0wmzlbqz7h891rw3vzhjcrksaa4xahn";
};
aarch64-linux = {
url = "https://dl.google.com/dl/cloudsdk/channels/rapid/downloads/google-cloud-sdk-537.0.0-linux-arm.tar.gz";
sha256 = "16zj9xx3mgldz0a9l45pw2l0gwkb9vfdv7s93v81pmz2jx5hd0d6";
};
aarch64-darwin = {
url = "https://dl.google.com/dl/cloudsdk/channels/rapid/downloads/google-cloud-sdk-537.0.0-darwin-arm.tar.gz";
sha256 = "0h5ldp6gw7mk7m9jljl1lvvz7sxkrssyy0w3zag5c1lbb7fb9r60";
};
i686-linux = {
url = "https://dl.google.com/dl/cloudsdk/channels/rapid/downloads/google-cloud-sdk-537.0.0-linux-x86.tar.gz";
sha256 = "0sgnnspjhsk4ydkq7x7gcnw19dbf66cq1rrwr0r1r97953k8rhvj";
};
};
}

View File

@@ -0,0 +1,44 @@
From b69fee70154a861637c82e98e18be01bbb96423b Mon Sep 17 00:00:00 2001
From: Florian Klink <flokli@flokli.de>
Date: Wed, 12 Jun 2019 17:03:09 +0200
Subject: [PATCH] kubeconfig: don't store absolute path to gcloud binary
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
The `gcloud beta container clusters get-credentials $cluster \
--region $region --project $project`
command can be used to write kubectl config files.
In that file, normally the absolute path to the `gcloud` binary is
stored.
This is a bad idea in NixOS. We might eventually garbage-collect that
specific gcloud binary - and in general, would expect a nix-shell
provided gcloud to be used.
In its current state, token renewal would just start to break with the
following error message:
Unable to connect to the server: error executing access token command "/nix/store/…/gcloud config config-helper --format=json": err=fork/exec /nix/store/…/gcloud: no such file or directory output= stderr=
Avoid this by storing just `gcloud` inside `cmd-path`, which causes
kubectl to lookup the gcloud command from $PATH, which is more likely to
keep working.
---
lib/googlecloudsdk/api_lib/container/kubeconfig.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/lib/googlecloudsdk/api_lib/container/kubeconfig.py b/lib/googlecloudsdk/api_lib/container/kubeconfig.py
index 5975cb8f..b98e6721 100644
--- a/lib/googlecloudsdk/api_lib/container/kubeconfig.py
+++ b/lib/googlecloudsdk/api_lib/container/kubeconfig.py
@@ -396,7 +396,7 @@ def _AuthProvider(name='gcp',
if sdk_bin_path is None:
log.error(SDK_BIN_PATH_NOT_FOUND)
raise Error(SDK_BIN_PATH_NOT_FOUND)
- cmd_path = os.path.join(sdk_bin_path, bin_name)
+ cmd_path = bin_name
try:
# Print warning if gke-gcloud-auth-plugin is not present or executable
_GetGkeGcloudPluginCommandAndPrintWarning()

View File

@@ -0,0 +1,47 @@
diff --git a/platform/gsutil/gslib/command_runner.py b/platform/gsutil/gslib/command_runner.py
index f490bb3..dc6bbcc 100644
--- a/platform/gsutil/gslib/command_runner.py
+++ b/platform/gsutil/gslib/command_runner.py
@@ -330,18 +330,6 @@ class CommandRunner(object):
Returns:
Return value(s) from Command that was run.
"""
- command_changed_to_update = False
- if (not skip_update_check and
- self.MaybeCheckForAndOfferSoftwareUpdate(command_name, debug)):
- command_name = 'update'
- command_changed_to_update = True
- args = [_StringToSysArgType('-n')]
-
- # Check for opt-in analytics.
- if system_util.IsRunningInteractively() and collect_analytics:
- metrics.CheckAndMaybePromptForAnalyticsEnabling()
-
- self.MaybePromptForPythonUpdate(command_name)
if not args:
args = []
@@ -415,15 +403,6 @@ class CommandRunner(object):
ShutDownGsutil()
if GetFailureCount() > 0:
return_code = 1
- if command_changed_to_update:
- # If the command changed to update, the user's original command was
- # not executed.
- return_code = 1
- print('\n'.join(
- textwrap.wrap(
- 'Update was successful. Exiting with code 1 as the original command '
- 'issued prior to the update was not executed and should be re-run.'
- )))
return return_code
def SkipUpdateCheck(self):
@@ -467,6 +446,7 @@ class CommandRunner(object):
return True
def MaybeCheckForAndOfferSoftwareUpdate(self, command_name, debug):
+ return False
"""Checks the last time we checked for an update and offers one if needed.
Offer is made if the time since the last update check is longer

View File

@@ -0,0 +1,195 @@
# Make sure that the "with-gce" flag is set when building `google-cloud-sdk`
# for GCE hosts. This flag prevents "google-compute-engine" from being a
# default dependency which is undesirable because this package is
#
# 1) available only on GNU/Linux (requires `systemd` in particular)
# 2) intended only for GCE guests (and is useless elsewhere)
# 3) used by `google-cloud-sdk` only on GCE guests
#
{
stdenv,
lib,
fetchurl,
makeWrapper,
python312,
openssl,
jq,
callPackage,
installShellFiles,
with-gce ? false,
# NumPy is an optional runtime dependency and only needed for IAP TCP forwarding
# https://cloud.google.com/iap/docs/using-tcp-forwarding#increasing_the_tcp_upload_bandwidth
with-numpy ? true,
}:
let
python3 = python312;
# include a compatible pyopenssl version: https://github.com/NixOS/nixpkgs/issues/379291
# remove ASAP: https://github.com/googleapis/google-api-python-client/issues/2554
pythonCustom = python3.override {
self = pythonCustom;
packageOverrides = _: super: {
pyopenssl = super.pyopenssl.overridePythonAttrs (old: rec {
version = "24.2.1";
src = old.src.override {
tag = version;
hash = "sha256-/TQnDWdycN4hQ7ZGvBhMJEZVafmL+0wy9eJ8hC6rfio=";
};
# 36 failed tests
doCheck = false;
});
};
};
pythonEnv = pythonCustom.withPackages (
p:
with p;
[
cffi
cryptography
pyopenssl
crcmod
grpcio
]
++ lib.optional with-gce google-compute-engine
++ lib.optional with-numpy numpy
);
data = import ./data.nix { };
sources = system: data.googleCloudSdkPkgs.${system} or (throw "Unsupported system: ${system}");
components = callPackage ./components.nix {
snapshotPath = ./components.json;
};
withExtraComponents = callPackage ./withExtraComponents.nix { inherit components; };
in
stdenv.mkDerivation rec {
pname = "google-cloud-sdk";
inherit (data) version;
src = fetchurl (sources stdenv.hostPlatform.system);
buildInputs = [ python3 ];
nativeBuildInputs = [
jq
makeWrapper
installShellFiles
];
patches = [
# For kubectl configs, don't store the absolute path of the `gcloud` binary as it can be garbage-collected
./gcloud-path.patch
# Disable checking for updates for the package
./gsutil-disable-updates.patch
];
installPhase = ''
runHook preInstall
mkdir -p $out/google-cloud-sdk
if [ -d platform/bundledpythonunix ]; then
rm -r platform/bundledpythonunix
fi
cp -R * .install $out/google-cloud-sdk/
mkdir -p $out/google-cloud-sdk/lib/surface/{alpha,beta}
cp ${./alpha__init__.py} $out/google-cloud-sdk/lib/surface/alpha/__init__.py
cp ${./beta__init__.py} $out/google-cloud-sdk/lib/surface/beta/__init__.py
# create wrappers with correct env
for program in gcloud bq gsutil git-credential-gcloud.sh docker-credential-gcloud; do
programPath="$out/google-cloud-sdk/bin/$program"
binaryPath="$out/bin/$program"
wrapProgram "$programPath" \
--set CLOUDSDK_PYTHON "${pythonEnv}/bin/python" \
--set CLOUDSDK_PYTHON_ARGS "-S -W ignore" \
--prefix PYTHONPATH : "${pythonEnv}/${python3.sitePackages}" \
--prefix PATH : "${openssl.bin}/bin"
mkdir -p $out/bin
ln -s $programPath $binaryPath
done
# disable component updater and update check
substituteInPlace $out/google-cloud-sdk/lib/googlecloudsdk/core/config.json \
--replace-fail "\"disable_updater\": false" "\"disable_updater\": true"
echo "
[component_manager]
disable_update_check = true" >> $out/google-cloud-sdk/properties
# setup bash completion
mkdir -p $out/share/bash-completion/completions
mv $out/google-cloud-sdk/completion.bash.inc $out/share/bash-completion/completions/gcloud
ln -s $out/share/bash-completion/completions/gcloud $out/share/bash-completion/completions/gsutil
# setup zsh completion
mkdir -p $out/share/zsh/site-functions
mv $out/google-cloud-sdk/completion.zsh.inc $out/share/zsh/site-functions/_gcloud
ln -s $out/share/zsh/site-functions/_gcloud $out/share/zsh/site-functions/_gsutil
# zsh doesn't load completions from $FPATH without #compdef as the first line
sed -i '1 i #compdef gcloud' $out/share/zsh/site-functions/_gcloud
# setup fish completion
installShellCompletion --cmd gcloud \
--fish <(echo "complete -c gcloud -f -a '(__fish_argcomplete_complete gcloud)'")
installShellCompletion --cmd gsutil \
--fish <(echo "complete -c gsutil -f -a '(__fish_argcomplete_complete gsutil)'")
# This directory contains compiled mac binaries. We used crcmod from
# 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 '{}' +
rm $out/google-cloud-sdk/platform/gsutil/gslib/commands/test.py
# compact all the JSON
find $out -name \*.json | while read path; do
jq -c . $path > $path.min
mv $path.min $path
done
runHook postInstall
'';
doInstallCheck = true;
installCheckPhase = ''
# Avoid trying to write logs to homeless-shelter
export HOME=$(mktemp -d)
$out/bin/gcloud version --format json | jq '."Google Cloud SDK"' | grep "${version}"
$out/bin/gsutil version | grep -w "$(cat platform/gsutil/VERSION)"
'';
passthru = {
inherit components withExtraComponents;
updateScript = ./update.sh;
};
meta = with lib; {
description = "Tools for the google cloud platform";
longDescription = "The Google Cloud SDK for GCE hosts. Used by `google-cloud-sdk` only on GCE guests.";
sourceProvenance = with sourceTypes; [
fromSource
binaryNativeCode # anthoscli and possibly more
];
# This package contains vendored dependencies. All have free licenses.
license = licenses.free;
homepage = "https://cloud.google.com/sdk/";
changelog = "https://cloud.google.com/sdk/docs/release-notes";
maintainers = with maintainers; [
iammrinal0
marcusramberg
pradyuman
stephenmw
zimbatm
ryan4yin
];
platforms = builtins.attrNames data.googleCloudSdkPkgs;
mainProgram = "gcloud";
};
}

View File

@@ -0,0 +1,50 @@
#!/usr/bin/env nix-shell
#! nix-shell -i bash -p nix jq curl
CHANNEL_URL="https://dl.google.com/dl/cloudsdk/channels/rapid"
BASE_URL="$CHANNEL_URL/downloads/google-cloud-sdk"
PACKAGE_DIR=$(dirname -- "$0")
VERSION=$(curl "https://storage.googleapis.com/storage/v1/b/cloud-sdk-release/o?delimiter=/&startOffset=google-cloud-sdk-${UPDATE_NIX_OLD_VERSION}&endOffset=google-cloud-sdk-9" | jq --raw-output '.items[-1].name | scan("\\d+\\.\\d+\\.\\d+")')
function genMainSrc() {
local url="${BASE_URL}-${VERSION}-${1}-${2}.tar.gz"
local sha256
sha256=$(nix-prefetch-url "$url")
echo " {"
echo " url = \"${url}\";"
echo " sha256 = \"${sha256}\";"
echo " };"
}
{
cat <<EOF
# DO NOT EDIT! This file is generated automatically by update.sh
{ }:
{
version = "${VERSION}";
googleCloudSdkPkgs = {
EOF
echo -n " x86_64-linux ="
genMainSrc "linux" "x86_64"
echo -n " x86_64-darwin ="
genMainSrc "darwin" "x86_64"
echo -n " aarch64-linux ="
genMainSrc "linux" "arm"
echo -n " aarch64-darwin ="
genMainSrc "darwin" "arm"
echo -n " i686-linux ="
genMainSrc "linux" "x86"
echo " };"
echo "}"
} > "${PACKAGE_DIR}/data.nix"
curl "${CHANNEL_URL}/components-v${VERSION}.json" -w "\n" > "${PACKAGE_DIR}/components.json"

View File

@@ -0,0 +1,86 @@
{
lib,
google-cloud-sdk,
symlinkJoin,
components,
}:
comps_:
let
# Remove components which are already installed by default
filterPreInstalled =
let
preInstalledComponents = with components; [
bq
bq-nix
core
core-nix
gcloud-deps
gcloud
gsutil
gsutil-nix
];
in
builtins.filter (drv: !(builtins.elem drv preInstalledComponents));
# Recursively build a list of components with their dependencies
# TODO this could be made faster, it checks the dependencies too many times
findDepsRecursive = lib.converge (
drvs: lib.unique (drvs ++ (builtins.concatMap (drv: drv.dependencies) drvs))
);
# Components to install by default
defaultComponents = with components; [
alpha
beta
];
comps = [
google-cloud-sdk
]
++ filterPreInstalled (findDepsRecursive (defaultComponents ++ comps_));
installCheck =
let
compNames = map lib.getName comps_;
in
''
$out/bin/gcloud components list --only-local-state --format 'value(id)' > component_list.txt
for comp in ${toString compNames}; do
snapshot_file="$out/google-cloud-sdk/.install/$comp.snapshot.json"
if ! [ -f "$snapshot_file" ]; then
echo "Failed to install component '$comp'"
exit 1
fi
if grep --quiet '"is_hidden":true' "$snapshot_file"; then
continue
fi
if ! grep --quiet "^$comp$" component_list.txt; then
echo "Failed to install component '$comp'"
exit 1
fi
done
'';
in
# The `gcloud` entrypoint script has some custom logic to determine the "real" cloud sdk
# root. In order to not trip up this logic and still have the symlink joined root we copy
# over this file. Since this file also has a Python wrapper, we need to copy that as well.
symlinkJoin {
name = "google-cloud-sdk-${google-cloud-sdk.version}";
inherit (google-cloud-sdk) meta;
paths = [
google-cloud-sdk
]
++ comps;
postBuild = ''
sed -i ';' $out/google-cloud-sdk/bin/.gcloud-wrapped
sed -i -e "s#${google-cloud-sdk}#$out#" "$out/google-cloud-sdk/bin/gcloud"
${installCheck}
'';
}