Skip to content

Commit 8939196

Browse files
authored
feat: Initial support for Terraform 1.9 versions (#83)
1 parent 034287e commit 8939196

File tree

7 files changed

+102
-41
lines changed

7 files changed

+102
-41
lines changed

.github/workflows/build.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -52,10 +52,10 @@ jobs:
5252
run: |
5353
if grep -q authToken ~/.config/cachix/cachix.dhall; then
5454
echo "Cachix token is present"
55-
cachix watch-exec nixpkgs-terraform nix -- flake check
55+
cachix watch-exec nixpkgs-terraform nix -- flake check --max-jobs 2
5656
else
5757
echo "Cachix token is not present"
58-
nix flake check
58+
nix flake check --max-jobs 2
5959
fi
6060
6161
template:

flake.lock

+35-24
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

flake.nix

+15-7
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,9 @@
44
inputs = {
55
config.url = "github:stackbuilders/nixpkgs-terraform?dir=templates/config";
66
flake-parts.url = "github:hercules-ci/flake-parts";
7-
nixpkgs-unstable.url = "github:nixos/nixpkgs/nixpkgs-unstable";
8-
nixpkgs.url = "github:nixos/nixpkgs/nixos-23.05";
7+
nixpkgs-1_0.url = "github:nixos/nixpkgs/41de143fda10e33be0f47eab2bfe08a50f234267"; # nixos-23.05
8+
nixpkgs-1_6.url = "github:nixos/nixpkgs/d6b3ddd253c578a7ab98f8011e59990f21dc3932"; # nixos-24.05
9+
nixpkgs-1_9.url = "github:nixos/nixpkgs/f5fd8730397b9951d24de58f51a5e9cb327e2a85"; # nixpkgs-unstable
910
systems.url = "github:nix-systems/default";
1011
};
1112

@@ -18,13 +19,20 @@
1819

1920
systems = import inputs.systems;
2021

21-
perSystem = { config, pkgs, pkgs-unstable, system, ... }:
22+
perSystem = { config, pkgs-1_0, pkgs-1_6, pkgs-1_9, system, ... }:
2223
let
2324
flakeConfig = import inputs.config;
2425
in
2526
{
2627
_module.args = {
27-
pkgs-unstable = import inputs.nixpkgs-unstable {
28+
pkgs-1_0 = import inputs.nixpkgs-1_0 {
29+
inherit system;
30+
};
31+
pkgs-1_6 = import inputs.nixpkgs-1_6 {
32+
inherit system;
33+
config = flakeConfig.nixpkgs-unstable;
34+
};
35+
pkgs-1_9 = import inputs.nixpkgs-1_9 {
2836
inherit system;
2937
config = flakeConfig.nixpkgs-unstable;
3038
};
@@ -41,11 +49,11 @@
4149
versionLessThan1_6 = version: builtins.compareVersions version "1.6.0" < 0;
4250
in
4351
{
44-
releases = pkgs.lib.filterAttrs (version: _: allowUnfree || versionLessThan1_6 version) versions.releases;
45-
latest = pkgs.lib.filterAttrs (_: version: allowUnfree || versionLessThan1_6 version) versions.latest;
52+
releases = pkgs-1_9.lib.filterAttrs (version: _: allowUnfree || versionLessThan1_6 version) versions.releases;
53+
latest = pkgs-1_9.lib.filterAttrs (_: version: allowUnfree || versionLessThan1_6 version) versions.latest;
4654
};
4755
releases = import ./lib/releases.nix {
48-
inherit pkgs pkgs-unstable; custom-lib = self.lib;
56+
inherit pkgs-1_0 pkgs-1_6 pkgs-1_9; custom-lib = self.lib;
4957
releases = filteredVersions.releases;
5058
silenceWarnings = flakeConfig.nixpkgs-terraform.silenceWarnings;
5159
};

lib/build-terraform.nix

+11-5
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,22 @@
1-
{ pkgs, pkgs-unstable, version, hash, vendorHash, silenceWarnings ? false }:
1+
{ pkgs-1_0, pkgs-1_6, pkgs-1_9, version, hash, vendorHash, silenceWarnings ? false }:
22
# https://www.hashicorp.com/blog/hashicorp-adopts-business-source-license
3-
if builtins.compareVersions version "1.6.0" >= 0
3+
if builtins.compareVersions version "1.9.0" >= 0
44
then
5-
# https://github.com/NixOS/nixpkgs/blob/nixpkgs-unstable/pkgs/applications/networking/cluster/terraform/default.nix
6-
(pkgs.lib.warnIf (! silenceWarnings) ("allowUnfree is enabled to build version " + version) pkgs-unstable.mkTerraform
5+
(pkgs-1_9.lib.warnIf (! silenceWarnings) ("allowUnfree is enabled to build version " + version) pkgs-1_9.mkTerraform
6+
{
7+
inherit version hash vendorHash;
8+
patches = [ ../patches/provider-path-1_9.patch ];
9+
})
10+
else if builtins.compareVersions version "1.6.0" >= 0
11+
then
12+
(pkgs-1_6.lib.warnIf (! silenceWarnings) ("allowUnfree is enabled to build version " + version) pkgs-1_6.mkTerraform
713
{
814
inherit version hash vendorHash;
915
patches = [ ../patches/provider-path-0_15.patch ];
1016
})
1117
else
1218
# https://github.com/NixOS/nixpkgs/blob/nixos-23.05/pkgs/applications/networking/cluster/terraform/default.nix
13-
(pkgs.mkTerraform {
19+
(pkgs-1_0.mkTerraform {
1420
inherit version hash vendorHash;
1521
patches = [ ../patches/provider-path-0_15.patch ];
1622
})

lib/releases.nix

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
{ custom-lib, pkgs, pkgs-unstable, releases, silenceWarnings }:
1+
{ custom-lib, pkgs-1_0, pkgs-1_6, pkgs-1_9, releases, silenceWarnings }:
22
builtins.mapAttrs
33
(version: { hash, vendorHash }: custom-lib.buildTerraform {
4-
inherit pkgs pkgs-unstable version hash vendorHash silenceWarnings;
4+
inherit pkgs-1_0 pkgs-1_6 pkgs-1_9 version hash vendorHash silenceWarnings;
55
})
66
releases

patches/provider-path-1_9.patch

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
diff -Naur terraform.old/internal/command/init.go terraform.new/internal/command/init.go
2+
--- terraform.old/internal/command/init.go
3+
+++ terraform.new/internal/command/init.go
4+
@@ -7,6 +7,7 @@
5+
"context"
6+
"errors"
7+
"fmt"
8+
+ "os"
9+
"log"
10+
"reflect"
11+
"sort"
12+
@@ -77,6 +78,11 @@
13+
// -force-copy implies -migrate-state
14+
if c.forceInitCopy {
15+
c.migrateState = true
16+
+ }
17+
+
18+
+ val, ok := os.LookupEnv("NIX_TERRAFORM_PLUGIN_DIR")
19+
+ if ok {
20+
+ initArgs.PluginPath = append(initArgs.PluginPath, val)
21+
}
22+
23+
if len(initArgs.PluginPath) > 0 {

versions.json

+14-1
Original file line numberDiff line numberDiff line change
@@ -311,6 +311,18 @@
311311
"1.8.5": {
312312
"hash": "sha256-5PzP0LUJPpOQQ8YqwBFyEFcsHF2O1uDD8Yh8wB3uJ8s=",
313313
"vendorHash": "sha256-PXA2AWq1IFmnqhhU92S9UaIYTUAAn5lsg3S7h5hBOQE="
314+
},
315+
"1.9.0": {
316+
"hash": "sha256-mxnRQkwUcWCYmk4QUbAb5UKs9zXrW0qlvPLkVidaeUs=",
317+
"vendorHash": "sha256-pKez3etNpwPU/pRjIzsVBXRjtqLYjnoYghBqFYYDfPU="
318+
},
319+
"1.9.1": {
320+
"hash": "sha256-WqcrjKzaJShEFyHeZD4N9pPG2G2tDicQ4e05rt40o00=",
321+
"vendorHash": "sha256-cPWJtrGad8VsvyjJHQwpfDitsJY/Q0iCtp1MRyzGT+U="
322+
},
323+
"1.9.2": {
324+
"hash": "sha256-g1CsDWjwjBVfSNFZ9PRGlPlJOrqXP2eMYk1P+ohtYNU=",
325+
"vendorHash": "sha256-cPWJtrGad8VsvyjJHQwpfDitsJY/Q0iCtp1MRyzGT+U="
314326
}
315327
},
316328
"latest": {
@@ -322,6 +334,7 @@
322334
"1.5": "1.5.7",
323335
"1.6": "1.6.6",
324336
"1.7": "1.7.5",
325-
"1.8": "1.8.5"
337+
"1.8": "1.8.5",
338+
"1.9": "1.9.2"
326339
}
327340
}

0 commit comments

Comments
 (0)