Skip to content

Commit 3e55629

Browse files
committed
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
1 parent e4deb0a commit 3e55629

File tree

6 files changed

+206
-18
lines changed

6 files changed

+206
-18
lines changed

LICENSE

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
Copyright (c) 2023-present Stack Builders Inc.
2+
3+
Permission is hereby granted, free of charge, to any person obtaining a copy of
4+
this software and associated documentation files (the "Software"), to deal in
5+
the Software without restriction, including without limitation the rights to
6+
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
7+
of the Software, and to permit persons to whom the Software is furnished to do
8+
so, subject to the following conditions:
9+
10+
The above copyright notice and this permission notice shall be included in all
11+
copies or substantial portions of the Software.
12+
13+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19+
SOFTWARE.

README.md

+99-4
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,110 @@
33
[![CI](https://github.com/stackbuilders/nixpkgs-terraform/actions/workflows/ci.yml/badge.svg)](https://github.com/stackbuilders/nixpkgs-terraform/actions/workflows/ci.yml)
44
[![Update](https://github.com/stackbuilders/nixpkgs-terraform/actions/workflows/update.yml/badge.svg)](https://github.com/stackbuilders/nixpkgs-terraform/actions/workflows/update.yml)
55

6-
## Available Versions
6+
A collection of Terraform versions that are automatically updated.
77

8-
Terraform versions greater than 1.5.0 are kept up to date via a weekly
9-
scheduled [CI workflow](.github/workflows/update.yaml).
8+
## How it works
109

11-
## Inspired By
10+
This flake provides a set of Terraform versions in the form of:
11+
12+
```nix
13+
nixpkgs-terraform.packages.${system}.${version}
14+
```
15+
16+
Terraform versions >= 1.5.0 are kept up to date via a weekly scheduled [CI
17+
workflow](.github/workflows/update.yml).
1218

1319
The current project structure as well as some components of the CI workflow are
1420
heavily inspired by the following projects:
1521

1622
- [nixpkgs-python](https://github.com/cachix/nixpkgs-python)
1723
- [nixpkgs-ruby](https://github.com/bobvanderlinden/nixpkgs-ruby)
24+
25+
## Install
26+
27+
The quickest way to get started with an empty project is to scaffold a new
28+
project using the [default](templates/default) template:
29+
30+
```sh
31+
nix flake init -t github:stackbuilders/nixpkgs-terraform
32+
```
33+
34+
Alternatively, add the following input to an existing `flake.nix` file:
35+
36+
```nix
37+
inputs.nixpkgs-terraform.url = "github:stackbuilders/nixpkgs-terraform";
38+
```
39+
40+
Some extra inputs are required for the example provided in the [Usage](#usage)
41+
section:
42+
43+
```nix
44+
inputs.flake-utils.url = "github:numtide/flake-utils";
45+
inputs.nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable";
46+
```
47+
48+
**Binary Cache**
49+
50+
It is highly recommended to set up the
51+
[nixpkgs-terraform](https://nixpkgs-terraform.cachix.org) binary cache to
52+
download pre-compiled Terraform binaries rather than compiling them locally for
53+
a better user experience. Add the following configuration to the `flake.nix`
54+
file:
55+
56+
```nix
57+
nixConfig = {
58+
extra-substituters = "https://nixpkgs-terraform.cachix.org";
59+
extra-trusted-public-keys = "nixpkgs-terraform.cachix.org-1:8Sit092rIdAVENA3ZVeH9hzSiqI/jng6JiCrQ1Dmusw=";
60+
};
61+
```
62+
63+
## Usage
64+
65+
After configuring the inputs from the [Install](#install) section, a common use
66+
case for this flake could be spawning a [nix-shell] with a specific Terraform
67+
version, which could be accomplished by extracting the desired version from
68+
`nixpkgs-terraform.packages` as follows:
69+
70+
```nix
71+
outputs = { self, flake-utils, nixpkgs-terraform, nixpkgs }:
72+
flake-utils.lib.eachDefaultSystem (system:
73+
let
74+
pkgs = nixpkgs.legacyPackages.${system};
75+
terraform = nixpkgs-terraform.packages.${system}."1.6.3";
76+
in
77+
{
78+
devShells.default = pkgs.mkShell {
79+
buildInputs = [ terraform ];
80+
};
81+
});
82+
```
83+
84+
Start a new [nix-shell] with Terraform installed by running the following
85+
command:
86+
87+
```sh
88+
env NIXPKGS_ALLOW_UNFREE=1 nix develop --impure
89+
```
90+
91+
**Note:** Due to Hashicorp’s most recent [license
92+
change](https://www.hashicorp.com/blog/hashicorp-adopts-business-source-license),
93+
the `NIXPKGS_ALLOW_UNFREE` flag is required for Terraform versions >= 1.6.0,
94+
`nix develop` should work out of the box for older versions.
95+
96+
## License
97+
98+
MIT, see [the LICENSE file](LICENSE).
99+
100+
## Contributing
101+
102+
Do you want to contribute to this project? Please take a look at our
103+
[contributing guideline](docs/CONTRIBUTING.md) to know how you can help us
104+
build it.
105+
106+
---
107+
<img src="https://www.stackbuilders.com/media/images/Sb-supports.original.png"
108+
alt="Stack Builders" width="50%"></img>
109+
[Check out our libraries](https://github.com/stackbuilders/) | [Join our
110+
team](https://www.stackbuilders.com/join-us/)
111+
112+
[nix-shell]: https://nixos.wiki/wiki/Development_environment_with_nix-shell

docs/CODE_OF_CONDUCT.md

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# Code of conduct
2+
3+
## Purpose
4+
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
5+
orientation, ability, ethnicity, socioeconomic status, and religion (or lack thereof).
6+
7+
## General recommendations
8+
Examples of behavior that contributes to creating a positive environment include:
9+
10+
- Using welcoming and inclusive language
11+
- Being respectful of differing viewpoints and experiences
12+
- Gracefully accepting constructive criticism
13+
- Focusing on what is best for the community
14+
- Showing empathy towards other community members
15+
16+
Examples of unacceptable behavior by participants include:
17+
18+
- The use of sexualized language or imagery and unwelcome sexual attention or advances
19+
- Trolling, insulting/derogatory comments, and personal or political attacks
20+
- Public or private harassment
21+
- Publishing others' private information, such as a physical or electronic address, without explicit permission
22+
- Other conduct which could reasonably be considered inappropriate in a professional setting
23+
24+
## Maintainer responsibilities
25+
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.
26+
27+
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.
28+
29+
## Scope
30+
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.
31+
32+
## Enforcement
33+
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.
34+
35+
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.

docs/CONTRIBUTING.md

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
2+
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:
3+
4+
- 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)
5+
6+
- 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.
7+
8+
- If adding any new features that you think should be considered in the README file, please add that information in your Pull Request.
9+
10+
- 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.
11+
12+
## Getting help
13+
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!

flake.nix

+16-14
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
{
2-
description = "TODO";
3-
42
inputs = {
53
flake-utils.inputs.systems.follows = "systems";
64
flake-utils.url = "github:numtide/flake-utils";
@@ -18,18 +16,6 @@
1816
versions = builtins.fromJSON (builtins.readFile ./versions.json);
1917
in
2018
{
21-
# https://github.com/NixOS/nix/issues/7165
22-
checks = self.packages.${system};
23-
packages = builtins.listToAttrs
24-
(builtins.map
25-
(version: {
26-
name = version;
27-
value = self.lib.buildTerraform {
28-
inherit system version;
29-
inherit (versions.${version}) hash vendorHash;
30-
};
31-
})
32-
(builtins.attrNames versions));
3319
devShell = pkgs.mkShell {
3420
buildInputs = [
3521
pkgs-unstable.black
@@ -42,6 +28,18 @@
4228
pkgs-unstable.nix-prefetch
4329
];
4430
};
31+
# https://github.com/NixOS/nix/issues/7165
32+
checks = self.packages.${system};
33+
packages = builtins.listToAttrs
34+
(builtins.map
35+
(version: {
36+
name = version;
37+
value = self.lib.buildTerraform {
38+
inherit system version;
39+
inherit (versions.${version}) hash vendorHash;
40+
};
41+
})
42+
(builtins.attrNames versions));
4543
}) // {
4644
lib.buildTerraform = { system, version, hash, vendorHash }:
4745
let
@@ -63,5 +61,9 @@
6361
inherit version hash vendorHash;
6462
patches = [ "${nixpkgs}/pkgs/applications/networking/cluster/terraform/provider-path-0_15.patch" ];
6563
};
64+
templates.default = {
65+
description = "Simple nix-shell with Terraform installed via nixpkgs-terraform";
66+
path = ./templates/default;
67+
};
6668
};
6769
}

templates/default/flake.nix

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
{
2+
inputs = {
3+
flake-utils.url = "github:numtide/flake-utils";
4+
nixpkgs-terraform.url = "github:stackbuilders/nixpkgs-terraform";
5+
nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable";
6+
};
7+
8+
nixConfig = {
9+
extra-substituters = "https://nixpkgs-terraform.cachix.org";
10+
extra-trusted-public-keys = "nixpkgs-terraform.cachix.org-1:8Sit092rIdAVENA3ZVeH9hzSiqI/jng6JiCrQ1Dmusw=";
11+
};
12+
13+
outputs = { self, flake-utils, nixpkgs-terraform, nixpkgs }:
14+
flake-utils.lib.eachDefaultSystem (system:
15+
let
16+
pkgs = nixpkgs.legacyPackages.${system};
17+
terraform = nixpkgs-terraform.packages.${system}."1.6.3";
18+
in
19+
{
20+
devShells.default = pkgs.mkShell {
21+
buildInputs = [ terraform ];
22+
};
23+
});
24+
}

0 commit comments

Comments
 (0)