|
| 1 | +{ |
| 2 | + description = "Flake for terraform-gcp-meshplatform"; |
| 3 | + |
| 4 | + inputs = { |
| 5 | + nixpkgs.url = "github:nixos/nixpkgs?ref=nixos-24.05"; |
| 6 | + }; |
| 7 | + |
| 8 | + outputs = { self, nixpkgs }: |
| 9 | + |
| 10 | + let |
| 11 | + # These tools are pre-installed in github actions, so we can save the time for installing them. |
| 12 | + github_actions_preinstalled = pkgs: |
| 13 | + with pkgs; |
| 14 | + [ |
| 15 | + awscli2 |
| 16 | + (azure-cli.withExtensions [ azure-cli.extensions.account ]) |
| 17 | + nodejs |
| 18 | + ]; |
| 19 | + |
| 20 | + # core packages required in CI and not preinstalled in github actions |
| 21 | + core_packages = pkgs: |
| 22 | + let |
| 23 | + tofu_terraform = |
| 24 | + pkgs.stdenv.mkDerivation { |
| 25 | + name = "tofu-terraform"; |
| 26 | + phases = [ "installPhase" ]; |
| 27 | + installPhase = '' |
| 28 | + mkdir -p $out/bin |
| 29 | + echo '#!/usr/bin/env sh' > $out/bin/terraform |
| 30 | + echo 'tofu "$@"' >> $out/bin/terraform |
| 31 | + chmod +x $out/bin/terraform |
| 32 | + ''; |
| 33 | + }; |
| 34 | + in |
| 35 | + with pkgs; |
| 36 | + [ |
| 37 | + opentofu |
| 38 | + terragrunt |
| 39 | + tflint |
| 40 | + tfupdate |
| 41 | + terraform-docs |
| 42 | + tofu_terraform |
| 43 | + pre-commit |
| 44 | + ]; |
| 45 | + |
| 46 | + importNixpkgs = system: import nixpkgs { inherit system; }; |
| 47 | + |
| 48 | + defaultShellForSystem = system: |
| 49 | + let |
| 50 | + pkgs = importNixpkgs system; |
| 51 | + in { |
| 52 | + default = pkgs.mkShell { |
| 53 | + name = "terraform-gcp-meshplatform"; |
| 54 | + packages = (github_actions_preinstalled pkgs) ++ (core_packages pkgs); |
| 55 | + }; |
| 56 | + }; |
| 57 | + |
| 58 | + in { |
| 59 | + devShells = { |
| 60 | + aarch64-darwin = defaultShellForSystem "aarch64-darwin"; |
| 61 | + x86_64-darwin = defaultShellForSystem "x86_64-darwin"; |
| 62 | + x86_64-linux = defaultShellForSystem "x86_64-linux" // { |
| 63 | + github_actions = |
| 64 | + let |
| 65 | + pkgs = importNixpkgs "x86_64-linux"; |
| 66 | + in |
| 67 | + pkgs.mkShell { |
| 68 | + name = "terraform-gcp-meshplatform"; |
| 69 | + packages = (core_packages pkgs); |
| 70 | + }; |
| 71 | + }; |
| 72 | + }; |
| 73 | + }; |
| 74 | +} |
| 75 | + |
0 commit comments