-
-
Notifications
You must be signed in to change notification settings - Fork 61
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Consider Terranix Integration #75
Comments
heya. here's the snippet of my {
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable";
flake-utils.url = "github:numtide/flake-utils";
terranix = {
url = "github:terranix/terranix";
inputs.nixpkgs.follows = "nixpkgs";
inputs.flake-utils.follows = "flake-utils";
};
terraform-nixos = {
url = "github:tweag/terraform-nixos";
flake = false;
};
};
outputs = inputs@{ self, ... }:
let
inherit (inputs.nixpkgs.lib) nixosSystem;
inherit (inputs.flake-utils.lib) eachDefaultSystem;
inherit (inputs.terranix.lib) terranixConfiguration;
in
{
nixosConfigurations.myhost = nixosSystem {
system = "x86_64-linux";
specialArgs = { inherit inputs; };
modules = [
./myhost.nix
];
};
terraformConfigurations.mydeployment = terranixConfiguration {
system = "x86_64-linux";
extraArgs = { inherit inputs; };
modules = [
./mydeployment.nix
];
};
} // (eachDefaultSystem (system:
let pkgs = import inputs.nixpkgs { inherit system; }; in
{
apps.deploy = {
type = "app";
program = toString (pkgs.writers.writeBash "deploy" ''
set -e
PATH=$PATH:"${pkgs.terraform}/bin"
WORKSPACE=$(terraform workspace show)
OUT_LINK=./config.tf.json
[ -e $OUT_LINK ] && rm -f $OUT_LINK
nix build --out-link $OUT_LINK .#terraformConfigurations.$WORKSPACE
terraform init
terraform apply $@
'');
};
}));
} and { config, pkgs, lib, inputs, ... }:
{
module."nixos_deploy_myhost" = {
source = "${inputs.terraform-nixos}/deploy_nixos";
target_user = "username";
target_host = "hostname";
target_port = 2222;
ssh_agent = true;
flake = true;
nixos_config = "myhost";
};
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This would probably be better as a discussion, but discussions weren't enabled on this repo at time of creation
Overview
Terranix is "a NixOS way to create terraform json files." It leverages the NixOS module system to generate a terraform config file.
By providing the utilities in this package as terranix module(s) in addition to (or instead of) the base terraform module, we could potentially simplify the implementation and provide a more flexible interface for consumers of this module.
Pros
nix-instantiate.sh
script could be removed entirely as all that info could be computed directly in the nix expression)Cons
The text was updated successfully, but these errors were encountered: