guix.scm 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. ;;; guix.scm --- Guix package for Emacs-Guix
  2. ;; Copyright © 2017 Alex Kost <alezost@gmail.com>
  3. ;; This file is part of Emacs-Guix.
  4. ;; Emacs-Guix 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. ;; Emacs-Guix 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 Emacs-Guix. If not, see <http://www.gnu.org/licenses/>.
  16. ;;; Commentary:
  17. ;; This file contains Guix package for development version of
  18. ;; Emacs-Guix. To build or install, run:
  19. ;;
  20. ;; guix build --file=guix.scm
  21. ;; guix package --install-from-file=guix.scm
  22. ;; The main purpose of this file though is to make a development
  23. ;; environment for building Emacs-Guix:
  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 emacs)
  41. (gnu packages pkg-config)
  42. (gnu packages texinfo))
  43. ;; The code for finding git files is based on
  44. ;; <https://git.dthompson.us/guile-sdl2.git/blob/HEAD:/guix.scm>.
  45. (define %source-dir (dirname (current-filename)))
  46. (define (git-output . args)
  47. "Execute 'git ARGS ...' command and return its output without trailing
  48. newspace."
  49. (with-directory-excursion %source-dir
  50. (let* ((port (apply open-pipe* OPEN_READ "git" args))
  51. (output (read-string port)))
  52. (close-port port)
  53. (string-trim-right output #\newline))))
  54. (define (git-files)
  55. "Return a list of all git-controlled files."
  56. (string-split (git-output "ls-files") #\newline))
  57. (define git-file?
  58. (let ((files (git-files)))
  59. (lambda (file stat)
  60. "Return #t if FILE is the git-controlled file in '%source-dir'."
  61. (match (stat:type stat)
  62. ('directory #t)
  63. ((or 'regular 'symlink)
  64. (any (cut string-suffix? <> file) files))
  65. (_ #f)))))
  66. (define (current-commit)
  67. (git-output "log" "-n" "1" "--pretty=format:%H"))
  68. (define emacs-guix-devel
  69. (let ((commit (current-commit)))
  70. (package
  71. (inherit emacs-guix)
  72. (version (string-append (package-version emacs-guix)
  73. "-" (string-take commit 7)))
  74. (source (local-file %source-dir
  75. #:recursive? #t
  76. #:select? git-file?))
  77. (arguments
  78. (append (package-arguments emacs-guix)
  79. '(#:phases
  80. (modify-phases %standard-phases
  81. (add-after 'unpack 'autogen
  82. (lambda _ (zero? (system* "sh" "autogen.sh"))))))))
  83. (native-inputs
  84. `(("pkg-config" ,pkg-config)
  85. ;; 'emacs-minimal' does not find Emacs packages (this is for
  86. ;; "guix environment").
  87. ("emacs" ,emacs-no-x)
  88. ("autoconf" ,autoconf)
  89. ("automake" ,automake)
  90. ("texinfo" ,texinfo))))))
  91. emacs-guix-devel
  92. ;;; guix.scm ends here