diff options
| author | Oleg Pykhalov <go.wigust@gmail.com> | 2019-01-04 14:27:30 +0300 |
|---|---|---|
| committer | Oleg Pykhalov <go.wigust@gmail.com> | 2019-01-04 14:51:59 +0300 |
| commit | 83b4647ef84781cd6630e053589ddc101f840289 (patch) | |
| tree | d41915a957e17facfbbc65294b6922c1630df3c3 /guix.scm | |
| download | zabbix-guix-83b4647ef84781cd6630e053589ddc101f840289.tar.gz | |
Initial commit.
* guix.scm: New file.
* zabbix.scm: New file.
* zabbix_guix: New file.
Diffstat (limited to 'guix.scm')
| -rw-r--r-- | guix.scm | 104 |
1 files changed, 104 insertions, 0 deletions
diff --git a/guix.scm b/guix.scm new file mode 100644 index 0000000..9fddd7f --- /dev/null +++ b/guix.scm @@ -0,0 +1,104 @@ +;; guix.scm --- Guix package for Zabbix-Guix +;; Copyright © 2019 Oleg Pykhalov <go.wigust@gmail.com> +;; Released under the GNU GPLv3 or any later version. + +(use-modules ((guix licenses) #:prefix license:) + (guix build-system guile) + (guix build utils) + (guix packages) + (guix gexp) + (guix git-download) + (ice-9 popen) + (ice-9 rdelim) + (gnu packages bash) + (gnu packages guile) + (gnu packages package-management)) + +(define %source-dir (dirname (current-filename))) + +(define (git . args) + "Execute 'git ARGS ...' command and return its output without trailing +newspace." + (with-directory-excursion %source-dir + (let* ((port (apply open-pipe* OPEN_READ "git" args)) + (output (read-string port))) + (close-port port) + (string-trim-right output #\newline)))) + +(let ((commit (git "log" "-n" "1" "--pretty=format:%H"))) + (package + (name "zabbix-guix") + (version (string-append "0.0.1" "-" (string-take commit 7))) + (source (local-file %source-dir + #:recursive? #t + #:select? (git-predicate %source-dir))) + (build-system guile-build-system) + (inputs + `(("bash" ,bash))) + (native-inputs + `(("guile" ,guile-2.2) + ("guile-json" ,guile-json) + ("guix" ,guix) + ,@(package-propagated-inputs guix))) + (arguments + `(#:modules ((guix build guile-build-system) + (guix build utils) + (srfi srfi-26) + (ice-9 popen) + (ice-9 rdelim)) + #:phases + (modify-phases %standard-phases + (replace 'unpack + (lambda* (#:key inputs #:allow-other-keys) + (for-each (lambda (file) + (copy-file (string-append (assoc-ref inputs "source") "/" file) + (string-append "./" file))) + '("zabbix_guix" "zabbix.scm")))) + (add-after 'unpack 'setenv + (lambda _ + (setenv "PATH" + (string-append (assoc-ref %build-inputs "bash") "/bin" ":" + (getenv "PATH"))))) + (add-after 'install 'install-script + (lambda* (#:key inputs outputs #:allow-other-keys) + (let* ((out (assoc-ref outputs "out")) + (bin (string-append out "/bin")) + (zabbix-guix (string-append bin "/zabbix_guix")) + (guile (assoc-ref inputs "guile")) + (guile-bin (string-append guile "/bin/guile")) + (git (assoc-ref inputs "guile-git")) + (bs (assoc-ref inputs "guile-bytestructures")) + (gcrypt (assoc-ref inputs "guile-gcrypt")) + (json (assoc-ref inputs "guile-json")) + (guix (assoc-ref inputs "guix")) + (deps (list out gcrypt json bs git guix)) + (effective + (read-line + (open-pipe* OPEN_READ guile-bin + "-c" "(display (effective-version))"))) + (path (string-join + (map (cut string-append <> + "/share/guile/site/" + effective) + deps) + ":")) + (gopath (string-join + (map (cut string-append <> + "/lib/guile/" effective + "/site-ccache") + deps) + ":"))) + (mkdir-p bin) + (substitute* "./zabbix_guix" + (("\\$\\(which guile\\)") guile-bin)) + (install-file "./zabbix_guix" bin) + (chmod zabbix-guix #o555) + (wrap-program zabbix-guix + `("GUILE_LOAD_PATH" ":" prefix (,path)) + `("GUILE_LOAD_COMPILED_PATH" ":" prefix (,gopath))) + #t)))))) + (home-page "https://anongit.duckdns.org/guix/zabbix-guix") + (description "This package provides a Guile script to monitor Guix +channels difference.") + (synopsis "Monitor Guix in Zabbix") + (license license:gpl3+))) |
