Created
April 29, 2024 19:12
-
-
Save arraen/cc8deacc58187e63d6409e05696d6c06 to your computer and use it in GitHub Desktop.
Nik flake - Terraform download
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
description = "Flake to download official Terraform binary"; | |
inputs = { | |
nixpkgs.url = "github:NixOS/nixpkgs"; | |
flake-utils.url = "github:numtide/flake-utils"; | |
}; | |
outputs = { self, nixpkgs, flake-utils, ... }: | |
flake-utils.lib.eachDefaultSystem (system: | |
let | |
pkgs = import nixpkgs { | |
inherit system; | |
}; | |
terraformVersion = "1.7.4"; | |
terraformSrc = { | |
x86_64-linux = { | |
url = "https://releases.hashicorp.com/terraform/${terraformVersion}/terraform_${terraformVersion}_linux_amd64.zip"; | |
sha256 = "285539a6fd62fb79f05edc15cc207ca90f282901c32261085ea0642a0d638dfd"; | |
}; | |
x86_64-darwin = { | |
url = "https://releases.hashicorp.com/terraform/${terraformVersion}/terraform_${terraformVersion}_darwin_amd64.zip"; | |
sha256 = "fcf35c8b1d3f46fb84f688312ef5f829081d2d56c10444b9f6e290e21e68871c"; | |
}; | |
aarch64-darwin = { | |
url = "https://releases.hashicorp.com/terraform/${terraformVersion}/terraform_${terraformVersion}_darwin_arm64.zip"; | |
sha256 = "3f25268a5d7677cc89d39a505362979acfb02f19ddb965d7ec0b33a6d9e64075"; | |
}; | |
}.${system} or (throw "Unsupported system: ${system}"); | |
in | |
{ | |
packages.terraform = pkgs.stdenv.mkDerivation { | |
name = "terraform-${terraformVersion}"; | |
src = pkgs.fetchurl terraformSrc; | |
sourceRoot = "."; | |
buildInputs = [ pkgs.unzip ]; # Required to unpack the zip file | |
installPhase = '' | |
mkdir -p $out/bin | |
cp terraform $out/bin/ | |
''; | |
meta = { | |
description = "Terraform is an open-source infrastructure as code software tool"; | |
homepage = https://www.terraform.io/; | |
license = pkgs.lib.licenses.mpl20; | |
}; | |
}; | |
defaultPackage = self.packages.${system}.terraform; | |
} | |
); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment