guix.scm 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. ;;; guix.scm --- Guix package for Guile-XOSD
  2. ;; Copyright © 2016–2017, 2021 Alex Kost <alezost@gmail.com>
  3. ;; This file is part of Guile-XOSD.
  4. ;; Guile-XOSD is free software; you can redistribute it and/or modify
  5. ;; it under the terms of the GNU General Public License as published by
  6. ;; the Free Software Foundation, either version 3 of the License, or
  7. ;; (at your option) any later version.
  8. ;;
  9. ;; Guile-XOSD is distributed in the hope that it will be useful,
  10. ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. ;; GNU General Public License for more details.
  13. ;;
  14. ;; You should have received a copy of the GNU General Public License
  15. ;; along with Guile-XOSD. If not, see <http://www.gnu.org/licenses/>.
  16. ;;; Commentary:
  17. ;; This file contains Guix package for development version of
  18. ;; Guile-XOSD. To build or install, run:
  19. ;;
  20. ;; guix build --file=guix.scm
  21. ;; guix package --install-from-file=guix.scm
  22. ;; Also you can use this file to make a development environment for
  23. ;; building Guile-XOSD:
  24. ;;
  25. ;; guix environment --pure --load=guix.scm
  26. ;; ./autogen.sh
  27. ;; ./configure
  28. ;; make
  29. ;;; Code:
  30. (use-modules
  31. (ice-9 match)
  32. (ice-9 popen)
  33. (ice-9 rdelim)
  34. (srfi srfi-1)
  35. (srfi srfi-26)
  36. (guix gexp)
  37. (guix packages)
  38. (guix build utils)
  39. (gnu packages autotools)
  40. (gnu packages guile)
  41. (gnu packages texinfo))
  42. ;; The code for finding git files is based on
  43. ;; <https://git.dthompson.us/guile-sdl2.git/blob/HEAD:/guix.scm>.
  44. (define %source-dir (dirname (current-filename)))
  45. (define (git-output . args)
  46. "Execute 'git ARGS ...' command and return its output without trailing
  47. newspace."
  48. (with-directory-excursion %source-dir
  49. (let* ((port (apply open-pipe* OPEN_READ "git" args))
  50. (output (read-string port)))
  51. (close-pipe port)
  52. (string-trim-right output #\newline))))
  53. (define (git-files)
  54. "Return a list of all git-controlled files."
  55. (string-split (git-output "ls-files") #\newline))
  56. (define git-file?
  57. (let ((files (git-files)))
  58. (lambda (file stat)
  59. "Return #t if FILE is the git-controlled file in '%source-dir'."
  60. (match (stat:type stat)
  61. ('directory #t)
  62. ((or 'regular 'symlink)
  63. (any (cut string-suffix? <> file) files))
  64. (_ #f)))))
  65. (define (current-commit)
  66. (git-output "log" "-n" "1" "--pretty=format:%H"))
  67. (define guile-xosd-devel
  68. (let ((commit (current-commit)))
  69. (package
  70. (inherit guile-xosd)
  71. (version (string-append (package-version guile-xosd)
  72. "-" (string-take commit 7)))
  73. (source (local-file %source-dir
  74. #:recursive? #t
  75. #:select? git-file?))
  76. (arguments
  77. '(#:phases
  78. (modify-phases %standard-phases
  79. (add-after 'unpack 'autogen
  80. (lambda _ (zero? (system* "sh" "autogen.sh")))))))
  81. (native-inputs
  82. (append (package-native-inputs guile-xosd)
  83. `(("autoconf" ,autoconf)
  84. ("automake" ,automake)
  85. ("libtool" ,libtool)
  86. ("texinfo" ,texinfo)))))))
  87. guile-xosd-devel
  88. ;;; guix.scm ends here