Repository navigation
fix!: Bump nixpkgs, vendor mkTerraform, drop x86_64-darwin #198
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -8,17 +8,20 @@ | |
| nixpkgs-24_05.url = "github:nixos/nixpkgs/nixos-24.05-small"; | ||
| # INFO: Channel used for building versions from 1.9 onwards | ||
| nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable"; | ||
| systems.url = "github:nix-systems/default"; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @CristhianMotoche I would recommend leaving this input or changing it to one that drops inputs = {
systems.url = "github:nix-systems/default-darwin";
nixpkgs-terraform = {
url = "github:stackbuilders/nixpkgs-terraform";
inputs.systems.follows = "systems";
};
};
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. +1. |
||
| }; | ||
|
|
||
| outputs = | ||
| { self | ||
| , nixpkgs | ||
| , systems | ||
| , ... | ||
| }@inputs: | ||
| let | ||
| forAllSystems = nixpkgs.lib.genAttrs (import systems); | ||
| # INFO: x86_64-darwin is not supported since nixpkgs 26.11 | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @CristhianMotoche I strongly suggest releasing this as a major change. If I recall correctly, the release process is automated on this project via semantic-release; therefore, adding the words
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Agreed. The last two commits already have |
||
| forAllSystems = nixpkgs.lib.genAttrs [ | ||
| "aarch64-darwin" | ||
| "aarch64-linux" | ||
| "x86_64-linux" | ||
| ]; | ||
|
|
||
| terraformVersions = builtins.fromJSON (builtins.readFile ./versions.json); | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -28,11 +28,18 @@ | |
| inherit system; | ||
| config.allowUnfree = false; | ||
| }; | ||
|
|
||
| # nixpkgs-unstable no longer provides mkTerraform, so use a vendored copy | ||
| mkTerraform = | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. question (non-blocking): Did you consider pinning Like the existing 23.05 and 24.05 pins: at its current head it ships Go 1.26.10, still has |
||
| if builtins.compareVersions version "1.9.0" >= 0 then | ||
| (pkgs.callPackage ./terraform.nix { }).mkTerraform | ||
| else | ||
| pkgs.mkTerraform; | ||
| in | ||
|
|
||
| pkgs.lib.warnIf (builtins.compareVersions version "1.6.0" >= 0) | ||
| "allowUnfree is enabled to build version ${version}" | ||
| pkgs.mkTerraform | ||
| mkTerraform | ||
| { | ||
| inherit version hash vendorHash; | ||
| patches = | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,195 @@ | ||||||||||||||||
| # Vendored from nixpkgs (pkgs/applications/networking/cluster/terraform/default.nix) | ||||||||||||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. praise: The source note makes the vendored copy easy to verify I diffed this against nixpkgs at d276d665, and the only differences are the removed |
||||||||||||||||
| # at d276d665e1c8414e4908c130d648f9bb122e3776, before `mkTerraform` was removed | ||||||||||||||||
| # upstream in NixOS/nixpkgs@88b583f9e2. | ||||||||||||||||
|
Comment on lines
+1
to
+3
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. suggestion (non-blocking): Keep the nixpkgs MIT notice on the vendored file Since this file is copied from nixpkgs, its license notice should travel with it. Both projects are MIT, so it's only about carrying the notice.
Suggested change
|
||||||||||||||||
| { stdenv | ||||||||||||||||
| , lib | ||||||||||||||||
| , buildGoModule | ||||||||||||||||
| , fetchFromGitHub | ||||||||||||||||
| , makeWrapper | ||||||||||||||||
| , coreutils | ||||||||||||||||
| , runtimeShell | ||||||||||||||||
| , installShellFiles | ||||||||||||||||
| , | ||||||||||||||||
| }: | ||||||||||||||||
|
|
||||||||||||||||
| let | ||||||||||||||||
| generic = | ||||||||||||||||
| { version | ||||||||||||||||
| , hash | ||||||||||||||||
| , vendorHash ? null | ||||||||||||||||
| , ... | ||||||||||||||||
| }@attrs: | ||||||||||||||||
| let | ||||||||||||||||
| attrs' = removeAttrs attrs [ | ||||||||||||||||
| "version" | ||||||||||||||||
| "hash" | ||||||||||||||||
| "vendorHash" | ||||||||||||||||
| ]; | ||||||||||||||||
| in | ||||||||||||||||
| buildGoModule ( | ||||||||||||||||
| { | ||||||||||||||||
| pname = "terraform"; | ||||||||||||||||
| inherit version vendorHash; | ||||||||||||||||
|
|
||||||||||||||||
| src = fetchFromGitHub { | ||||||||||||||||
| owner = "hashicorp"; | ||||||||||||||||
| repo = "terraform"; | ||||||||||||||||
| rev = "v${version}"; | ||||||||||||||||
| inherit hash; | ||||||||||||||||
| }; | ||||||||||||||||
|
|
||||||||||||||||
| # Set CGO_ENABLED based on platform: | ||||||||||||||||
| # - Linux: CGO_ENABLED=0 for static linking (avoids LTO plugin issues) | ||||||||||||||||
| # - Darwin: CGO_ENABLED=1 to avoid DNS resolution issues | ||||||||||||||||
| # See: https://github.com/hashicorp/terraform/blob/main/BUILDING.md | ||||||||||||||||
| env.CGO_ENABLED = if stdenv.hostPlatform.isDarwin then "1" else "0"; | ||||||||||||||||
|
|
||||||||||||||||
| ldflags = [ | ||||||||||||||||
| "-s" | ||||||||||||||||
| "-w" | ||||||||||||||||
| "-X 'github.com/hashicorp/terraform/version.dev=no'" | ||||||||||||||||
| ]; | ||||||||||||||||
|
|
||||||||||||||||
| postPatch = '' | ||||||||||||||||
| # Between go 1.23 and 1.24 the following GODEBUG setting was removed, and a new | ||||||||||||||||
| # similar one was added. | ||||||||||||||||
| # https://github.com/golang/go/issues/72111 | ||||||||||||||||
| # The setting is configured upstream due to the following timeouts caused by | ||||||||||||||||
| # the TLS handshake using post-quantum crypto with servers that don't support it | ||||||||||||||||
| # https://tldr.fail/ | ||||||||||||||||
| substituteInPlace go.mod \ | ||||||||||||||||
| --replace-quiet 'godebug tlskyber=0' 'godebug tlsmlkem=0' | ||||||||||||||||
| ''; | ||||||||||||||||
| postConfigure = '' | ||||||||||||||||
| # speakeasy hardcodes /bin/stty https://github.com/bgentry/speakeasy/issues/22 | ||||||||||||||||
| substituteInPlace vendor/github.com/bgentry/speakeasy/speakeasy_unix.go \ | ||||||||||||||||
| --replace-fail "/bin/stty" "${coreutils}/bin/stty" | ||||||||||||||||
| ''; | ||||||||||||||||
|
|
||||||||||||||||
| nativeBuildInputs = [ installShellFiles ]; | ||||||||||||||||
|
|
||||||||||||||||
| postInstall = '' | ||||||||||||||||
| # https://github.com/posener/complete/blob/9a4745ac49b29530e07dc2581745a218b646b7a3/cmd/install/bash.go#L8 | ||||||||||||||||
| installShellCompletion --bash --name terraform <(echo complete -C terraform terraform) | ||||||||||||||||
| ''; | ||||||||||||||||
|
|
||||||||||||||||
| preCheck = '' | ||||||||||||||||
| export HOME=$TMPDIR | ||||||||||||||||
| export TF_SKIP_REMOTE_TESTS=1 | ||||||||||||||||
| ''; | ||||||||||||||||
|
|
||||||||||||||||
| subPackages = [ "." ]; | ||||||||||||||||
|
|
||||||||||||||||
| meta = { | ||||||||||||||||
| description = "Tool for building, changing, and versioning infrastructure"; | ||||||||||||||||
| homepage = "https://www.terraform.io/"; | ||||||||||||||||
| changelog = "https://github.com/hashicorp/terraform/blob/v${version}/CHANGELOG.md"; | ||||||||||||||||
| license = lib.licenses.bsl11; | ||||||||||||||||
| maintainers = with lib.maintainers; [ | ||||||||||||||||
| Chili-Man | ||||||||||||||||
| kalbasit | ||||||||||||||||
| timstott | ||||||||||||||||
| zimbatm | ||||||||||||||||
| zowoq | ||||||||||||||||
| techknowlogick | ||||||||||||||||
| qjoly | ||||||||||||||||
| ]; | ||||||||||||||||
| mainProgram = "terraform"; | ||||||||||||||||
| }; | ||||||||||||||||
| } | ||||||||||||||||
| // attrs' | ||||||||||||||||
| ); | ||||||||||||||||
|
|
||||||||||||||||
| pluggable = | ||||||||||||||||
| terraform: | ||||||||||||||||
| let | ||||||||||||||||
| withPlugins = | ||||||||||||||||
| plugins: | ||||||||||||||||
| let | ||||||||||||||||
| actualPlugins = plugins terraform.plugins; | ||||||||||||||||
|
|
||||||||||||||||
| # Wrap PATH of plugins propagatedBuildInputs, plugins may have runtime dependencies on external binaries | ||||||||||||||||
| wrapperInputs = lib.unique ( | ||||||||||||||||
| lib.flatten (lib.catAttrs "propagatedBuildInputs" (builtins.filter (x: x != null) actualPlugins)) | ||||||||||||||||
| ); | ||||||||||||||||
|
|
||||||||||||||||
| passthru = { | ||||||||||||||||
| withPlugins = newplugins: withPlugins (x: newplugins x ++ actualPlugins); | ||||||||||||||||
| full = withPlugins (p: lib.filter lib.isDerivation (lib.attrValues p.actualProviders)); | ||||||||||||||||
|
|
||||||||||||||||
| # Expose wrappers around the override* functions of the terraform | ||||||||||||||||
| # derivation. | ||||||||||||||||
| # | ||||||||||||||||
| # Note that this does not behave as anyone would expect if plugins | ||||||||||||||||
| # are specified. The overrides are not on the user-visible wrapper | ||||||||||||||||
| # derivation but instead on the function application that eventually | ||||||||||||||||
| # generates the wrapper. This means: | ||||||||||||||||
| # | ||||||||||||||||
| # 1. When using overrideAttrs, only `passthru` attributes will | ||||||||||||||||
| # become visible on the wrapper derivation. Other overrides that | ||||||||||||||||
| # modify the derivation *may* still have an effect, but it can be | ||||||||||||||||
| # difficult to follow. | ||||||||||||||||
| # | ||||||||||||||||
| # 2. Other overrides may work if they modify the terraform | ||||||||||||||||
| # derivation, or they may have no effect, depending on what | ||||||||||||||||
| # exactly is being changed. | ||||||||||||||||
| # | ||||||||||||||||
| # 3. Specifying overrides on the wrapper is unsupported. | ||||||||||||||||
| # | ||||||||||||||||
| # See nixpkgs#158620 for details. | ||||||||||||||||
| overrideDerivation = f: (pluggable (terraform.overrideDerivation f)).withPlugins plugins; | ||||||||||||||||
| overrideAttrs = f: (pluggable (terraform.overrideAttrs f)).withPlugins plugins; | ||||||||||||||||
| override = x: (pluggable (terraform.override x)).withPlugins plugins; | ||||||||||||||||
| }; | ||||||||||||||||
| in | ||||||||||||||||
| # Don't bother wrapping unless we actually have plugins, since the wrapper will stop automatic downloading | ||||||||||||||||
| # of plugins, which might be counterintuitive if someone just wants a vanilla Terraform. | ||||||||||||||||
| if actualPlugins == [ ] then | ||||||||||||||||
| terraform.overrideAttrs | ||||||||||||||||
| (orig: { | ||||||||||||||||
| passthru = orig.passthru // passthru; | ||||||||||||||||
| }) | ||||||||||||||||
| else | ||||||||||||||||
| lib.appendToName "with-plugins" ( | ||||||||||||||||
| stdenv.mkDerivation { | ||||||||||||||||
| inherit (terraform) meta pname version; | ||||||||||||||||
| nativeBuildInputs = [ makeWrapper ]; | ||||||||||||||||
|
|
||||||||||||||||
| # Expose the passthru set with the override functions | ||||||||||||||||
| # defined above, as well as any passthru values already | ||||||||||||||||
| # set on `terraform` at this point (relevant in case a | ||||||||||||||||
| # user overrides attributes). | ||||||||||||||||
| passthru = terraform.passthru // passthru; | ||||||||||||||||
|
|
||||||||||||||||
| buildCommand = '' | ||||||||||||||||
| # Create wrappers for terraform plugins because Terraform only | ||||||||||||||||
| # walks inside of a tree of files. | ||||||||||||||||
| for providerDir in ${toString actualPlugins} | ||||||||||||||||
| do | ||||||||||||||||
| for file in $(find $providerDir/libexec/terraform-providers -type f) | ||||||||||||||||
| do | ||||||||||||||||
| relFile=''${file#$providerDir/} | ||||||||||||||||
| mkdir -p $out/$(dirname $relFile) | ||||||||||||||||
| cat <<WRAPPER > $out/$relFile | ||||||||||||||||
| #!${runtimeShell} | ||||||||||||||||
| exec "$file" "$@" | ||||||||||||||||
| WRAPPER | ||||||||||||||||
| chmod +x $out/$relFile | ||||||||||||||||
| done | ||||||||||||||||
| done | ||||||||||||||||
|
|
||||||||||||||||
| # Create a wrapper for terraform to point it to the plugins dir. | ||||||||||||||||
| mkdir -p $out/bin/ | ||||||||||||||||
| makeWrapper "${terraform}/bin/terraform" "$out/bin/terraform" \ | ||||||||||||||||
| --set NIX_TERRAFORM_PLUGIN_DIR $out/libexec/terraform-providers \ | ||||||||||||||||
| --prefix PATH : "${lib.makeBinPath wrapperInputs}" | ||||||||||||||||
| ''; | ||||||||||||||||
| } | ||||||||||||||||
| ); | ||||||||||||||||
| in | ||||||||||||||||
| withPlugins (_: [ ]); | ||||||||||||||||
| in | ||||||||||||||||
| { | ||||||||||||||||
| # Constructor for other terraform versions | ||||||||||||||||
| mkTerraform = attrs: pluggable (generic attrs); | ||||||||||||||||
| } | ||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
suggestion (non-blocking): Move the breaking changes where users will see them
This warning sits under the binary cache section, but x86_64-darwin packages are gone entirely, not just uncached. Could we move it next to the
allowUnfreenote at the top, point Intel Mac users tov5.24.0(the last release that provides it), and add a line thatwithPluginson Terraform >= 1.9 now needs fully qualified names such asp.hashicorp_aws?