nixos-config/terranix/workadventure-jitsi-setup/shell.nix

48 lines
1.2 KiB
Nix
Raw Normal View History

2020-12-30 01:18:37 +01:00
{ pkgs ? import <nixpkgs> { } }:
let
terranix = pkgs.callPackage (pkgs.fetchgit {
url = "https://github.com/mrVanDalo/terranix.git";
rev = "2.3.0";
sha256 = "030067h3gjc02llaa7rx5iml0ikvw6szadm0nrss2sqzshsfimm4";
}) { };
terraform = pkgs.writers.writeBashBin "terraform" ''
export TF_VAR_hcloud_api_token=`${pkgs.pass}/bin/pass development/hetzner.com/api-token`
${pkgs.terraform_0_12}/bin/terraform "$@"
'';
in pkgs.mkShell {
buildInputs = [
terranix
terraform
2021-01-10 03:59:23 +01:00
(pkgs.writers.writeBashBin "terraform-prepare" ''
2020-12-30 01:18:37 +01:00
${pkgs.openssh}/bin/ssh-keygen -P "" -f ${toString ./.}/sshkey
'')
2021-01-10 03:59:23 +01:00
(pkgs.writers.writeBashBin "terraform-build" ''
2020-12-30 01:18:37 +01:00
set -e
set -o pipefail
${terranix}/bin/terranix | ${pkgs.jq}/bin/jq '.' > config.tf.json
${terraform}/bin/terraform init
${terraform}/bin/terraform apply
'')
2021-01-10 03:59:23 +01:00
(pkgs.writers.writeBashBin "terraform-destroy" ''
2020-12-30 01:18:37 +01:00
${terraform}/bin/terraform destroy
rm ${toString ./.}/config.tf.json
2020-12-31 02:51:13 +01:00
'')
2021-01-10 03:59:23 +01:00
(pkgs.writers.writeBashBin "terraform-cleanup" ''
2020-12-30 01:18:37 +01:00
rm ${toString ./.}/sshkey
rm ${toString ./.}/sshkey.pub
rm ${toString ./.}/terraform.tfstate*
'')
];
}