Skip to content

TECHNOFAB11/Tofunix

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

58 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Tofunix

built with nix pipeline status License: MIT Latest Release Support me Docs

Writing Terraform configurations using Nix, validated by the NixOS/nixpkgs module system. Inspired by Terranix but stricter and mostly for use with OpenTofu.

What is Tofunix?

Tofunix bridges the Nix and Terraform/Opentofu ecosystems by allowing you to define your infrastructure as Nix expressions (everything, not just NixOS and friends). It provides:

  • Type-safe resource definitions & correctness using Nix's module system & generators
  • Reproducible environments with locked dependencies
  • Developer Experience: Nix is arguably better and more flexible than HCL

Quick Start

1. Define your configuration

Create a my-infra.nix file:

{ref, ...}: {
  variable."bunny_api_key" = {
    type = "string";
  };
  provider.bunnynet."default" = {
    api_key = ref.var.bunny_api_key;
  };
}

2. Run with Nix

{
  inputs.tofunix.url = "gitlab:TECHNOFAB/tofunix?dir=lib";
  # perSystem
  # tofunix-lib = inputs.tofunix.lib { inherit pkgs lib; };
  packages.tofunix = tofunix-lib.mkCliAio {
    plugins = [
      (tofunix-lib.mkOpentofuProvider {
        owner = "bunnyway";
        repo = "bunnynet";
        version = "0.7.0";
        hash = "sha256-GvgAD+E/3potxlZJ3QF3UKB0r4I7lU/NGoV+/8R7RuU=";
      })
    ];
    moduleConfig = ./my-infra.nix;  # nix module, so either a path, an attrset, a function etc.
  };
}
nix run .#tofunix -- apply # , validate, etc.

Documentation

See the docs.

About

[mirror] Combining Nix and Terraform for reproducibility and developer experience. https://gitlab.com/TECHNOFAB/tofunix

Topics

Resources

License

Stars

Watchers

Forks

Contributors