DEV Community

Cover image for Combining Nix with Terraform for better DevOps
Emilia G.
Emilia G.

Posted on • Originally published at stackbuilders.com

Combining Nix with Terraform for better DevOps

An investment in creating the best software in the world will still go to waste if the infrastructure it runs on isn’t well-managed. At Stack Builders, our mission is to push the boundaries of the software industry through quality, pragmatic solutions that bring to life our client's vision, and one way we are doing this is to leverage our training and staff experience with functional programming to make DevOps better.

In that light, we’re thrilled to announce the release of nixpkgs-terraform! This Nix project significantly enhances the flexibility and control of your Terraform environment, making its installation and management declarative and reproducible. This is largely thanks to Nix and its unique capabilities for precisely pinning packages to a version, ensuring its consistency across different environments. Forget about writing documentation on environment setup - just use one of the provided templates to bootstrap your Terraform installation and get the whole team on the same version with minimal manual intervention.

No need for deep knowledge of Nix either - just keep adding tools to your template of choice to craft a reproducible, declarative, and portable development environment for everyone on the project so that you can focus on what matters.

At Stack Builders, our DevOps/SRE team uses nix-shells to install all of the necessary tooling to work on various Infrastructure-as-Code projects across the board. However, while nix-shells are useful for creating portable development environments, more fine-grained control over the different Terraform versions was lacking. We've taken inspiration from nixpkgs-python and nixpkgs-ruby, and we're grateful for the paths they've paved.

We’ve noticed that some users have been asking about how to use older versions of Terraform in their Nix setups [1, 2]. This is an example of the diverse needs of people and the importance of maintaining backward compatibility. We hope that nixpkgs-terraform will be a useful tool for these users.

The design of nixpkgs-terraform follows a bottom-up approach, making it more approachable for newcomers. We hope this will empower everyone to take their Nix experience to the next level!

Looking forward to your feedback and contributions. Happy Nixing!

Don't forget to subscribe to our newsletter.

Top comments (0)