From b1bba3159da52dc0217c76d654d2f6e5e3e689f2 Mon Sep 17 00:00:00 2001 From: Nick Novitski Date: Sun, 13 Oct 2024 09:20:36 +0200 Subject: [PATCH] Doc fixes --- OPTIONS.md | 45 --------------------------------------- README.md | 29 +++++++++++++++++++------ shell-modules/default.nix | 2 +- 3 files changed, 23 insertions(+), 53 deletions(-) diff --git a/OPTIONS.md b/OPTIONS.md index e02d630..2955e3a 100644 --- a/OPTIONS.md +++ b/OPTIONS.md @@ -43,48 +43,3 @@ Default value: not defined A non-empty string representing the name of the configuration to use in the environment. Default value: not defined - -## Node.js - -[https://nodejs.org/en](https://nodejs.org/en) - -### javascript.node.corepack-shims - -An array of strings which, if `javascript.node.enable` is true, are passed to `corepack enable`, creating [corepack](https://nodejs.org/api/corepack.html) package manager shims. - -Currently, supported values are `"yarn"`, `"pnpm"`, and `"npm"`. - -Default value: `[]` - -### javascript.node.enable - -Whether to add the Node.js runtime to the environment. - -Default value: false - -### javascript.node.env - -If set, then the `NODE_ENV` variable is set to this value in the environment. The only valid values are `"production"`, `"development"`, and `"test"`. - -Default value: unset - -### javascript.node.package - -If `javascript.volta.enable` is true, this package is added to the environment. There are [several alternative packages in nixpkgs](https://search.nixos.org/packages?from=0&size=50&sort=relevance&type=packages&query=nodejs-), such as `nodejs-slim` (which lacks npm), or `nodejs_22` (the latest version in the 22.x line). - -Default value: `pkgs.nodejs` - -## Volta - -[The Hassle-Free JavaScript Tool Manager](https://volta.sh/) - -### javascript.volta.enable - -Whether to add volta to the environment. - -Default value: false -### javascript.volta.home - -A non-empty string. If `javascript.volta.enable` is true, the `VOLTA_HOME` variable is set to this value in the environment. - -Default value: `"$HOME/.volta"` diff --git a/README.md b/README.md index 9908645..ad03af1 100644 --- a/README.md +++ b/README.md @@ -1,17 +1,32 @@ # gcloud-nix -A [make-shell](https://github.com/nicknovitski/make-shell) module for the Google Cloud SDK, or `gcloud` CLI tool. +A [make-shell](https://github.com/nicknovitski/make-shell) module for [the Google Cloud SDK](https://cloud.google.com/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](https://github.com/nicknovitski/make-shell/blob/main/WHY.md). -The Google Cloud SDK nix package has a +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" ]; +} - -This is a module for `make-shell` that lets you +# For each project: +pkgs.make-shell { + imports = [./gke.nix]; # DRY! + # project-specific options +} -I work on projects which attempts to explain how it might be useful, but I thought that creating this repository might also give an indirect explanation. +# 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 @@ -30,7 +45,7 @@ Then, add the shell module to your shell's imports. It'll look something like t ```nix devShells.default = pkgs.make-shell = { imports = [inputs.gcloud-nix.shellModules.default]; # add option declarations... - javascript.gcloud.enable = true; # ...and definitions! + 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 @@ -39,7 +54,7 @@ make-shells.default = {gcloud.enable = true;}; ## Usage -The options this module declares are documented [the OPTIONS.md file](OPTIONS.md). Although if you know even a little nix, I bet you can read the declarations directly from [the module itself](shell-modules/default.nix) directory. +The options which this module declares are documented [the OPTIONS.md file](OPTIONS.md). Although if you know even a little nix, I bet you can read the declarations directly from [the module itself](shell-modules/default.nix). ## Examples diff --git a/shell-modules/default.nix b/shell-modules/default.nix index 5a4042d..48ab648 100644 --- a/shell-modules/default.nix +++ b/shell-modules/default.nix @@ -48,7 +48,7 @@ in }; properties = mkOption { default = { }; - description = "k"; + description = "Configuration properties to set in the shell"; type = types.attrsOf ( types.attrsOf ( types.oneOf [