From 96c718d0dd5c26f4c15f3f2822742e11ca3a2130 Mon Sep 17 00:00:00 2001 From: Deepak Mallubhotla Date: Thu, 4 Sep 2025 16:07:30 -0500 Subject: [PATCH] initial commit --- README.md | 8 +++++++ flake.lock | 62 ++++++++++++++++++++++++++++++++++++++++++++++++++++ flake.nix | 48 ++++++++++++++++++++++++++++++++++++++++ justfile | 25 +++++++++++++++++++++ terraform.tf | 10 +++++++++ treefmt.nix | 21 ++++++++++++++++++ 6 files changed, 174 insertions(+) create mode 100644 README.md create mode 100644 flake.lock create mode 100644 flake.nix create mode 100644 justfile create mode 100644 terraform.tf create mode 100644 treefmt.nix diff --git a/README.md b/README.md new file mode 100644 index 0000000..976d1b1 --- /dev/null +++ b/README.md @@ -0,0 +1,8 @@ +# Testaform + +Testing terraform out + +--- + + +Add `dotenv` to .envrc after other nix stuff, and store keys in .env, which is fine for a testing project. diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..a9a1b0b --- /dev/null +++ b/flake.lock @@ -0,0 +1,62 @@ +{ + "nodes": { + "nixpkgs": { + "locked": { + "lastModified": 1755615617, + "narHash": "sha256-HMwfAJBdrr8wXAkbGhtcby1zGFvs+StOp19xNsbqdOg=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "20075955deac2583bb12f07151c2df830ef346b4", + "type": "github" + }, + "original": { + "owner": "nixos", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs_2": { + "locked": { + "lastModified": 1754340878, + "narHash": "sha256-lgmUyVQL9tSnvvIvBp7x1euhkkCho7n3TMzgjdvgPoU=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "cab778239e705082fe97bb4990e0d24c50924c04", + "type": "github" + }, + "original": { + "owner": "nixos", + "ref": "nixpkgs-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "nixpkgs": "nixpkgs", + "treefmt-nix": "treefmt-nix" + } + }, + "treefmt-nix": { + "inputs": { + "nixpkgs": "nixpkgs_2" + }, + "locked": { + "lastModified": 1755934250, + "narHash": "sha256-CsDojnMgYsfshQw3t4zjRUkmMmUdZGthl16bXVWgRYU=", + "owner": "numtide", + "repo": "treefmt-nix", + "rev": "74e1a52d5bd9430312f8d1b8b0354c92c17453e5", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "treefmt-nix", + "type": "github" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..c1fe3bf --- /dev/null +++ b/flake.nix @@ -0,0 +1,48 @@ +{ + description = "Basic flake and files - change me"; + + inputs = { + nixpkgs.url = "github:nixos/nixpkgs?ref=nixos-unstable"; + treefmt-nix.url = "github:numtide/treefmt-nix"; + }; + outputs = + { nixpkgs, ... }@inputs: + let + supportedSystems = [ "x86_64-linux" ]; + pkgsFor = + system: + let + pkgs = import nixpkgs { + inherit system; + config.allowUnfree = true; + }; + in + pkgs.extend ( + nixpkgs.lib.composeManyExtensions [ ] + # nixpkgs.lib.composeManyExtensions ([ ] ++ builtins.attrValues self.overlays) + ); + eachSystem = f: nixpkgs.lib.genAttrs supportedSystems (system: f (pkgsFor system)); + + treefmtEval = eachSystem (pkgs: inputs.treefmt-nix.lib.evalModule pkgs ./treefmt.nix); + in + { + # nix fmt formatter + formatter = eachSystem (pkgs: treefmtEval.${pkgs.system}.config.build.wrapper); + + # default devshell + + devShells = eachSystem (pkgs: { + default = pkgs.mkShell { + packages = with pkgs; [ + just + awscli2 + terraform + ]; + + # Will be executed before entering the shell + # or running a command + shellHook = ''''; + }; + }); + }; +} diff --git a/justfile b/justfile new file mode 100644 index 0000000..18b9a0d --- /dev/null +++ b/justfile @@ -0,0 +1,25 @@ +# by default list all just commands +default: + just --list + +# run all tests +test: + #!/usr/bin/env bash + set -euxo pipefail + + # would love test: fmt to make sure formatting happens but in WSL formatting is slow... + # poor filesystem access performance + + echo "testing..." + nix flake check + # uv run ruff check src tests + +# + +# format code +fmt: + #!/usr/bin/env bash + set -euxo pipefail + nix fmt + # shouldn't actually be that hard to put into nix fmt but lazyyy + terraform fmt diff --git a/terraform.tf b/terraform.tf new file mode 100644 index 0000000..65c7ec2 --- /dev/null +++ b/terraform.tf @@ -0,0 +1,10 @@ +terraform { + required_providers { + aws = { + source = "hashicorp/aws" + version = "~> 5.92" + } + } + + required_version = ">= 1.2" +} diff --git a/treefmt.nix b/treefmt.nix new file mode 100644 index 0000000..aa39100 --- /dev/null +++ b/treefmt.nix @@ -0,0 +1,21 @@ +# treefmt.nix +{ ... }: +{ + projectRootFile = "treefmt.nix"; + settings.global.excludes = [ + "*.toml" + "*.txt" + ".gitattributes" + "CLAUDE.md" + ".python-version" + ]; + + programs.deadnix.enable = true; + programs.mdsh.enable = true; + programs.nixfmt.enable = true; + programs.shellcheck.enable = true; + programs.shfmt.enable = true; + programs.yamlfmt.enable = true; + programs.just.enable = true; + +}