diff --git a/rekahsoft-gnu/packages/terraform.scm b/rekahsoft-gnu/packages/terraform.scm index 97460b7..205a9d9 100644 --- a/rekahsoft-gnu/packages/terraform.scm +++ b/rekahsoft-gnu/packages/terraform.scm @@ -19,6 +19,7 @@ (define-module (rekahsoft-gnu packages terraform) #:use-module ((guix licenses) #:prefix license:) #:use-module (gnu packages golang) + #:use-module (guix utils) #:use-module (guix packages) #:use-module (guix download) #:use-module (guix git-download) @@ -30,6 +31,12 @@ (package (name "terraform") (version "0.12.30") + +;; TODO: Uses vendored dependencies +(define-public terraform-0.13 + (package + (name "terraform") + (version "0.13.6") (source (origin (method git-fetch) (uri (git-reference @@ -38,35 +45,45 @@ (file-name (git-file-name name version)) (sha256 (base32 - "0mv2nsy2ygb1kgkw98xckihcdqxpzhdmks5p2gi2l7wb7lx51yz2")))) + "1mvxjn1mpc32xq1ax521wa49m5gj5hvdajmb7q4i8sjiqf49213j")))) (build-system go-build-system) (native-inputs `(("go-gox" ,go-github-com-mitchellh-gox))) (arguments `(#:import-path "github.com/hashicorp/terraform" #:install-source? #f - #:phases (modify-phases %standard-phases - (replace 'build - (lambda _ - (with-directory-excursion "src/github.com/hashicorp/terraform" - (setenv "TF_RELEASE" "") - (setenv "XC_OS" "linux") - (setenv "XC_ARCH" - (let ((system ,(or (%current-target-system) - (%current-system)))) - (cond - ((string-prefix? "x86_64" system) - "amd64") - ((string-prefix? "i686" system) - "386") - (else "")))) - (invoke "./scripts/build.sh")))) - (replace 'install - (lambda* (#:key outputs #:allow-other-keys) - (let ((out (assoc-ref outputs "out"))) - (with-directory-excursion "src/github.com/hashicorp/terraform" - (rename-file "bin/terraform" "bin/terraform-0.12") - (copy-recursively "bin" (string-append out "/bin"))))))))) + #:modules ((guix build go-build-system) + (guix build utils) + (srfi srfi-1)) + #:phases + (modify-phases %standard-phases + (replace 'build + (lambda _ + (with-directory-excursion "src/github.com/hashicorp/terraform" + (setenv "TF_RELEASE" "") + (setenv "XC_OS" "linux") + (setenv "XC_ARCH" + (let ((system ,(or (%current-target-system) + (%current-system)))) + (cond + ((string-prefix? "x86_64" system) + "amd64") + ((string-prefix? "i686" system) + "386") + (else "")))) + (invoke "./scripts/build.sh")))) + (replace 'install + (lambda* (#:key outputs #:allow-other-keys) + (let* ((out (assoc-ref outputs "out")) + (bin (string-append out "/bin")) + (version (last (string-split out #\-))) + (components (string-split version #\.)) + (major+minor (take components 2)) + (executable (string-append "terraform-" (string-join major+minor ".")))) + (with-directory-excursion "src/github.com/hashicorp/terraform/bin" + (rename-file "terraform" executable) + (install-file executable bin) + #t))))))) (synopsis "Safely and predictably create, change, and improve infrastructure") (description "Terraform is a tool for building, changing, and versioning @@ -75,6 +92,34 @@ popular service providers as well as custom in-house solutions.") (home-page "https://github.com/hashicorp/terraform") (license license:mpl2.0))) +(define-public terraform-0.12 + (package/inherit terraform-0.13 + (name "terraform") + (version "0.12.30") + (source (origin + (method git-fetch) + (uri (git-reference + (url "https://github.com/hashicorp/terraform") + (commit (string-append "v" version)))) + (file-name (git-file-name name version)) + (sha256 + (base32 + "0mv2nsy2ygb1kgkw98xckihcdqxpzhdmks5p2gi2l7wb7lx51yz2")))))) + +(define-public terraform-0.11 + (package/inherit terraform-0.13 + (name "terraform") + (version "0.11.14") + (source (origin + (method git-fetch) + (uri (git-reference + (url "https://github.com/hashicorp/terraform") + (commit (string-append "v" version)))) + (file-name (git-file-name name version)) + (sha256 + (base32 + "1bzz5wy13gh8j47mxxp6ij6yh20xmxd9n5lidaln3mf1bil19dmc")))))) + (define* (wrap-terraform terraform #:optional (name (string-append (package-name terraform) "-wrapper"))) @@ -85,71 +130,31 @@ popular service providers as well as custom in-house solutions.") (outputs '("out")) (propagated-inputs `(("terraform" ,terraform))) (arguments - `(#:modules ((guix build utils)) + `(#:modules ((guix build utils) + (srfi srfi-1)) #:builder (begin - (use-modules (guix build utils)) - (let ((bin (string-append (assoc-ref %outputs "out") "/bin")) - (terraform (string-append (assoc-ref %build-inputs "terraform") "/bin/"))) + (use-modules (guix build utils) + (srfi srfi-1)) + (let* ((out (assoc-ref %outputs "out")) + (bin (string-append out "/bin")) + (terraform (string-append (assoc-ref %build-inputs "terraform") "/bin/")) + (version (last (string-split out #\-))) + (components (string-split version #\.)) + (major+minor (take components 2))) (mkdir-p bin) - (symlink (string-append terraform "terraform-0.12") + (symlink (string-append terraform "terraform-" (string-join major+minor ".")) (string-append bin "/" "terraform")) #t)))) - (synopsis "Wrapper for the terraform 0.12 commands") + (synopsis "Wrapper for terraform commands") (description - "This package provides wrappers for the commands of Terraform@tie{}0.12.x such + "This package provides wrappers for the commands of Terraform@tie{}MAJOR.MINOR.x such that they can be invoked under their usual name---e.g., @command{terraform} -instead of @command{terraform-0.12}."))) +instead of @command{terraform-MAJOR.MINOR}."))) -(define-public terraform-wrapper (wrap-terraform terraform)) - -(define-public terraform-0.11 - (package - (name "terraform0.11") - (version "0.11.14") - (source (origin - (method git-fetch) - (uri (git-reference - (url "https://github.com/hashicorp/terraform") - (commit (string-append "v" version)))) - (file-name (git-file-name name version)) - (sha256 - (base32 - "1bzz5wy13gh8j47mxxp6ij6yh20xmxd9n5lidaln3mf1bil19dmc")))) - (build-system go-build-system) - (native-inputs - `(("go-gox" ,go-github-com-mitchellh-gox))) - (arguments - `(#:import-path "github.com/hashicorp/terraform" - #:install-source? #f - #:phases (modify-phases %standard-phases - (replace 'build - (lambda _ - (with-directory-excursion "src/github.com/hashicorp/terraform" - (setenv "TF_RELEASE" "") - (setenv "XC_OS" "linux") - (setenv "XC_ARCH" - (let ((system ,(or (%current-target-system) - (%current-system)))) - (cond - ((string-prefix? "x86_64" system) - "amd64") - ((string-prefix? "i686" system) - "386") - (else "")))) - (invoke "./scripts/build.sh")))) - (replace 'install - (lambda* (#:key outputs #:allow-other-keys) - (let ((out (assoc-ref outputs "out"))) - (with-directory-excursion "src/github.com/hashicorp/terraform" - (copy-recursively "bin" (string-append out "/bin"))))))))) - (synopsis "Safely and predictably create, change, and improve infrastructure") - (description - "Terraform is a tool for building, changing, and versioning -infrastructure safely and efficiently. Terraform can manage existing and -popular service providers as well as custom in-house solutions.") - (home-page "https://github.com/hashicorp/terraform") - (license license:mpl2.0))) +(define-public terraform-wrapper-0.13 (wrap-terraform terraform-0.13)) +(define-public terraform-wrapper-0.12 (wrap-terraform terraform-0.12)) +(define-public terraform-wrapper-0.11 (wrap-terraform terraform-0.11)) (define terraform-provider-phases '(modify-phases %standard-phases