Skip to content

Commit

Permalink
Update README file and add LICENSE (#4)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
sestrella authored Nov 16, 2023
1 parent 8dc7dfb commit a6f05a8
Show file tree
Hide file tree
Showing 6 changed files with 206 additions and 18 deletions.
19 changes: 19 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -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.
103 changes: 99 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

---
<img src="https://www.stackbuilders.com/media/images/Sb-supports.original.png"
alt="Stack Builders" width="50%"></img>
[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
35 changes: 35 additions & 0 deletions docs/CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
@@ -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 [[email protected]](mailto:[email protected]). 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.
13 changes: 13 additions & 0 deletions docs/CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -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 [[email protected]](mailto:[email protected])

- 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 [[email protected]](mailto:[email protected]) for more information. Thank you for contributing!
30 changes: 16 additions & 14 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
{
description = "TODO";

inputs = {
flake-utils.inputs.systems.follows = "systems";
flake-utils.url = "github:numtide/flake-utils";
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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;
};
};
}
24 changes: 24 additions & 0 deletions templates/default/flake.nix
Original file line number Diff line number Diff line change
@@ -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 ];
};
});
}

0 comments on commit a6f05a8

Please sign in to comment.