From a6f05a81badb33d3e7a3575cb45e404241cfa627 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebasti=C3=A1n=20Estrella?= <2049686+sestrella@users.noreply.github.com> Date: Wed, 15 Nov 2023 20:04:03 -0500 Subject: [PATCH] Update README file and add LICENSE (#4) * Update README file and add LICENSE * Add headline and fix broken link * Update Install and Usage section based on default template * Fix template output * Update intro * Remove flake.lock from default template --- LICENSE | 19 +++++++ README.md | 103 ++++++++++++++++++++++++++++++++++-- docs/CODE_OF_CONDUCT.md | 35 ++++++++++++ docs/CONTRIBUTING.md | 13 +++++ flake.nix | 30 ++++++----- templates/default/flake.nix | 24 +++++++++ 6 files changed, 206 insertions(+), 18 deletions(-) create mode 100644 LICENSE create mode 100644 docs/CODE_OF_CONDUCT.md create mode 100644 docs/CONTRIBUTING.md create mode 100644 templates/default/flake.nix diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..eb7b477 --- /dev/null +++ b/LICENSE @@ -0,0 +1,19 @@ +Copyright (c) 2023-present Stack Builders Inc. + +Permission is hereby granted, free of charge, to any person obtaining a copy of +this software and associated documentation files (the "Software"), to deal in +the Software without restriction, including without limitation the rights to +use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +of the Software, and to permit persons to whom the Software is furnished to do +so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/README.md b/README.md index 7a99e39..be3948c 100644 --- a/README.md +++ b/README.md @@ -3,15 +3,110 @@ [![CI](https://github.com/stackbuilders/nixpkgs-terraform/actions/workflows/ci.yml/badge.svg)](https://github.com/stackbuilders/nixpkgs-terraform/actions/workflows/ci.yml) [![Update](https://github.com/stackbuilders/nixpkgs-terraform/actions/workflows/update.yml/badge.svg)](https://github.com/stackbuilders/nixpkgs-terraform/actions/workflows/update.yml) -## Available Versions +A collection of Terraform versions that are automatically updated. -Terraform versions greater than 1.5.0 are kept up to date via a weekly -scheduled [CI workflow](.github/workflows/update.yaml). +## How it works -## Inspired By +This flake provides a set of Terraform versions in the form of: + +```nix +nixpkgs-terraform.packages.${system}.${version} +``` + +Terraform versions >= 1.5.0 are kept up to date via a weekly scheduled [CI +workflow](.github/workflows/update.yml). The current project structure as well as some components of the CI workflow are heavily inspired by the following projects: - [nixpkgs-python](https://github.com/cachix/nixpkgs-python) - [nixpkgs-ruby](https://github.com/bobvanderlinden/nixpkgs-ruby) + +## Install + +The quickest way to get started with an empty project is to scaffold a new +project using the [default](templates/default) template: + +```sh +nix flake init -t github:stackbuilders/nixpkgs-terraform +``` + +Alternatively, add the following input to an existing `flake.nix` file: + +```nix +inputs.nixpkgs-terraform.url = "github:stackbuilders/nixpkgs-terraform"; +``` + +Some extra inputs are required for the example provided in the [Usage](#usage) +section: + +```nix +inputs.flake-utils.url = "github:numtide/flake-utils"; +inputs.nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable"; +``` + +**Binary Cache** + +It is highly recommended to set up the +[nixpkgs-terraform](https://nixpkgs-terraform.cachix.org) binary cache to +download pre-compiled Terraform binaries rather than compiling them locally for +a better user experience. Add the following configuration to the `flake.nix` +file: + +```nix +nixConfig = { + extra-substituters = "https://nixpkgs-terraform.cachix.org"; + extra-trusted-public-keys = "nixpkgs-terraform.cachix.org-1:8Sit092rIdAVENA3ZVeH9hzSiqI/jng6JiCrQ1Dmusw="; +}; +``` + +## Usage + +After configuring the inputs from the [Install](#install) section, a common use +case for this flake could be spawning a [nix-shell] with a specific Terraform +version, which could be accomplished by extracting the desired version from +`nixpkgs-terraform.packages` as follows: + +```nix +outputs = { self, flake-utils, nixpkgs-terraform, nixpkgs }: + flake-utils.lib.eachDefaultSystem (system: + let + pkgs = nixpkgs.legacyPackages.${system}; + terraform = nixpkgs-terraform.packages.${system}."1.6.3"; + in + { + devShells.default = pkgs.mkShell { + buildInputs = [ terraform ]; + }; + }); +``` + +Start a new [nix-shell] with Terraform installed by running the following +command: + +```sh +env NIXPKGS_ALLOW_UNFREE=1 nix develop --impure +``` + +**Note:** Due to Hashicorp’s most recent [license +change](https://www.hashicorp.com/blog/hashicorp-adopts-business-source-license), +the `NIXPKGS_ALLOW_UNFREE` flag is required for Terraform versions >= 1.6.0, +`nix develop` should work out of the box for older versions. + +## License + +MIT, see [the LICENSE file](LICENSE). + +## Contributing + +Do you want to contribute to this project? Please take a look at our +[contributing guideline](docs/CONTRIBUTING.md) to know how you can help us +build it. + +--- + +[Check out our libraries](https://github.com/stackbuilders/) | [Join our +team](https://www.stackbuilders.com/join-us/) + +[nix-shell]: https://nixos.wiki/wiki/Development_environment_with_nix-shell diff --git a/docs/CODE_OF_CONDUCT.md b/docs/CODE_OF_CONDUCT.md new file mode 100644 index 0000000..f592bc1 --- /dev/null +++ b/docs/CODE_OF_CONDUCT.md @@ -0,0 +1,35 @@ +# Code of conduct + +## Purpose +The primary goal of this Code of Conduct is to enable an open and welcoming environment. We pledge to making participation in our project a harassment-free experience for everyone, regardless of gender, sexual +orientation, ability, ethnicity, socioeconomic status, and religion (or lack thereof). + +## General recommendations +Examples of behavior that contributes to creating a positive environment include: + +- Using welcoming and inclusive language +- Being respectful of differing viewpoints and experiences +- Gracefully accepting constructive criticism +- Focusing on what is best for the community +- Showing empathy towards other community members + +Examples of unacceptable behavior by participants include: + +- The use of sexualized language or imagery and unwelcome sexual attention or advances +- Trolling, insulting/derogatory comments, and personal or political attacks +- Public or private harassment +- Publishing others' private information, such as a physical or electronic address, without explicit permission +- Other conduct which could reasonably be considered inappropriate in a professional setting + +## Maintainer responsibilities +Project maintainers are responsible for clarifying the standards of acceptable behavior and are expected to take appropriate and fair corrective action in response to any instances of unacceptable behavior. + +Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, or to ban temporarily or permanently any contributor for other behaviors that they deem inappropriate, threatening, offensive, or harmful. + +## Scope +This Code of Conduct applies both within project spaces and in public spaces when an individual is representing the project or its community. Examples of representing a project or community include using an official project e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event. Representation of a project may be further defined and clarified by project maintainers. + +## Enforcement +Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project team at [community@stackbuilders.com](mailto:community@stackbuilders.com). All complaints will be reviewed and investigated and will result in a response that is deemed necessary and appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident. Further details of specific enforcement policies may be posted separately. + +Project maintainers who do not follow or enforce the Code of Conduct in good faith may face temporary or permanent repercussions as determined by other members of the project's leadership. diff --git a/docs/CONTRIBUTING.md b/docs/CONTRIBUTING.md new file mode 100644 index 0000000..38d9251 --- /dev/null +++ b/docs/CONTRIBUTING.md @@ -0,0 +1,13 @@ + +Thank you for your interest in contributing to this Stack Builders' library. To contribute, please take our [Code of Conduct](CODE_OF_CONDUCT.md) into account, along with the following recommendations: + +- When submitting contributions to this repository, please make sure to discuss with the maintainer(s) the change you want to make. You can do this through an issue, or by sending an email to [community@stackbuilders.com](mailto:community@stackbuilders.com) + +- Once the change has been discussed with the maintainer(s), feel free to open a Pull Request. Please include a link to the issue you're trying to solve, or a quick summary of the discussed changes. + +- If adding any new features that you think should be considered in the README file, please add that information in your Pull Request. + +- Once you get an approval from any of the maintainers, please merge your Pull Request. Keep in mind that some of our Stack Builders repositories use CI/CD pipelines, so you will need to pass all of the required checks before merging. + +## Getting help +Contact any of our current maintainers, or send us an email at [community@stackbuilders.com](mailto:community@stackbuilders.com) for more information. Thank you for contributing! diff --git a/flake.nix b/flake.nix index a55a951..4ebaa3b 100644 --- a/flake.nix +++ b/flake.nix @@ -1,6 +1,4 @@ { - description = "TODO"; - inputs = { flake-utils.inputs.systems.follows = "systems"; flake-utils.url = "github:numtide/flake-utils"; @@ -18,18 +16,6 @@ versions = builtins.fromJSON (builtins.readFile ./versions.json); in { - # https://github.com/NixOS/nix/issues/7165 - checks = self.packages.${system}; - packages = builtins.listToAttrs - (builtins.map - (version: { - name = version; - value = self.lib.buildTerraform { - inherit system version; - inherit (versions.${version}) hash vendorHash; - }; - }) - (builtins.attrNames versions)); devShell = pkgs.mkShell { buildInputs = [ pkgs-unstable.black @@ -42,6 +28,18 @@ pkgs-unstable.nix-prefetch ]; }; + # https://github.com/NixOS/nix/issues/7165 + checks = self.packages.${system}; + packages = builtins.listToAttrs + (builtins.map + (version: { + name = version; + value = self.lib.buildTerraform { + inherit system version; + inherit (versions.${version}) hash vendorHash; + }; + }) + (builtins.attrNames versions)); }) // { lib.buildTerraform = { system, version, hash, vendorHash }: let @@ -63,5 +61,9 @@ inherit version hash vendorHash; patches = [ "${nixpkgs}/pkgs/applications/networking/cluster/terraform/provider-path-0_15.patch" ]; }; + templates.default = { + description = "Simple nix-shell with Terraform installed via nixpkgs-terraform"; + path = ./templates/default; + }; }; } diff --git a/templates/default/flake.nix b/templates/default/flake.nix new file mode 100644 index 0000000..d88645b --- /dev/null +++ b/templates/default/flake.nix @@ -0,0 +1,24 @@ +{ + inputs = { + flake-utils.url = "github:numtide/flake-utils"; + nixpkgs-terraform.url = "github:stackbuilders/nixpkgs-terraform"; + nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable"; + }; + + nixConfig = { + extra-substituters = "https://nixpkgs-terraform.cachix.org"; + extra-trusted-public-keys = "nixpkgs-terraform.cachix.org-1:8Sit092rIdAVENA3ZVeH9hzSiqI/jng6JiCrQ1Dmusw="; + }; + + outputs = { self, flake-utils, nixpkgs-terraform, nixpkgs }: + flake-utils.lib.eachDefaultSystem (system: + let + pkgs = nixpkgs.legacyPackages.${system}; + terraform = nixpkgs-terraform.packages.${system}."1.6.3"; + in + { + devShells.default = pkgs.mkShell { + buildInputs = [ terraform ]; + }; + }); +}