;;; Copyright (C) 2023, 2024, 2025 David Thompson <dave@spritely.institute>
;;; Copyright (C) 2023, 2024, 2025 Igalia, S.L.
;;;
;;; Licensed under the Apache License, Version 2.0 (the "License");
;;; you may not use this file except in compliance with the License.
;;; You may obtain a copy of the License at
;;;
;;;    http://www.apache.org/licenses/LICENSE-2.0
;;;
;;; Unless required by applicable law or agreed to in writing, software
;;; distributed under the License is distributed on an "AS IS" BASIS,
;;; WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
;;; See the License for the specific language governing permissions and
;;; limitations under the License.

(use-modules (guix)
             (guix build-system gnu)
             (guix git)
             (guix git-download)
             ((guix licenses) #:prefix license:)
             (guix packages)
             (gnu packages autotools)
             (gnu packages guile)
             (gnu packages guile-xyz)
             (gnu packages node)
             (gnu packages pkg-config)
             (gnu packages texinfo)
             (gnu packages tls))

;; Uncomment and update when we need a fresher Guile than what Guix
;; provides.
;;
;; (define guile-next-next
;;   (let ((commit "c8a169d38825d5a21da5392b355ca5fc9f33fa55")
;;         (revision "1"))
;;     (package
;;      (inherit guile-next)
;;      (version (git-version "3.0.10" revision commit))
;;      (source
;;       (origin
;;        (method git-fetch)
;;        (uri (git-reference
;;              (url "https://codeberg.org/guile/guile.git")
;;              (commit commit)))
;;        (file-name (git-file-name "guile" version))
;;        (sha256
;;         (base32 "01gqf6c9rnr5l8qralfwq23xmfxbnim1kqppgrd2l42pak3rm9c2")))))))

(define guile-websocket*
  (package
    (inherit guile-websocket)
    (version "0.3.0")
    (source
     (origin
       (method git-fetch)
       (uri (git-reference
              (url "https://git.dthompson.us/guile-websocket.git")
              (commit (string-append "v" version))))
       (file-name (git-file-name "guile-websocket" version))
       (sha256
        (base32 "0hiyfq8igkfck655pz3236fdggms2vz89nn2s0chaspldqzwilsv"))))))

(package
  (name "guile-hoot")
  (version "0.8.0-git")
  (source (git-checkout (url (dirname (current-filename)))))
  (build-system gnu-build-system)
  (arguments
   '(#:make-flags '("GUILE_AUTO_COMPILE=0")))
  (native-inputs
   (list autoconf automake guile-syntax-highlight pkg-config texinfo))
  (inputs
   (list guile-next guile-fibers guile-gnutls guile-websocket* node))
  (synopsis "WebAssembly compiler for Guile Scheme")
  (description "Guile-hoot is an ahead-of-time, whole-program WebAssembly compiler for
GNU Guile.")
  (home-page "https://spritely.institute/hoot")
  (license (list license:asl2.0 license:lgpl3+)))
