Adding extra components in google-cloud-sdk via overlay

I have this shell.nix:

with import <nixpkgs> { }; let
  google-cloud-sdk = with; withExtraCompoonents [components.gke-gcloud-plugin];
in mkShell {
  name = "env";
  buildInputs = [ google-cloud-sdk ];

and it works - so I can do nix-shell and then use the GKE plugin.

What I wanted to do next is install the same plugin globally with nix-env. Normally I make changes to existing packages with an overlay, but I can’t figure out how to do that. I tried this in ~/.config/nixpkgs/overlays/gcloud.nix:

self: super: {
  google-cloud-sdk = with; withExtraComponents [components.gke-gcloud-auth-plugin];

but it results in an infinite recursion error. If I change the name of the package

self: super: {
  gcloud = with; withExtraComponents [components.gke-gcloud-auth-plugin];

then it works with nix-shell -p gcloud but not nix-env -i gcloud (“error: selector ‘gcloud’ matches no derivations”). So is there a way to break the infinite recursion or fix the nix-env some other way?

1 Like

Can we get some more eyes on this? I’ve been trying to debug the problem, but I’m in over my head. (I use NixOS and my own overlays are much simpler.)

Hosted by Flying Circus.