Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Overriding Terraform package is incompatible with terraform-with-plugins #27

Open
srounce opened this issue Jan 11, 2023 · 3 comments
Open
Labels
bug Something isn't working

Comments

@srounce
Copy link
Member

srounce commented Jan 11, 2023

Describe the bug

When setting programs.terraform.package to the result of terraform-with-plugins the terraform binary cannot be found:

Failed to load formatter #terraform due to error: cannot find binary path

To Reproduce

Steps to reproduce the behaviour:

  1. Given the following expression:
let 
  tf = nixpkgs.terraform.withPlugins (p: [
    p.null
  ]);
in
{
  formatter.x86_64-linux = sources.treefmt-nix.lib.mkWrapper
    nixpkgs
    {
      programs.terraform = {
        enable = true;
        package = tf;
      };
    };
}

Expected behavior

Treefmt should find the Terraform binary.

System information

OS: Nixos unstable (5efc8ca954272c4376ac929f4c5ffefcc20551d5)

Versions:

  • Nix: 2.12.0
  • nixpkgs: 5efc8ca954272c4376ac929f4c5ffefcc20551d5
  • treefmt-nix: 6717065d6a432bc3f5b827007ad959e6032d5856

Additional context

@zimbatm diagnosed this issue as being due to the pname of the terraform-with-plugins result not being "terraform". Currently settings.formatter.terraform.command = lib.mkForce "${tf}/bin/terraform"; is a valid workaround.

@srounce srounce added the bug Something isn't working label Jan 11, 2023
@zowoq
Copy link
Contributor

zowoq commented Mar 31, 2023

Adding pname to the wrapper in NixOS/nixpkgs#224005.

@zimbatm
Copy link
Member

zimbatm commented Mar 31, 2023

The best way to fix this is to either

  1. move the -with-plugins annotation to the version (eg: terraform-1.2.3+with-plugins)
  2. or set meta.mainProgram = "terraform" on the terraform package

Or both

@zowoq
Copy link
Contributor

zowoq commented Mar 31, 2023

Sorry, I don't understand why we would need to do either of those, does setting the wrapper pname to terraform not work?

Rechecked, I can reproduce the failure from the example and it works once pname is set.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants