Skip to content
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

terraform-full: fix evaluation #100072

Merged
merged 2 commits into from Oct 9, 2020
Merged

terraform-full: fix evaluation #100072

merged 2 commits into from Oct 9, 2020

Conversation

@zimbatm
Copy link
Member

@zimbatm zimbatm commented Oct 9, 2020

Fix the nixpkgs evaluation that was broken by
cd1b594 (#99198)

Things done
  • Tested using sandboxing (nix.useSandbox on NixOS, or option sandbox in nix.conf on non-NixOS linux)
  • Built on platform(s)
    • NixOS
    • macOS
    • other Linux distributions
  • Tested via one or more NixOS test(s) if existing and applicable for the change (look inside nixos/tests)
  • Tested compilation of all pkgs that depend on this change using nix-shell -p nixpkgs-review --run "nixpkgs-review wip"
  • Tested execution of all binary files (usually in ./result/bin/)
  • Determined the impact on package closure size (by running nix path-info -S before and after)
  • Ensured that relevant documentation is up to date
  • Fits CONTRIBUTING.md.
We will be relying on the pname to figure out where to link the plugin.
@zimbatm zimbatm changed the title ###### Motivation for this change terraform-full: fix evaluation Oct 9, 2020
Copy link
Contributor

@timstott timstott left a comment

Successfully tested with the setup below.

# main.tf
terraform {
  required_providers {
    acme = {
      source  = "getstackhead/acme"
      version = "1.5.0-patched"
    }
    auth0 = {
      source = "nixpkgs/auth0"
    }
    ansible = {
      source = "nixpkgs/ansible"
    }
  }
}

# provider available on registry.terraform.io
provider "acme" {}
# custom providers
provider "ansible" {}
provider "auth0" {}
# hashicorp providers
provider "cloudinit" {}
provider "dns" {}
rm -rf .terraform
nix-shell -I nixpkgs=$HOME/projects/nix/nixpkgs -p 'terraform_0_13.withPlugins (p : with p;[acme auth0 cloudinit dns ansible])' --command "terraform init"

Initializing provider plugins...
- Finding getstackhead/acme versions matching "1.5.0-patched"...
- Finding latest version of nixpkgs/auth0...
- Finding latest version of nixpkgs/ansible...
- Finding latest version of hashicorp/cloudinit...
- Finding latest version of hashicorp/dns...
- Installing nixpkgs/auth0 v0.11.0...
- Installed nixpkgs/auth0 v0.11.0 (unauthenticated)
- Installing nixpkgs/ansible v1.0.3...
- Installed nixpkgs/ansible v1.0.3 (unauthenticated)
- Installing hashicorp/cloudinit v1.0.0...
- Installed hashicorp/cloudinit v1.0.0 (unauthenticated)
- Installing hashicorp/dns v2.2.0...
- Installed hashicorp/dns v2.2.0 (unauthenticated)
- Installing getstackhead/acme v1.5.0-patched...
- Installed getstackhead/acme v1.5.0-patched (unauthenticated)

The following providers do not have any version constraints in configuration,
so the latest version was installed.

To prevent automatic upgrades to new major versions that may contain breaking
changes, we recommend adding version constraints in a required_providers block
in your configuration, with the constraint strings suggested below.

* hashicorp/cloudinit: version = "~> 1.0.0"
* hashicorp/dns: version = "~> 2.2.0"
* nixpkgs/ansible: version = "~> 1.0.3"
* nixpkgs/auth0: version = "~> 0.11.0"

Terraform has been successfully initialized!

Move the providerSourceAddress fallback to the terraform.withPlugins
function. Since plugins can be arbitrary derivations, there is no
guarantee that this attribute will be exposed.

While doing that I also cleaned the toDrv function to only pass
attributes to the builder which are required by the build.

The Terraform 0.13 fallback slug has changed from
`nixpkgs/<provider-owner>/<provider-name>` to `nixpkgs/<provider-name>`
as the owner is also not always available. As a nixpkgs user, all I know
is that the provider is in nixpkgs and his name, the owner information
is not necessarily easy to get by.
@zimbatm zimbatm force-pushed the tf-0.13-fixups branch from fe9b869 to c79ff8d Oct 9, 2020
@zimbatm zimbatm merged commit 0e354d8 into NixOS:master Oct 9, 2020
2 of 4 checks passed
@zimbatm zimbatm deleted the tf-0.13-fixups branch Oct 9, 2020
@jfroche
Copy link
Contributor

@jfroche jfroche commented Oct 14, 2020

@zimbatm Would it be an option to backport this to 20.09 release to be able to use terraform 0.13 in 20.09 ? I can cherry pick if you want

@zimbatm
Copy link
Member Author

@zimbatm zimbatm commented Oct 14, 2020

Was the 0.13 initial work also ported to 20.09? Normally I would say no, as 20.09 should only get fixes at this point.

@timstott
Copy link
Contributor

@timstott timstott commented Oct 14, 2020

The initial work is not in release-20.09 or nixos-20.09 branches. So that rules out the inclusion of these changes into the 20.09 release.

@jfroche you may want to acquire these changes through an overlay.

@jfroche
Copy link
Contributor

@jfroche jfroche commented Oct 14, 2020

@timstott Sure understand your point. We already use this wonderful commit (thank you !) within our overlay.

But is that mean that terraform 0.13 is available in 20.09 but that we cannot use it with providers ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

3 participants