[Question] Support for `google-cloud-sdk` `withExtraComponents` option?
I tried many ways to obtain the result of installing google-cloud-sdk.withExtraComponents [google-cloud-sdk.components.gke-gcloud-auth-plugin], including manually editing the devbox.json file, to no avail.
It seems like the only way to properly use google-cloud-sdk and kubectl as of today.
Is there a way to achieve this using devbox? Thanks!
Hey @gdahia
Currently, this can be done using our Flake Support. The steps to do this are:
- Create a subdirectory called
gcloudin your project - Within that subdirectory, create a
flake.nixfile and add the following:
{
description = "Google Cloud SDK with GKE auth plugin";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
flake-utils.url = "github:numtide/flake-utils";
};
outputs = { self, nixpkgs, flake-utils}:
flake-utils.lib.eachDefaultSystem (system:
let
pkgs = import nixpkgs {
inherit system;
};
in {
packages = {
google-cloud-sdk = pkgs.google-cloud-sdk.withExtraComponents [pkgs.google-cloud-sdk.components.gke-gcloud-auth-plugin];
};
}
);
}
- Add the flake package to your
devbox.jsonby runningdevbox add path:gcloud#google-cloud-sdk, or adding the following to yourdevbox.json:
"packages": [
"<other packages>"
"path:gcloud#google-cloud-sdk"
]
- Now when you run
devbox shell, Devbox will install the SDK with the extra components.
Let me know if this works for you. We should look into making this easier, or finding a way to better customize packages in your devbox.json
Thanks for the reply. For my particular setup, I wanted this for devbox global. How could I adapt these instructions for that setting?
Also, I would be willing to help to implement this in my free time. Unfortunately, I have zero experience with the project and would need some light guidance to do that.
@gdahia This can be added to devbox global by adding the subdirecory and flake in your Devbox global path (print this out by running devbox global path in your terminal) as described above.
You can then add the flake to your global profile using devbox global add path:gcloud#google-cloud-sdk
Thanks, this worked perfectly!
Thanks for the solution @Lagoja.
Any suggestion on how to pin the version? I'm sorry I haven't researched a solution yet. I'm using devbox to avoid Flakes. Would we need to return additional attributes pkgs?
"packages": [
"<other packages>"
"path:[email protected]#[email protected]"
]
Error: error installing package path:./gcloud#[email protected]
source: nix path-info exit code: 1, output: error: flake 'path:/Users/work/Development/GitHub/PHACDataHub/sci-portal/gcloud' does not provide attribute '[email protected]', '[email protected]' or '[email protected]'
, err: exit status 1
@Lagoja 's solution worked for me. Thank you ! There are another person who also used this solution - https://github.com/vfarcic/crossplane-kubernetes/blob/main/devbox.json
@seanpoulter or anyone else found a syntax to pin the google-cloud-sdk version ?