From 9915757715c96e0643bd5bd0dff466a1d9c652a7 Mon Sep 17 00:00:00 2001 From: "Collin J. Doering" Date: Mon, 6 Dec 2021 14:37:34 -0500 Subject: [PATCH] rekahsoft-gnu: Patch terraform sources to read GUIX_TERRAFORM_PLUGIN_DIR variable Additionally, propagate the GUIX_TERRAFORM_PLUGIN_DIR variable so that only guix installed terraform providers can be used. This has the effect of disabling automatic fetching of terraform providers, which may be inconvenient to those who are not expecting this behavior. On Nix, this is resolved by not using a shim shell script that sets this variable when no terraform providers are installed. This approach doesn't work very well on guix, so in the future separate packages which inherit from the existing terraform packages but do not set this environment variable may be provided. --- .../patches/terraform-provider-path.patch | 16 ++++++++++++++++ rekahsoft-gnu/packages/terraform.scm | 18 +++++++++++++++++- 2 files changed, 33 insertions(+), 1 deletion(-) create mode 100644 rekahsoft-gnu/packages/patches/terraform-provider-path.patch diff --git a/rekahsoft-gnu/packages/patches/terraform-provider-path.patch b/rekahsoft-gnu/packages/patches/terraform-provider-path.patch new file mode 100644 index 0000000..4f22ba3 --- /dev/null +++ b/rekahsoft-gnu/packages/patches/terraform-provider-path.patch @@ -0,0 +1,16 @@ +diff --git a/command/init.go b/command/init.go +index 403ca245b..05d98329a 100644 +--- a/command/init.go ++++ b/command/init.go +@@ -64,6 +64,11 @@ func (c *InitCommand) Run(args []string) int { + return 1 + } + ++ val, ok := os.LookupEnv("GUIX_TERRAFORM_PLUGIN_DIR") ++ if ok { ++ flagPluginPath = append(flagPluginPath, val) ++ } ++ + if len(flagPluginPath) > 0 { + c.pluginPath = flagPluginPath + c.getPlugins = false diff --git a/rekahsoft-gnu/packages/terraform.scm b/rekahsoft-gnu/packages/terraform.scm index 6e788cc..78980eb 100644 --- a/rekahsoft-gnu/packages/terraform.scm +++ b/rekahsoft-gnu/packages/terraform.scm @@ -18,6 +18,7 @@ (define-module (rekahsoft-gnu packages terraform) #:use-module ((guix licenses) #:prefix license:) + #:use-module (gnu packages) #:use-module (gnu packages golang) #:use-module (guix utils) #:use-module (guix packages) @@ -27,6 +28,14 @@ #:use-module (guix build-system trivial) #:use-module (rekahsoft-gnu packages golang)) +(define (search-rekahsoft-gnu-patches patch) + (parameterize + ((%patch-path + (map (lambda (directory) + (string-append directory "/rekahsoft-gnu/packages/patches")) + %load-path))) + (search-patches patch))) + ;; TODO: Uses vendored dependencies (define-public terraform-0.13 (package @@ -37,6 +46,7 @@ (uri (git-reference (url "https://github.com/hashicorp/terraform") (commit (string-append "v" version)))) + (patches (search-rekahsoft-gnu-patches "terraform-provider-path.patch")) (file-name (git-file-name name version)) (sha256 (base32 @@ -53,7 +63,11 @@ (variable "SSL_CERT_FILE") (file-type 'regular) (separator #f) ;single entry - (files '("etc/ssl/certs/ca-certificates.crt"))))) + (files '("etc/ssl/certs/ca-certificates.crt"))) + (search-path-specification + (variable "GUIX_TERRAFORM_PLUGIN_DIR") + (separator #f) ;single entry + (files '("libexec/terraform"))))) (arguments `(#:import-path "github.com/hashicorp/terraform" #:install-source? #f @@ -106,6 +120,7 @@ popular service providers as well as custom in-house solutions.") (uri (git-reference (url "https://github.com/hashicorp/terraform") (commit (string-append "v" version)))) + (patches (search-rekahsoft-gnu-patches "terraform-provider-path.patch")) (file-name (git-file-name name version)) (sha256 (base32 @@ -120,6 +135,7 @@ popular service providers as well as custom in-house solutions.") (uri (git-reference (url "https://github.com/hashicorp/terraform") (commit (string-append "v" version)))) + (patches (search-rekahsoft-gnu-patches "terraform-provider-path.patch")) (file-name (git-file-name name version)) (sha256 (base32