guix.scm 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. ;; -*- geiser-scheme-implementation: guile -*-
  2. ;;; guix.scm -- Guix package definition
  3. ;;; guile-semver --- Semantic Versioning tooling for guile
  4. ;;; Copyright © 2017 Jelle Dirk Licht <jlicht@fsfe.org>
  5. ;;; Also borrowing code from:
  6. ;;; guile-sdl2 --- FFI bindings for SDL2
  7. ;;; Copyright © 2015 David Thompson <davet@gnu.org>
  8. ;;; Mes --- Maxwell Equations of Software
  9. ;;; Copyright © 2016,2017,2018 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
  10. ;;;
  11. ;;; guix.scm: This file is part of guile-semver.
  12. ;;;
  13. ;;; guile-semver is free software; you can redistribute it and/or modify it
  14. ;;; under the terms of the GNU General Public License as published by the Free
  15. ;;; Software Foundation; either version 3 of the License, or (at your option)
  16. ;;; any later version.
  17. ;;;
  18. ;;; guile-semver is distributed in the hope that it will be useful, but
  19. ;;; WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
  20. ;;; or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
  21. ;;; for more details.
  22. ;;;
  23. ;;; You should have received a copy of the GNU General Public License along
  24. ;;; with guile-semver. If not, see <http://www.gnu.org/licenses/>.
  25. ;;; Commentary:
  26. ;;
  27. ;; GNU Guix development package. To build and install, run:
  28. ;;
  29. ;; guix package -f guix.scm
  30. ;;
  31. ;; To build it, but not install it, run:
  32. ;;
  33. ;; guix build -f guix.scm
  34. ;;
  35. ;; To use as the basis for a development environment, run:
  36. ;;
  37. ;; guix environment -l guix.scm
  38. ;;
  39. ;;; Code:
  40. (use-modules (srfi srfi-1)
  41. (srfi srfi-26)
  42. (ice-9 match)
  43. (ice-9 popen)
  44. (ice-9 rdelim)
  45. (guix build utils)
  46. (guix build-system gnu)
  47. (guix download)
  48. (guix gexp)
  49. (guix git-download)
  50. (guix licenses)
  51. (guix packages)
  52. (gnu packages)
  53. (gnu packages autotools)
  54. (gnu packages base)
  55. (gnu packages code)
  56. (gnu packages guile)
  57. (gnu packages pkg-config)
  58. (gnu packages texinfo))
  59. (define %source-dir (dirname (current-filename)))
  60. ;; TODO: create utility function using guile-git
  61. (define git-file?
  62. (let* ((pipe (with-directory-excursion %source-dir
  63. (open-pipe* OPEN_READ "git" "ls-files")))
  64. (files (let loop ((lines '()))
  65. (match (read-line pipe)
  66. ((? eof-object?)
  67. (reverse lines))
  68. (line
  69. (loop (cons line lines))))))
  70. (status (close-pipe pipe)))
  71. (lambda (file stat)
  72. (match (stat:type stat)
  73. ('directory #t)
  74. ((or 'regular 'symlink)
  75. (any (cut string-suffix? <> file) files))
  76. (_ #f)))))
  77. (define-public guile-semver
  78. (let ((commit "aacff7326f27830ac0f3bad064888909a4c170b8")
  79. (revision "0")
  80. (version "0.1.0"))
  81. (package
  82. (name "guile-semver")
  83. (version (string-append version "-" revision "." (string-take commit 7)))
  84. (source (local-file %source-dir
  85. #:recursive? #t
  86. #:select? (git-predicate %source-dir)))
  87. (source #f)
  88. (build-system gnu-build-system)
  89. (arguments
  90. '(#:phases
  91. (modify-phases %standard-phases
  92. (add-after 'unpack 'bootstrap
  93. (lambda _ (invoke "sh" "bootstrap.sh"))))))
  94. (native-inputs
  95. `(("pkg-config" ,pkg-config)
  96. ("autoconf" ,autoconf)
  97. ("lcov" ,lcov) ; For generating test coverage data
  98. ("automake" ,automake)
  99. ("texinfo" ,texinfo)))
  100. (inputs
  101. `(("guile" ,guile-2.2)))
  102. (home-page "https://git.fsfe.org/jlicht/guile-semver")
  103. (synopsis "Semantic Versioning tooling for Guile")
  104. (description "guile-semver provides similar tooling to the node semver
  105. package for reading and manipulating datums coforming to the Semantic versioning
  106. standard.")
  107. (license gpl3+))))
  108. (define-public guile-semver.git
  109. (let ((version "0.1.0")
  110. (revision "0")
  111. (commit (read-string (open-pipe "git show HEAD | head -1 | cut -d ' ' -f 2" OPEN_READ))))
  112. (package
  113. (inherit guile-semver)
  114. (name "guile-semver.git")
  115. (version (string-append version "-" revision "." (string-take commit 7)))
  116. (source (local-file %source-dir #:recursive? #t #:select? git-file?)))))
  117. guile-semver.git