guix.scm 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. ;;;; guix.scm -- Guix package definition
  2. ;;; Copyright © 2016 Jan Nieuwenhuizen <janneke@gnu.org>
  3. ;;; Copyright © 2016, 2017 Mathieu Lirzin <mthl@gnu.org>
  4. ;;;
  5. ;;; This file is part of Cuirass.
  6. ;;;
  7. ;;; Cuirass is free software: you can redistribute it and/or modify
  8. ;;; it under the terms of the GNU General Public License as published by
  9. ;;; the Free Software Foundation, either version 3 of the License, or
  10. ;;; (at your option) any later version.
  11. ;;;
  12. ;;; Cuirass is distributed in the hope that it will be useful,
  13. ;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. ;;; GNU General Public License for more details.
  16. ;;;
  17. ;;; You should have received a copy of the GNU General Public License
  18. ;;; along with Cuirass. If not, see <http://www.gnu.org/licenses/>.
  19. (use-modules (ice-9 popen)
  20. (ice-9 rdelim)
  21. (gnu)
  22. (guix)
  23. (srfi srfi-1))
  24. (define (keep-cuirass-file? file stat)
  25. ;; Return #t if FILE in Cuirass repository must be kept, #f otherwise. FILE
  26. ;; is an absolute file name and STAT is the result of 'lstat' applied to
  27. ;; FILE.
  28. (not (or (any (lambda (str) (string-contains file str))
  29. '(".git" "autom4te" "Makefile.in" ".go" ".log"
  30. "stamp-vti" ".dirstamp"))
  31. (any (lambda (str) (string-suffix? str file))
  32. '("trs""configure" "Makefile" "config.status" "pre-inst-env"
  33. "aclocal.m4" "bin/cuirass" "bin/evaluate" "config.cache"
  34. "guix.scm")))))
  35. (define %aux-dir
  36. (current-source-directory))
  37. (define %srcdir
  38. (dirname %aux-dir))
  39. (define (git-version-gen)
  40. ;; Return a string containing Cuirass version number.
  41. (let* ((cmd "git-version-gen .tarball-version")
  42. (port (open-input-pipe (string-append %aux-dir "/" cmd)))
  43. (str (read-line port)))
  44. (close-pipe port)
  45. str))
  46. (define (spec+package-list spec)
  47. (list spec (specification->package spec)))
  48. (package
  49. (inherit (specification->package "cuirass"))
  50. (version (git-version-gen))
  51. (source (local-file %srcdir #:recursive? #t
  52. #:select? keep-cuirass-file?))
  53. (arguments
  54. '(#:phases
  55. (modify-phases %standard-phases
  56. (add-before 'configure 'bootstrap
  57. (lambda _ (zero? (system* "sh" "bootstrap"))))
  58. (add-after 'install 'wrap-program
  59. (lambda* (#:key inputs outputs #:allow-other-keys)
  60. ;; Wrap the 'cuirass' command to refer to the right modules.
  61. (let* ((out (assoc-ref outputs "out"))
  62. (json (assoc-ref inputs "guile-json"))
  63. (squee (assoc-ref inputs "guile-squee"))
  64. (zlib (assoc-ref inputs "guile-zlib"))
  65. (guix (assoc-ref inputs "guix"))
  66. (mods (string-append json "/share/guile/site/3.0:"
  67. squee "/share/guile/site/3.0:"
  68. zlib "/share/guile/site/3.0:"
  69. guix "/share/guile/site/3.0")))
  70. (wrap-program (string-append out "/bin/cuirass")
  71. `("GUILE_LOAD_PATH" ":" prefix (,mods))
  72. `("GUILE_LOAD_COMPILED_PATH" ":" prefix (,mods)))))))))
  73. (inputs
  74. (map spec+package-list
  75. '("guile"
  76. "guile-fibers"
  77. "guile-json"
  78. "guile-squee"
  79. "guile-git"
  80. "guile-zlib"
  81. "guix")))
  82. (native-inputs
  83. (map spec+package-list
  84. '("autoconf"
  85. "automake"
  86. "bash"
  87. "pkg-config"
  88. "texinfo"))))