Skip to content

A shell module for adding the Google Cloud SDK

Notifications You must be signed in to change notification settings

nicknovitski/gcloud-nix

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

gcloud-nix

A make-shell module for the Google Cloud SDK, or gcloud.

Why?

make-shell is a modular interface for making nix derivations intended for use by the nix develop command. It has it's own lengthy WHY document.

I wrote this module to scratch a small itch I had when working on a bunch of projects were all deployed to Google Cloud, especially on Google Kubernetes Engine. Once this module existed I could write a module that defines shared settings, and have project-specific overrides this:

# gke.nix
{pkgs, ...}: {
  gcloud.enable = true;
  gcloud.extra-components = [ "kubectl" "gke-gcloud-auth-plugin" "skaffold" ];
}

# For each project:
pkgs.make-shell {
  imports = [./gke.nix]; # DRY!
  # project-specific options
}

# For example, a project which also uses pubsub:
pkgs.make-shell ({pkgs, ...}: {
  imports = [./gke.nix];
  gcloud.extra-components = [ "pubsub-emulator" ]; # merges cleanly with the components in gke.nix!
  packages = [ pkgs.openjdk ]; # necessary for the emulator to run
})

Installation

First make sure that you've installed make-shell in your flake.

Then, add gcloud to your flake inputs. Maybe they'd look like this:

  inputs = {
    gcloud-nix.url = "github:nicknovitski/gcloud-nix";
    make-shell.url = "github:nicknovitski/make-shell";
    nixpkgs.url = "github:nixos/nixpkgs?ref=nixos-unstable";
  };

Then, add the shell module to your shell's imports. It'll look something like this:

devShells.default = pkgs.make-shell = { 
  imports = [inputs.gcloud-nix.shellModules.default]; # add option declarations...
  gcloud.enable = true; # ...and definitions!
}
# or, if you're using flake-parts...
make-shell.imports = [gcloud-nix.shellModules.default]; # shared imports for all `make-shells` attributes
make-shells.default = {gcloud.enable = true;};

Usage

The options which this module declares are documented the OPTIONS.md file. Although if you know even a little nix, I bet you can read the declarations directly from the module itself.

Examples

See example/flake.nix.

About

A shell module for adding the Google Cloud SDK

Resources

Stars

Watchers

Forks

Packages

No packages published