From ddbd7abbb2a5ccead1fb85832d82446575320806 Mon Sep 17 00:00:00 2001 From: Kiara Grouwstra Date: Fri, 14 Nov 2025 11:27:23 +0100 Subject: [PATCH] centralize TF providers (#586) Reviewed-on: https://git.fediversity.eu/fediversity/fediversity/pulls/586 --- deployment/check/data-model-tf/nixosTest.nix | 2 -- deployment/run/providers.nix | 35 ++++++++++++++++++++ deployment/run/tf-netbox-cluster-type/tf.nix | 20 +---------- deployment/run/tf-netbox-cluster/tf.nix | 20 +---------- deployment/run/tf-netbox-get-ip/tf.nix | 20 +---------- deployment/run/tf-netbox-store-ips/tf.nix | 20 +---------- deployment/run/tf-proxmox-template/tf.nix | 20 +---------- deployment/run/tf-proxmox-vm/tf.nix | 20 +---------- deployment/run/tf-single-host/tf.nix | 1 - 9 files changed, 41 insertions(+), 117 deletions(-) create mode 100644 deployment/run/providers.nix diff --git a/deployment/check/data-model-tf/nixosTest.nix b/deployment/check/data-model-tf/nixosTest.nix index 07581b9c..2b88431e 100644 --- a/deployment/check/data-model-tf/nixosTest.nix +++ b/deployment/check/data-model-tf/nixosTest.nix @@ -1,7 +1,6 @@ { lib, pkgs, - sources, modulesPath, ... }: @@ -34,7 +33,6 @@ in environment.systemPackages = [ deploy - (pkgs.callPackage ../../run/tf-single-host/tf.nix { inherit sources; }) ]; # needed only when building from deployer diff --git a/deployment/run/providers.nix b/deployment/run/providers.nix new file mode 100644 index 00000000..1aca2196 --- /dev/null +++ b/deployment/run/providers.nix @@ -0,0 +1,35 @@ +{ + pkgs, +}: +let + sources = import ../../npins; + mkProvider = + args: + pkgs.terraform-providers.mkProvider ( + { mkProviderFetcher = { repo, ... }: sources.${repo}; } // args + ); +in +{ + netbox = mkProvider { + owner = "e-breuninger"; + repo = "terraform-provider-netbox"; + rev = "v5.0.0"; + spdx = "MPL-2.0"; + # hash = "sha256-iCaCt8ZbkxCk43QEyj3PeHYuKPCPVU2oQ78aumH/l6k="; + hash = null; + vendorHash = "sha256-Q3H/6mpkWn1Gw0NRMtKtkBRGHjPJZGBFdGwfalyQ4Z0="; + homepage = "https://registry.terraform.io/providers/e-breuninger/netbox"; + provider-source-address = "registry.opentofu.org/e-breuninger/netbox"; + }; + proxmox = mkProvider { + owner = "bpg"; + repo = "terraform-provider-proxmox"; + # 0.82+ need go 1.25 + rev = "v0.81.0"; + spdx = "MPL-2.0"; + hash = null; + vendorHash = "sha256-cpei22LkKqohlE76CQcIL5d7p+BjNcD6UQ8dl0WXUOc="; + homepage = "https://registry.terraform.io/providers/bpg/proxmox"; + provider-source-address = "registry.opentofu.org/bpg/proxmox"; + }; +} diff --git a/deployment/run/tf-netbox-cluster-type/tf.nix b/deployment/run/tf-netbox-cluster-type/tf.nix index ec79dab2..b6040a69 100644 --- a/deployment/run/tf-netbox-cluster-type/tf.nix +++ b/deployment/run/tf-netbox-cluster-type/tf.nix @@ -1,24 +1,6 @@ { pkgs, }: -let - sources = import ../../../npins; - mkProvider = - args: - pkgs.terraform-providers.mkProvider ( - { mkProviderFetcher = { repo, ... }: sources.${repo}; } // args - ); -in (pkgs.callPackage ../../tf.nix { }).withPlugins (_: [ - (mkProvider { - owner = "e-breuninger"; - repo = "terraform-provider-netbox"; - rev = "v5.0.0"; - spdx = "MPL-2.0"; - # hash = "sha256-iCaCt8ZbkxCk43QEyj3PeHYuKPCPVU2oQ78aumH/l6k="; - hash = null; - vendorHash = "sha256-Q3H/6mpkWn1Gw0NRMtKtkBRGHjPJZGBFdGwfalyQ4Z0="; - homepage = "https://registry.terraform.io/providers/e-breuninger/netbox"; - provider-source-address = "registry.opentofu.org/e-breuninger/netbox"; - }) + (pkgs.callPackage ../providers.nix { }).netbox ]) diff --git a/deployment/run/tf-netbox-cluster/tf.nix b/deployment/run/tf-netbox-cluster/tf.nix index ec79dab2..b6040a69 100644 --- a/deployment/run/tf-netbox-cluster/tf.nix +++ b/deployment/run/tf-netbox-cluster/tf.nix @@ -1,24 +1,6 @@ { pkgs, }: -let - sources = import ../../../npins; - mkProvider = - args: - pkgs.terraform-providers.mkProvider ( - { mkProviderFetcher = { repo, ... }: sources.${repo}; } // args - ); -in (pkgs.callPackage ../../tf.nix { }).withPlugins (_: [ - (mkProvider { - owner = "e-breuninger"; - repo = "terraform-provider-netbox"; - rev = "v5.0.0"; - spdx = "MPL-2.0"; - # hash = "sha256-iCaCt8ZbkxCk43QEyj3PeHYuKPCPVU2oQ78aumH/l6k="; - hash = null; - vendorHash = "sha256-Q3H/6mpkWn1Gw0NRMtKtkBRGHjPJZGBFdGwfalyQ4Z0="; - homepage = "https://registry.terraform.io/providers/e-breuninger/netbox"; - provider-source-address = "registry.opentofu.org/e-breuninger/netbox"; - }) + (pkgs.callPackage ../providers.nix { }).netbox ]) diff --git a/deployment/run/tf-netbox-get-ip/tf.nix b/deployment/run/tf-netbox-get-ip/tf.nix index ec79dab2..b6040a69 100644 --- a/deployment/run/tf-netbox-get-ip/tf.nix +++ b/deployment/run/tf-netbox-get-ip/tf.nix @@ -1,24 +1,6 @@ { pkgs, }: -let - sources = import ../../../npins; - mkProvider = - args: - pkgs.terraform-providers.mkProvider ( - { mkProviderFetcher = { repo, ... }: sources.${repo}; } // args - ); -in (pkgs.callPackage ../../tf.nix { }).withPlugins (_: [ - (mkProvider { - owner = "e-breuninger"; - repo = "terraform-provider-netbox"; - rev = "v5.0.0"; - spdx = "MPL-2.0"; - # hash = "sha256-iCaCt8ZbkxCk43QEyj3PeHYuKPCPVU2oQ78aumH/l6k="; - hash = null; - vendorHash = "sha256-Q3H/6mpkWn1Gw0NRMtKtkBRGHjPJZGBFdGwfalyQ4Z0="; - homepage = "https://registry.terraform.io/providers/e-breuninger/netbox"; - provider-source-address = "registry.opentofu.org/e-breuninger/netbox"; - }) + (pkgs.callPackage ../providers.nix { }).netbox ]) diff --git a/deployment/run/tf-netbox-store-ips/tf.nix b/deployment/run/tf-netbox-store-ips/tf.nix index ec79dab2..b6040a69 100644 --- a/deployment/run/tf-netbox-store-ips/tf.nix +++ b/deployment/run/tf-netbox-store-ips/tf.nix @@ -1,24 +1,6 @@ { pkgs, }: -let - sources = import ../../../npins; - mkProvider = - args: - pkgs.terraform-providers.mkProvider ( - { mkProviderFetcher = { repo, ... }: sources.${repo}; } // args - ); -in (pkgs.callPackage ../../tf.nix { }).withPlugins (_: [ - (mkProvider { - owner = "e-breuninger"; - repo = "terraform-provider-netbox"; - rev = "v5.0.0"; - spdx = "MPL-2.0"; - # hash = "sha256-iCaCt8ZbkxCk43QEyj3PeHYuKPCPVU2oQ78aumH/l6k="; - hash = null; - vendorHash = "sha256-Q3H/6mpkWn1Gw0NRMtKtkBRGHjPJZGBFdGwfalyQ4Z0="; - homepage = "https://registry.terraform.io/providers/e-breuninger/netbox"; - provider-source-address = "registry.opentofu.org/e-breuninger/netbox"; - }) + (pkgs.callPackage ../providers.nix { }).netbox ]) diff --git a/deployment/run/tf-proxmox-template/tf.nix b/deployment/run/tf-proxmox-template/tf.nix index 880a56ff..55b4d974 100644 --- a/deployment/run/tf-proxmox-template/tf.nix +++ b/deployment/run/tf-proxmox-template/tf.nix @@ -1,25 +1,7 @@ { pkgs, }: -let - sources = import ../../../npins; - mkProvider = - args: - pkgs.terraform-providers.mkProvider ( - { mkProviderFetcher = { repo, ... }: sources.${repo}; } // args - ); -in (pkgs.callPackage ../../tf.nix { }).withPlugins (p: [ p.external - (mkProvider { - owner = "bpg"; - repo = "terraform-provider-proxmox"; - # 0.82+ need go 1.25 - rev = "v0.81.0"; - spdx = "MPL-2.0"; - hash = null; - vendorHash = "sha256-cpei22LkKqohlE76CQcIL5d7p+BjNcD6UQ8dl0WXUOc="; - homepage = "https://registry.terraform.io/providers/bpg/proxmox"; - provider-source-address = "registry.opentofu.org/bpg/proxmox"; - }) + (pkgs.callPackage ../providers.nix { }).proxmox ]) diff --git a/deployment/run/tf-proxmox-vm/tf.nix b/deployment/run/tf-proxmox-vm/tf.nix index b387cc6b..37458fee 100644 --- a/deployment/run/tf-proxmox-vm/tf.nix +++ b/deployment/run/tf-proxmox-vm/tf.nix @@ -1,26 +1,8 @@ { pkgs, }: -let - sources = import ../../../npins; - mkProvider = - args: - pkgs.terraform-providers.mkProvider ( - { mkProviderFetcher = { repo, ... }: sources.${repo}; } // args - ); -in (pkgs.callPackage ../../tf.nix { }).withPlugins (p: [ p.external p.null - (mkProvider { - owner = "bpg"; - repo = "terraform-provider-proxmox"; - # 0.82+ need go 1.25 - rev = "v0.81.0"; - spdx = "MPL-2.0"; - hash = null; - vendorHash = "sha256-cpei22LkKqohlE76CQcIL5d7p+BjNcD6UQ8dl0WXUOc="; - homepage = "https://registry.terraform.io/providers/bpg/proxmox"; - provider-source-address = "registry.opentofu.org/bpg/proxmox"; - }) + (pkgs.callPackage ../providers.nix { }).proxmox ]) diff --git a/deployment/run/tf-single-host/tf.nix b/deployment/run/tf-single-host/tf.nix index dd6bb141..f2fa0108 100644 --- a/deployment/run/tf-single-host/tf.nix +++ b/deployment/run/tf-single-host/tf.nix @@ -1,5 +1,4 @@ { pkgs, - ... }: (pkgs.callPackage ../../tf.nix { }).withPlugins (p: [ p.external ])