nixos-config/terranix/tinc-test/01-terranix/shell.nix

35 lines
976 B
Nix
Raw Normal View History

2020-01-06 06:37:25 +01:00
{ 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
'';
clean = pkgs.writers.writeBashBin "clean" ''
${terraform}/bin/terraform destroy
rm ${toString ./.}/config.tf.json
rm ${toString ./.}/terraform.tfstate*
'';
in pkgs.mkShell {
buildInputs = with pkgs; [ terranix terraform create clean ];
}