nixos-config/terranix/tinc-test/01-terranix/shell.nix
Ingolf Wagner 973e3b3305
reformat
2021-11-01 19:30:41 +01:00

37 lines
998 B
Nix

{ pkgs ? import <nixpkgs> { } }:
let
terranix = pkgs.callPackage
(pkgs.fetchgit {
url = "https://github.com/mrVanDalo/terranix.git";
rev = "6097722f3a94972a92d810f3a707351cd425a4be";
sha256 = "1d8w82mvgflmscvq133pz9ynr79cgd5qjggng85byk8axj6fg6jw";
})
{ };
terraform = pkgs.writers.writeDashBin "terraform" ''
export TF_VAR_hcloud_api_token=`${pkgs.pass}/bin/pass development/hetzner.com/api-token`
${pkgs.terraform_0_11}/bin/terraform "$@"
'';
create = pkgs.writers.writeDashBin "create" ''
${terranix}/bin/terranix | ${pkgs.jq}/bin/jq '.' > ${
toString ./.
}/config.tf.json \
&& ${terraform}/bin/terraform init \
&& ${terraform}/bin/terraform apply
'';
destroy = pkgs.writers.writeBashBin "destroy" ''
${terraform}/bin/terraform destroy
rm ${toString ./.}/config.tf.json
rm ${toString ./.}/terraform.tfstate*
'';
in
pkgs.mkShell {
buildInputs = with pkgs; [ terranix terraform create destroy ];
}