diff --git a/examples/terraform/.test.sh b/examples/terraform/.test.sh index 73726b66d..699b88b6a 100755 --- a/examples/terraform/.test.sh +++ b/examples/terraform/.test.sh @@ -1,3 +1,3 @@ #!/usr/bin/env bash set -ex -terraform --version | grep "1.5.6" +terraform --version | grep "1.8.4" diff --git a/examples/terraform/devenv.nix b/examples/terraform/devenv.nix index 5789790c5..be7acf2d3 100644 --- a/examples/terraform/devenv.nix +++ b/examples/terraform/devenv.nix @@ -1,11 +1,8 @@ { pkgs, ... }: { - # For versions >= 1.6.0 open a shell by running the following command: - # - # env NIXPKGS_ALLOW_UNFREE=1 devenv --impure shell languages.terraform = { enable = true; - version = "1.5.6"; + version = "1.8.4"; }; } diff --git a/templates/terraform/.envrc b/templates/terraform/.envrc index b351dff3d..ac18306bf 100644 --- a/templates/terraform/.envrc +++ b/templates/terraform/.envrc @@ -2,9 +2,8 @@ if ! has nix_direnv_version || ! nix_direnv_version 2.2.1; then source_url "https://raw.githubusercontent.com/nix-community/nix-direnv/2.2.1/direnvrc" "sha256-zelF0vLbEl5uaqrfIzbgNzJWGmLzCmYAkInj/LNxvKs=" fi -nix_direnv_watch_file devenv.nix -nix_direnv_watch_file devenv.lock -nix_direnv_watch_file devenv.yaml +nix_direnv_watch_file flake.nix +nix_direnv_watch_file flake.lock if ! use flake . --impure then echo "devenv could not be built. The devenv environment was not loaded. Make the necessary changes to devenv.nix and hit enter to try again." >&2 diff --git a/templates/terraform/flake.nix b/templates/terraform/flake.nix index a5c0ed05e..0ee96c84a 100644 --- a/templates/terraform/flake.nix +++ b/templates/terraform/flake.nix @@ -1,25 +1,36 @@ { inputs = { + devenv.inputs.nixpkgs.follows = "nixpkgs"; devenv.url = "github:cachix/devenv"; - flake-utils.url = "github:numtide/flake-utils"; - nixpkgs.url = "nixpkgs/nixos-23.05"; + nixpkgs-terraform.url = "github:stackbuilders/nixpkgs-terraform"; + nixpkgs.url = "github:cachix/devenv-nixpkgs/rolling"; + systems.url = "github:nix-systems/default"; }; - outputs = { self, devenv, flake-utils, nixpkgs }@inputs: - flake-utils.lib.eachDefaultSystem (system: - let - pkgs = nixpkgs.legacyPackages.${system}; - in - { - devShells.default = devenv.lib.mkShell { - inherit inputs pkgs; - modules = [{ - env.AWS_PROFILE = ""; + nixConfig = { + extra-substituters = "https://devenv.cachix.org https://nixpkgs-terraform.cachix.org"; + extra-trusted-public-keys = "devenv.cachix.org-1:w1cLUi8dv3hnoSPGAuibQv+f9TZLr6cv/Hm9XgU50cw= nixpkgs-terraform.cachix.org-1:8Sit092rIdAVENA3ZVeH9hzSiqI/jng6JiCrQ1Dmusw="; + }; - languages.terraform.enable = true; + outputs = { self, devenv, nixpkgs, systems, ... }@inputs: + let + forEachSystem = nixpkgs.lib.genAttrs (import systems); + in + { + devShells = forEachSystem (system: + let + pkgs = nixpkgs.legacyPackages.${system}; + in + { + default = devenv.lib.mkShell { + inherit inputs pkgs; + modules = [{ + languages.terraform.enable = true; + languages.terraform.version = "1.8.4"; - pre-commit.hooks.terraform-format.enable = true; - }]; - }; - }); + pre-commit.hooks.terraform-format.enable = true; + }]; + }; + }); + }; }