aboutsummaryrefslogtreecommitdiff
;;; GNU Guix --- Functional package management for GNU
;;; Copyright © 2018 Ricardo Wurmus <rekado@elephly.net>
;;; Copyright © 2019-2020, 2022, 2024 Ludovic Courtès <ludo@gnu.org>
;;;
;;; This file is part of GNU Guix.
;;;
;;; GNU Guix is free software; you can redistribute it and/or modify it
;;; under the terms of the GNU General Public License as published by
;;; the Free Software Foundation; either version 3 of the License, or (at
;;; your option) any later version.
;;;
;;; GNU Guix is distributed in the hope that it will be useful, but
;;; WITHOUT ANY WARRANTY; without even the implied warranty of
;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
;;; GNU General Public License for more details.
;;;
;;; You should have received a copy of the GNU General Public License
;;; along with GNU Guix.  If not, see <http://www.gnu.org/licenses/>.

(define-module (test-channels)
  #:use-module (guix channels)
  #:use-module (guix profiles)
  #:use-module ((guix build syscalls) #:select (mkdtemp!))
  #:use-module (guix tests)
  #:use-module (guix store)
  #:use-module (guix derivations)
  #:use-module (guix sets)
  #:use-module (guix gexp)
  #:use-module ((guix diagnostics)
                #:select (error-location?
                          error-location location-line
                          formatted-message?
                          formatted-message-string
                          formatted-message-arguments))
  #:use-module ((guix build utils) #:select (which))
  #:use-module (git)
  #:use-module (guix git)
  #:use-module (guix git-authenticate)
  #:use-module (guix openpgp)
  #:use-module (guix tests git)
  #:use-module (guix tests gnupg)
  #:use-module (srfi srfi-1)
  #:use-module (srfi srfi-26)
  #:use-module (srfi srfi-34)
  #:use-module (srfi srfi-35)
  #:use-module (srfi srfi-64)
  #:use-module (rnrs bytevectors)
  #:use-module (rnrs io ports)
  #:use-module (ice-9 control)
  #:use-module (ice-9 match))

(define (gpg+git-available?)
  (and #t                                         ;'git' is always available
       (which (gpg-command)) (which (gpgconf-command))))

(define commit-id-string
  (compose oid->string commit-id))


(test-begin "channels")

(define* (make-instance #:key
                        (name 'fake)
                        (commit "cafebabe")
                        (spec #f))
  (define instance-dir (mkdtemp! "/tmp/checkout.XXXXXX"))
  (when spec
    (call-with-output-file (string-append instance-dir "/.guix-channel")
      (lambda (port) (write spec port))))
  (checkout->channel-instance instance-dir
                              #:commit commit
                              #:name name))

(define instance--boring (make-instance))
(define instance--unsupported-version
  (make-instance #:spec
                 '(channel (version 42) (dependencies whatever))))
(define instance--no-deps
  (make-instance #:spec
                 '(channel (version 0))))
(define instance--sub-directory
  (make-instance #:spec
                 '(channel (version 0) (directory "modules"))))
(define instance--simple
  (make-instance #:spec
                 '(channel
                   (version 0)
                   (dependencies
                    (channel
                     (name test-channel)
                     (url "https://example.com/test-channel"))))))
(define instance--with-dupes
  (make-instance #:spec
                 '(channel
                   (version 0)
                   (dependencies
                    (channel
                     (name test-channel)
                     (url "https://example.com/test-channel"))
                    (channel
                     (name test-channel)
                     (url "https://example.com/test-channel")
                     (commit "abc1234"))
                    (channel
                     (name test-channel)
                     (url "https://example.com/test-channel-elsewhere"))))))

(define channel-instance-metadata
  (@@ (guix channels) channel-instance-metadata))
(define channel-metadata-directory
  (@@ (guix channels) channel-metadata-directory))
(define channel-metadata-dependencies
  (@@ (guix channels) channel-metadata-dependencies))


(test-equal "channel-instance-metadata returns default if .guix-channel does not exist"
  '("/" ())
  (let ((metadata (channel-instance-metadata instance--boring)))
    (list (channel-metadata-directory metadata)
          (channel-metadata-dependencies metadata))))

(test-equal "channel-instance-metadata and default dependencies"
  '()
  (channel-metadata-dependencies (channel-instance-metadata instance--no-deps)))

(test-equal "channel-instance-metadata and directory"
  "/modules"
  (channel-metadata-directory
   (channel-instance-metadata instance--sub-directory)))

(test-equal "channel-instance-metadata rejects unsupported version"
  1                              ;line number in the generated '.guix-channel'
  (guard (c ((and (message-condition? c) (error-location? c))
             (location-line (error-location c))))
    (channel-instance-metadata instance--unsupported-version)))

(test-assert "channel-instance-metadata returns <channel-metadata>"
  (every (@@ (guix channels) channel-metadata?)
         (map channel-instance-metadata
              (list instance--no-deps
                    instance--simple
                    instance--with-dupes))))

(test-assert "channel-instance-metadata dependencies are channels"
  (let ((deps ((@@ (guix channels) channel-metadata-dependencies)
               (channel-instance-metadata instance--simple))))
    (match deps
      (((? channel? dep)) #t)
      (_ #f))))

(test-assert "latest-channel-instances includes channel dependencies"
  (let* ((channel (channel
                   (name 'test)
                   (url "test")))
         (test-dir (channel-instance-checkout instance--simple)))
    (mock ((guix git) update-cached-checkout
           (lambda* (url #:key ref starting-commit)
             (match url
               ("test" (values test-dir "caf3cabba9e" #f))
               (_      (values (channel-instance-checkout instance--no-deps)
                               "abcde1234" #f)))))
          (with-store store
            (let ((instances (latest-channel-instances store (list channel))))
              (and (eq? 2 (length instances))
                   (lset= eq?
                          '(test test-channel)
                          (map (compose channel-name channel-instance-channel)
                               instances))))))))

(test-assert "latest-channel-instances excludes duplicate channel dependencies"
  (let* ((channel (channel
                   (name 'test)
                   (url "test")))
         (test-dir (channel-instance-checkout instance--with-dupes)))
    (mock ((guix git) update-cached-checkout
           (lambda* (url #:key ref starting-commit)
             (match url
               ("test" (values test-dir "caf3cabba9e" #f))
               (_      (values (channel-instance-checkout instance--no-deps)
                               "abcde1234" #f)))))
          (with-store store
            (let ((instances (latest-channel-instances store (list channel))))
              (and (= 2 (length instances))
                   (lset= eq?
                          '(test test-channel)
                          (map (compose channel-name channel-instance-channel)
                               instances))
                   ;; only the most specific channel dependency should remain,
                   ;; i.e. the one with a specified commit.
                   (find (lambda (instance)
                           (and (eq? (channel-name
                                      (channel-instance-channel instance))
                                     'test-channel)
                                (equal? (channel-commit
                                         (channel-instance-channel instance))
                                        "abc1234")))
                         instances)))))))

(test-equal "latest-channel-instances reads dependencies from most-specific instance"
  '(chan1 chan2)
  ;; Here '.guix-channel' in DIRECTORY2 is less specific than the
  ;; user-provided channel spec in ONE: the latter specifies a commit.  Since
  ;; the most specific one "wins", the bogus '.guix-channel' file added in
  ;; DIRECTORY1 as its second commit must not be taken into account.
  ;; See <https://issues.guix.gnu.org/68822>.
  (with-temporary-git-repository directory1
      `((add "a.scm" "(define-module (a))")
        (commit "first commit")
        (add ".guix-channel"
             ,(object->string
               '(channel
                 (version 0)
                 (dependencies
                  ;; Attempting to fetch this dependency would fail.
                  (channel
                   (name nonexistent-dependency)
                   (url "http://guix.example.org/does-not-exist.git"))))))
        (commit "second commit"))
    (with-temporary-git-repository directory2
        `((add ".guix-channel"
               ,(object->string
                 `(channel (version 0)
                           (dependencies
                            (channel
                             (name chan1)
                             ;; Note: no 'commit' field here.
                             (url ,(string-append "file://" directory1)))))))
          (commit "initial commit"))
      (with-repository directory1 repository
        (let* ((commit (find-commit repository "first"))
               (one    (channel
                        (url (string-append "file://" directory1))
                        (commit (oid->string (commit-id commit))) ;<- specific
                        (name 'chan1)))
               (two    (channel
                        (url (string-append "file://" directory2))
                        (name 'chan2))))

          (with-store store
            (map (compose channel-name channel-instance-channel)
                 (delete-duplicates
                  (append (latest-channel-instances store (list one two))
                          (latest-channel-instances store (list two one)))
                  (lambda (instance1 instance2)
                    (string=? (channel-instance-commit instance1)
                              (channel-instance-commit instance2)))))))))))

(test-equal "latest-channel-instances #:validate-pull"
  'descendant

  ;; Make sure the #:validate-pull procedure receives the right values.
  (let/ec return
    (with-temporary-git-repository directory
        '((add "a.txt" "A")
          (commit "first commit")
          (add "b.scm" "#t")
          (commit "second commit"))
      (with-repository directory repository
        (let* ((commit1 (find-commit repository "first"))
               (commit2 (find-commit repository "second"))
               (spec    (channel (url (string-append "file://" directory))
                                 (name 'foo)))
               (new     (channel (inherit spec)
                                 (commit (oid->string (commit-id commit2)))))
               (old     (channel (inherit spec)
                                 (commit (oid->string (commit-id commit1))))))
          (define (validate-pull channel current commit relation)
            (return (and (eq? channel old)
                         (string=? (oid->string (commit-id commit2))
                                   current)
                         (string=? (oid->string (commit-id commit1))
                                   commit)
                         relation)))

          (with-store store
            ;; Attempt a downgrade from NEW to OLD.
            (latest-channel-instances store (list old)
                                      #:current-channels (list new)
                                      #:validate-pull validate-pull)))))))

(test-assert "channel-instances->manifest"
  ;; Compute the manifest for a graph of instances and make sure we get a
  ;; derivation graph that mirrors the instance graph.  This test also ensures
  ;; we don't try to access Git repositores at all at this stage.
  (let* ((spec      (lambda deps
                      `(channel (version 0)
                                (dependencies
                                 ,@(map (lambda (dep)
                                          `(channel
                                            (name ,dep)
                                            (url "http://example.org")))
                                        deps)))))
         (guix      (make-instance #:name 'guix))
         (instance0 (make-instance #:name 'a))
         (instance1 (make-instance #:name 'b #:spec (spec 'a)))
         (instance2 (make-instance #:name 'c #:spec (spec 'b)))
         (instance3 (make-instance #:name 'd #:spec (spec 'c 'a))))
    (%graft? #f)                                    ;don't try to build stuff

    ;; Create 'build-self.scm' so that GUIX is recognized as the 'guix' channel.
    (let ((source (channel-instance-checkout guix)))
      (mkdir (string-append source "/build-aux"))
      (call-with-output-file (string-append source
                                            "/build-aux/build-self.scm")
        (lambda (port)
          (write '(begin
                    (use-modules (guix) (gnu packages bootstrap))

                    (lambda _
                      (package->derivation %bootstrap-guile)))
                 port))))

    (with-store store
      (let ()
        (define manifest
          (run-with-store store
            (channel-instances->manifest (list guix
                                               instance0 instance1
                                               instance2 instance3))))

        (define entries
          (manifest-entries manifest))

        (define (depends? drv in out)
          ;; Return true if DRV depends (directly or indirectly) on all of IN
          ;; and none of OUT.
          (let ((set (list->set
                      (requisites store
                                  (list (derivation-file-name drv)))))
                (in  (map derivation-file-name in))
                (out (map derivation-file-name out)))
            (and (every (cut set-contains? set <>) in)
                 (not (any (cut set-contains? set <>) out)))))

        (define (lookup name)
          (run-with-store store
            (lower-object
             (manifest-entry-item
              (manifest-lookup manifest
                               (manifest-pattern (name name)))))))

        (let ((drv-guix (lookup "guix"))
              (drv0     (lookup "a"))
              (drv1     (lookup "b"))
              (drv2     (lookup "c"))
              (drv3     (lookup "d")))
          (and (depends? drv-guix '() (list drv0 drv1 drv2 drv3))
               (depends? drv0
                         (list) (list drv1 drv2 drv3))
               (depends? drv1
                         (list drv0) (list drv2 drv3))
               (depends? drv2
                         (list drv1) (list drv3))
               (depends? drv3
                         (list drv2 drv0) (list))))))))

(test-equal "channel-news, no news"
  '()
  (with-temporary-git-repository directory
      '((add "a.txt" "A")
        (commit "the commit"))
    (with-repository directory repository
      (let ((channel (channel (url (string-append "file://" directory))
                              (name 'foo)))
            (latest  (reference-name->oid repository "HEAD")))
        (channel-news-for-commit channel (oid->string latest))))))

(test-assert "channel-news, one entry"
  (with-temporary-git-repository directory
      `((add ".guix-channel"
             ,(object->string
               '(channel (version 0)
                         (news-file "news.scm"))))
        (commit "first commit")
        (add "src/a.txt" "A")
        (commit "second commit")
        (tag "tag-for-first-news-entry")
        (add "news.scm"
             ,(lambda (repository)
                (let ((previous
                       (reference-name->oid repository "HEAD")))
                  (object->string
                   `(channel-news
                     (version 0)
                     (entry (commit ,(oid->string previous))
                            (title (en "New file!")
                                   (eo "Nova dosiero!"))
                            (body (en "Yeah, a.txt."))))))))
        (commit "third commit")
        (add "src/b.txt" "B")
        (commit "fourth commit")
        (add "news.scm"
             ,(lambda (repository)
                (let ((second
                       (commit-id
                        (find-commit repository "second commit")))
                      (previous
                       (reference-name->oid repository "HEAD")))
                  (object->string
                   `(channel-news
                     (version 0)
                     (entry (commit ,(oid->string previous))
                            (title (en "Another file!"))
                            (body (en "Yeah, b.txt.")))
                     (entry (tag "tag-for-first-news-entry")
                            (title (en "Old news.")
                                   (eo "Malnovaĵoj."))
                            (body (en "For a.txt"))))))))
        (commit "fifth commit"))
    (with-repository directory repository
      (define (find-commit* message)
        (oid->string (commit-id (find-commit repository message))))

      (let ((channel (channel (url (string-append "file://" directory))
                              (name 'foo)))
            (commit1 (find-commit* "first commit"))
            (commit2 (find-commit* "second commit"))
            (commit3 (find-commit* "third commit"))
            (commit4 (find-commit* "fourth commit"))
            (commit5 (find-commit* "fifth commit")))
        ;; First try fetching all the news up to a given commit.
        (and (null? (channel-news-for-commit channel commit2))
             (lset= string=?
                    (map channel-news-entry-commit
                         (channel-news-for-commit channel commit5))
                    (list commit2 commit4))
             (lset= equal?
                    (map channel-news-entry-title
                         (channel-news-for-commit channel commit5))
                    '((("en" . "Another file!"))
                      (("en" . "Old news.") ("eo" . "Malnovaĵoj."))))
             (lset= string=?
                    (map channel-news-entry-commit
                         (channel-news-for-commit channel commit3))
                    (list commit2))

             ;; Now fetch news entries that apply to a commit range.
             (lset= string=?
                    (map channel-news-entry-commit
                         (channel-news-for-commit channel commit3 commit1))
                    (list commit2))
             (lset= string=?
                    (map channel-news-entry-commit
                         (channel-news-for-commit channel commit5 commit3))
                    (list commit4))
             (lset= string=?
                    (map channel-news-entry-commit
                         (channel-news-for-commit channel commit5 commit1))
                    (list commit4 commit2))
             (lset= equal?
                    (map channel-news-entry-tag
                         (channel-news-for-commit channel commit5 commit1))
                    '(#f "tag-for-first-news-entry")))))))

(test-assert "channel-news, annotated tag"
  (with-temporary-git-repository directory
      `((add ".guix-channel"
             ,(object->string
               '(channel (version 0)
                         (news-file "news.scm"))))
        (add "src/a.txt" "A")
        (commit "first commit")
        (tag "tag-for-first-news-entry"
             "This is an annotated tag.")
        (add "news.scm"
             ,(lambda (repository)
                (let ((previous
                       (reference-name->oid repository "HEAD")))
                  (object->string
                   `(channel-news
                     (version 0)
                     (entry (tag "tag-for-first-news-entry")
                            (title (en "New file!"))
                            (body (en "Yeah, a.txt."))))))))
        (commit "second commit"))
    (with-repository directory repository
      (define (find-commit* message)
        (oid->string (commit-id (find-commit repository message))))

      (let ((channel (channel (url (string-append "file://" directory))
                              (name 'foo)))
            (commit1 (find-commit* "first commit"))
            (commit2 (find-commit* "second commit")))
        (and (null? (channel-news-for-commit channel commit1))
             (lset= equal?
                    (map channel-news-entry-title
                         (channel-news-for-commit channel commit2))
                    '((("en" . "New file!"))))
             (lset= string=?
                    (map channel-news-entry-tag
                         (channel-news-for-commit channel commit2))
                    (list "tag-for-first-news-entry"))
             ;; This is an annotated tag, but 'channel-news-entry-commit'
             ;; should give us the commit ID, not the ID of the annotated tag
             ;; object.
             (lset= string=?
                    (map channel-news-entry-commit
                         (channel-news-for-commit channel commit2))
                    (list commit1)))))))

(test-assert "latest-channel-instances, missing introduction for 'guix'"
  (with-temporary-git-repository directory
      '((add "a.txt" "A")
        (commit "first commit")
        (add "b.scm" "#t")
        (commit "second commit"))
    (with-repository directory repository
      (let* ((commit1 (find-commit repository "first"))
             (commit2 (find-commit repository "second"))
             (channel (channel (url (string-append "file://" directory))
                               (name 'guix))))

        (guard (c ((formatted-message? c)
                   (->bool (string-contains (formatted-message-string c)
                                            "introduction"))))
          (with-store store
            ;; Attempt a downgrade from NEW to OLD.
            (latest-channel-instances store (list channel))
            #f))))))

(unless (gpg+git-available?) (test-skip 1))
(test-equal "authenticate-channel, wrong first commit signer"
  #t
  (with-fresh-gnupg-setup (list %ed25519-public-key-file
                                %ed25519-secret-key-file
                                %ed25519-2-public-key-file
                                %ed25519-2-secret-key-file)
    (with-temporary-git-repository directory
        `((add ".guix-channel"
               ,(object->string
                 '(channel (version 0)
                           (keyring-reference "master"))))
          (add ".guix-authorizations"
               ,(object->string
                 `(authorizations (version 0)
                                  ((,(key-fingerprint
                                      %ed25519-public-key-file)
                                    (name "Charlie"))))))
          (add "signer.key" ,(call-with-input-file %ed25519-public-key-file
                               get-string-all))
          (commit "first commit"
                  (signer ,(key-fingerprint %ed25519-public-key-file)))
          (add "random" ,(random-text))
          (commit "second commit"
                  (signer ,(key-fingerprint %ed25519-public-key-file))))
      (with-repository directory repository
        (let* ((commit1 (find-commit repository "first"))
               (commit2 (find-commit repository "second"))
               (intro   (make-channel-introduction
                         (commit-id-string commit1)
                         (openpgp-public-key-fingerprint
                          (read-openpgp-packet
                           %ed25519-2-public-key-file)))) ;different key
               (channel (channel (name 'example)
                                 (url (string-append "file://" directory))
                                 (introduction intro))))
          (guard (c ((formatted-message? c)
                     (and (string-contains (formatted-message-string c)
                                           "initial commit")
                          (equal? (formatted-message-arguments c)
                                  (list
                                   (oid->string (commit-id commit1))
                                   (key-fingerprint %ed25519-public-key-file)
                                   (key-fingerprint
                                    %ed25519-2-public-key-file))))))
            (authenticate-channel channel directory
                                  (commit-id-string commit2)
                                  #:keyring-reference-prefix "")
            'failed))))))

(unless (gpg+git-available?) (test-skip 1))
(test-equal "authenticate-channel, not a descendant of introductory commit"
  #t
  (with-fresh-gnupg-setup (list %ed25519-public-key-file
                                %ed25519-secret-key-file
                                %ed25519-2-public-key-file
                                %ed25519-2-secret-key-file)
    (with-temporary-git-repository directory
        `((add ".guix-channel"
               ,(object->string
                 '(channel (version 0)
                           (keyring-reference "master"))))
          (add ".guix-authorizations"
               ,(object->string
                 `(authorizations (version 0)
                                  ((,(key-fingerprint
                                      %ed25519-public-key-file)
                                    (name "Charlie"))))))
          (add "signer.key" ,(call-with-input-file %ed25519-public-key-file
                               get-string-all))
          (commit "first commit"
                  (signer ,(key-fingerprint %ed25519-public-key-file)))
          (branch "alternate-branch")
          (checkout "alternate-branch")
          (add "something.txt" ,(random-text))
          (commit "intro commit"
                  (signer ,(key-fingerprint %ed25519-public-key-file)))
          (checkout "master")
          (add "random" ,(random-text))
          (commit "second commit"
                  (signer ,(key-fingerprint %ed25519-public-key-file))))
      (with-repository directory repository
        (let* ((commit1 (find-commit repository "first"))
               (commit2 (find-commit repository "second"))
               (commit0 (commit-lookup
                         repository
                         (reference-target
                          (branch-lookup repository "alternate-branch"))))
               (intro   (make-channel-introduction
                         (commit-id-string commit0)
                         (openpgp-public-key-fingerprint
                          (read-openpgp-packet
                           %ed25519-public-key-file))))
               (channel (channel (name 'example)
                                 (url (string-append "file://" directory))
                                 (introduction intro))))
          (guard (c ((formatted-message? c)
                     (and (string-contains (formatted-message-string c)
                                           "not a descendant")
                          (equal? (formatted-message-arguments c)
                                  (list
                                   (oid->string (commit-id commit2))
                                   (oid->string (commit-id commit0)))))))
            (authenticate-channel channel directory
                                  (commit-id-string commit2)
                                  #:keyring-reference-prefix "")
            'failed))))))

(unless (gpg+git-available?) (test-skip 1))
(test-equal "authenticate-channel, .guix-authorizations"
  #t
  (with-fresh-gnupg-setup (list %ed25519-public-key-file
                                %ed25519-secret-key-file
                                %ed25519-2-public-key-file
                                %ed25519-2-secret-key-file)
    (with-temporary-git-repository directory
        `((add ".guix-channel"
               ,(object->string
                 '(channel (version 0)
                           (keyring-reference "channel-keyring"))))
          (add ".guix-authorizations"
               ,(object->string
                 `(authorizations (version 0)
                                  ((,(key-fingerprint
                                      %ed25519-public-key-file)
                                    (name "Charlie"))))))
          (commit "zeroth commit")
          (add "a.txt" "A")
          (commit "first commit"
                  (signer ,(key-fingerprint %ed25519-public-key-file)))
          (add "b.txt" "B")
          (commit "second commit"
                  (signer ,(key-fingerprint %ed25519-public-key-file)))
          (add "c.txt" "C")
          (commit "third commit"
                  (signer ,(key-fingerprint %ed25519-2-public-key-file)))
          (branch "channel-keyring")
          (checkout "channel-keyring")
          (add "signer.key" ,(call-with-input-file %ed25519-public-key-file
                               get-string-all))
          (add "other.key" ,(call-with-input-file %ed25519-2-public-key-file
                              get-string-all))
          (commit "keyring commit")
          (checkout "master"))
      (with-repository directory repository
        (let* ((commit1 (find-commit repository "first"))
               (commit2 (find-commit repository "second"))
               (commit3 (find-commit repository "third"))
               (intro   (make-channel-introduction
                         (commit-id-string commit1)
                         (openpgp-public-key-fingerprint
                          (read-openpgp-packet
                           %ed25519-public-key-file))))
               (channel (channel (name 'example)
                                 (url (string-append "file://" directory))
                                 (introduction intro))))
          ;; COMMIT1 and COMMIT2 are fine.
          (and (authenticate-channel channel directory
                                     (commit-id-string commit2)
                                     #:keyring-reference-prefix "")

               ;; COMMIT3 is signed by an unauthorized key according to its
               ;; parent's '.guix-authorizations' file.
               (guard (c ((unauthorized-commit-error? c)
                          (and (oid=? (git-authentication-error-commit c)
                                      (commit-id commit3))
                               (bytevector=?
                                (openpgp-public-key-fingerprint
                                 (unauthorized-commit-error-signing-key c))
                                (openpgp-public-key-fingerprint
                                 (read-openpgp-packet
                                  %ed25519-2-public-key-file))))))
                 (authenticate-channel channel directory
                                       (commit-id-string commit3)
                                       #:keyring-reference-prefix "")
                 'failed)))))))

(unless (gpg+git-available?) (test-skip 1))
(test-equal "latest-channel-instances, authenticate dependency"
  #t
  ;; Make sure that a channel dependency that has an introduction is
  ;; authenticated.  This test checks that an authentication error is raised
  ;; as it should when authenticating the dependency.
  (with-fresh-gnupg-setup (list %ed25519-public-key-file
                                %ed25519-secret-key-file)
    (with-temporary-git-repository dependency-directory
        `((add ".guix-channel"
               ,(object->string
                 '(channel (version 0)
                           (keyring-reference "master"))))
          (add ".guix-authorizations"
               ,(object->string
                 `(authorizations (version 0) ())))
          (add "signer.key" ,(call-with-input-file %ed25519-public-key-file
                               get-string-all))
          (commit "zeroth commit"
                  (signer ,(key-fingerprint %ed25519-public-key-file)))
          (add "foo.txt" "evil")
          (commit "unsigned commit"))
      (with-repository dependency-directory dependency
        (let* ((commit0 (find-commit dependency "zeroth"))
               (commit1 (find-commit dependency "unsigned"))
               (intro   `(channel-introduction
                          (version 0)
                          (commit ,(commit-id-string commit0))
                          (signer ,(openpgp-format-fingerprint
                                    (openpgp-public-key-fingerprint
                                     (read-openpgp-packet
                                      %ed25519-public-key-file)))))))
          (with-temporary-git-repository directory
              `((add ".guix-channel"
                     ,(object->string
                       `(channel (version 0)
                                 (dependencies
                                  (channel
                                   (name test-channel)
                                   (url ,dependency-directory)
                                   (introduction ,intro))))))
                (commit "single commit"))
            (let ((channel (channel (name 'test) (url directory))))
              (guard (c ((unsigned-commit-error? c)
                         (oid=? (git-authentication-error-commit c)
                                (commit-id commit1))))
                (with-store store
                  (latest-channel-instances store (list channel))
                  'failed)))))))))

(test-end "channels")
"https://github.com/AlbanBedel/scummc") (license license:gpl2+))) (define-public sfml (package (name "sfml") (version "2.5.1") (source (origin (method git-fetch) ;; Do not fetch the archives from ;; http://mirror0.sfml-dev.org/files/ because files there seem ;; to be changed in place. (uri (git-reference (url "https://github.com/SFML/SFML") (commit version))) (file-name (git-file-name name version)) (sha256 (base32 "0abr8ri2ssfy9ylpgjrr43m6rhrjy03wbj9bn509zqymifvq5pay")) (modules '((guix build utils))) (snippet '(begin ;; Ensure system libraries are used. (delete-file-recursively "extlibs") #t)))) (build-system cmake-build-system) (arguments '(#:configure-flags (list "-DSFML_INSTALL_PKGCONFIG_FILES=TRUE" "-DSFML_OS_PKGCONFIG_DIR=lib/pkgconfig") #:tests? #f)) ; no tests (native-inputs (list pkg-config)) (inputs `(("mesa" ,mesa) ("glew" ,glew) ("libx11" ,libx11) ("xcb-util-image" ,xcb-util-image) ("libxrandr" ,libxrandr) ("eudev" ,eudev) ("libjpeg" ,libjpeg-turbo) ("libsndfile" ,libsndfile) ("stb-image" ,stb-image) ("stb-image-write" ,stb-image-write))) (propagated-inputs ;; In Requires.private of pkg-config files. (list flac freetype libvorbis openal)) (home-page "https://www.sfml-dev.org") (synopsis "Simple and Fast Multimedia Library") (description "SFML provides a simple interface to the various computer components, to ease the development of games and multimedia applications. It is composed of five modules: system, window, graphics, audio and network.") (license license:zlib))) (define-public csfml (package (name "csfml") (version "2.5.1") (source (origin (method git-fetch) (uri (git-reference (url "https://github.com/SFML/CSFML") (commit version))) (file-name (git-file-name name version)) (sha256 (base32 "1wj1p798myyavld2xdhvvflb5h4nf1vgxxzs6nh5qad44vj9b3kb")))) (build-system cmake-build-system) (arguments (list #:configure-flags #~(list "-DCSFML_BUILD_DOC=TRUE") #:tests? #f)) ;no tests (native-inputs (list doxygen)) (inputs (list sfml)) (synopsis "C bindings for the SFML multimedia library") (description "CSFML is the official C binding to the SFML libraries. SFML provides a simple interface to the various computer components, to ease the development of games and multimedia applications. It is composed of five modules: system, window, graphics, audio and network.") (home-page "https://www.sfml-dev.org/download/csfml/") (license license:zlib))) (define-public sfxr (package (name "sfxr") (version "1.2.1") (source (origin (method url-fetch) (uri (string-append "http://www.drpetter.se/files/sfxr-sdl-1.2.1.tar.gz")) (sha256 (base32 "0dfqgid6wzzyyhc0ha94prxax59wx79hqr25r6if6by9cj4vx4ya")))) (build-system gnu-build-system) (arguments `(#:phases (modify-phases %standard-phases (delete 'configure) ; no configure script (add-before 'build 'patch-makefile (lambda* (#:key outputs #:allow-other-keys) (let ((out (assoc-ref outputs "out"))) (substitute* "Makefile" (("\\$\\(DESTDIR\\)/usr") out)) (substitute* "main.cpp" (("/usr/share") (string-append out "/share"))) #t)))) #:tests? #f)) ; no tests (native-inputs (list pkg-config desktop-file-utils)) (inputs (list sdl gtk+)) (synopsis "Simple sound effect generator") (description "Sfxr is a tool for quickly generating simple sound effects. Originally created for use in video game prototypes, it can generate random sounds from presets such as \"explosion\" or \"powerup\".") (home-page "https://www.drpetter.se/project_sfxr.html") (license license:expat))) (define-public surgescript (package (name "surgescript") (version "0.6.0") (source (origin (method git-fetch) (uri (git-reference (url "https://github.com/alemart/surgescript") (commit (string-append "v" version)))) (file-name (git-file-name name version)) (sha256 (base32 "17k14108hvz329cqnr3g799ksmiv8d710slnghi2wmwswir8s0jd")))) (build-system cmake-build-system) (arguments (list #:tests? #f)) ; there are no tests (home-page "https://docs.opensurge2d.org") (synopsis "Scripting language for games") (description "@code{SurgeScript} is a dynamically typed object-oriented scripting language designed for games. Each object is a state machine that can be customized by attaching other objects. The language supports automatic garbage collection and can be extended with plugins.") (license license:asl2.0))) (define-public physfs (package (name "physfs") (version "3.0.2") (source (origin (method url-fetch) (uri (string-append "https://icculus.org/physfs/downloads/physfs-" version ".tar.bz2")) (file-name (string-append name "-" version ".tar.gz")) (sha256 (base32 "0qzqz4r88gvd8m7sh2z5hvqcr0jfr4wb2f77c19xycyn0rigfk9h")))) (build-system cmake-build-system) (arguments '(#:tests? #f ; no check target #:configure-flags '("-DPHYSFS_BUILD_STATIC=OFF") #:phases (modify-phases %standard-phases (add-after 'unpack 'patch-CMakeLists.txt (lambda _ (substitute* "CMakeLists.txt" ;; XXX: For some reason CMakeLists.txt disables ;; RUNPATH manipulation when the compiler is GCC. (("CMAKE_COMPILER_IS_GNUCC") "FALSE")) #t))))) (inputs (list zlib)) (native-inputs (list doxygen)) (home-page "https://icculus.org/physfs") (synopsis "File system abstraction library") (description "PhysicsFS is a library to provide abstract access to various archives. It is intended for use in video games. For security, no file writing done through the PhysicsFS API can leave a defined @emph{write directory}. For file reading, a @emph{search path} with archives and directories is defined, and it becomes a single, transparent hierarchical file system. So archive files can be accessed in the same way as you access files directly on a disk, and it makes it easy to ship a new archive that will override a previous archive on a per-file basis.") (license license:zlib))) (define-public love (package (name "love") (version "11.4") (source (origin (method url-fetch) (uri (string-append "https://github.com/love2d/love/releases/download/" version "/love-" version "-linux-src.tar.gz")) (sha256 (base32 "0sak3zjpzfs3ys315m8qvszi946fz76jcpsb58j11wplyp5fwbz3")))) (build-system gnu-build-system) (native-inputs (list pkg-config)) (inputs (list devil freetype libmodplug libtheora libvorbis luajit mesa mpg123 openal sdl2 zlib)) (synopsis "2D game framework for Lua") (description "LÖVE is a framework for making 2D games in the Lua programming language.") (home-page "https://love2d.org/") (license license:zlib))) (define-public love-nuklear (package (name "love-nuklear") (version "2.6.1") (source (origin (method git-fetch) (uri (git-reference (url "https://github.com/keharriso/love-nuklear/") (commit (string-append "v" version)) (recursive? #t))) ;; NOTE: the HEAD of the Nuklear git-submodule is at commit ;; "adc52d710fe3c87194b99f540c53e82eb75c2521" of Oct 1 2019 (file-name (git-file-name name version)) (sha256 (base32 "090xp5c975155hd1pa7bdssdlawvygs5s6icdkwbyc8il5kg5kgv")))) (build-system cmake-build-system) (arguments `(#:build-type "Release" #:tests? #f #:phases (modify-phases %standard-phases (add-after 'unpack 'patch-cmake (lambda _ (substitute* "CMakeLists.txt" (("DESTINATION .") "DESTINATION lib/love"))))))) (inputs (list luajit)) (synopsis "Lightweight immediate mode GUI for LÖVE games") (description "LÖVE is a Lua framework for making 2D games. Nuklear is a minimal state immediate mode graphical user interface toolkit. This package is the Nuklear bindings for LÖVE created by Kevin Harrison.") (home-page "https://github.com/keharriso/love-nuklear/") (license license:expat))) (define-public allegro-4 (package (name "allegro") (version "4.4.3.1") (source (origin (method url-fetch) (uri (string-append "https://github.com/liballeg/allegro5/" "releases/download/" version "/allegro-" version ".tar.gz")) (sha256 (base32 "1m6lz35nk07dli26kkwz3wa50jsrxs1kb6w1nj14a911l34xn6gc")))) (build-system cmake-build-system) (arguments '(#:phases (modify-phases %standard-phases (add-after 'unpack 'patch-build-system (lambda _ ;; Build addons as shared libraries. Trying to set ADDON_LINKAGE ;; via a command line option doesn't work because it is ;; unconditionally clobbered in the build script. (substitute* '("CMakeLists.txt") (("ADDON_LINKAGE STATIC") "ADDON_LINKAGE SHARED"))))))) (inputs (list glu libpng libvorbis mesa zlib)) (synopsis "Game programming library") (description "Allegro is a library mainly aimed at video game and multimedia programming. It handles common, low-level tasks such as creating windows, accepting user input, loading data, drawing images, playing sounds, etc.") (home-page "https://liballeg.org") (license license:giftware))) (define-public allegro (package (name "allegro") (version "5.2.7.0") (source (origin (method url-fetch) (uri (string-append "https://github.com/liballeg/allegro5/releases" "/download/" version "/allegro-" version ".tar.gz")) (sha256 (base32 "034pmbmbq6jagpp4lhnyjqmf8gcz5fx74d9rknrm7d4wv4cv7qy1")))) (build-system cmake-build-system) (arguments `(#:tests? #f)) ; there are no tests (inputs ;; FIXME: Add the following optional inputs: xinput2, opensl, dumb `(("flac" ,flac) ("freetype" ,freetype) ("glu" ,glu) ("gtk" ,gtk+) ("libjpeg" ,libjpeg-turbo) ("libpng" ,libpng) ("libtheora" ,libtheora) ("libvorbis" ,libvorbis) ("libxcursor" ,libxcursor) ("libxinerama" ,libxinerama) ("libxrandr" ,libxrandr) ("mesa" ,mesa) ("openal" ,openal) ("physfs" ,physfs) ("zlib" ,zlib))) (native-inputs (list pkg-config)) (synopsis "Game programming library") (description "Allegro is a library mainly aimed at video game and multimedia programming. It handles common, low-level tasks such as creating windows, accepting user input, loading data, drawing images, playing sounds, etc.") (home-page "https://liballeg.org") (license license:bsd-3))) (define-public allegro-5.0 (package (inherit allegro) (name "allegro") (version "5.0.11") (source (origin (method url-fetch) (uri (string-append "https://github.com/liballeg/allegro5/releases" "/download/" version "/allegro-" (if (equal? "0" (string-take-right version 1)) (string-drop-right version 2) version) ".tar.gz")) (patches (search-patches "allegro-mesa-18.2.5-and-later.patch")) (sha256 (base32 "0cd51qrh97jrr0xdmnivqgwljpmizg8pixsgvc4blqqlaz4i9zj9")))))) (define-public aseprite (package (name "aseprite") (version "1.1.7") ; After 1.1.7 the source is no longer distributed under the GPL. ;; TODO: Unbundle third party software. (source (origin (method url-fetch/zipbomb) (uri (string-append "https://github.com/aseprite/aseprite" "/releases/download/v" version "/Aseprite-v" version "-Source.zip")) (sha256 (base32 "1plss4i1lfxcznv9p0pip1bkhj7ipw7jlhsh5avd6dzw079l4nvv")))) (build-system cmake-build-system) (arguments '(#:configure-flags ;; Use shared libraries instead of building bundled source. (list "-DWITH_WEBP_SUPPORT=1" "-DUSE_SHARED_CURL=1" "-DUSE_SHARED_GIFLIB=1" "-DUSE_SHARED_JPEGLIB=1" "-DUSE_SHARED_ZLIB=1" "-DUSE_SHARED_LIBPNG=1" "-DUSE_SHARED_LIBLOADPNG=1" "-DUSE_SHARED_LIBWEBP=1" "-DUSE_SHARED_TINYXML=1" "-DUSE_SHARED_PIXMAN=1" "-DUSE_SHARED_FREETYPE=1" "-DUSE_SHARED_ALLEGRO4=1" "-DENABLE_UPDATER=0" ; no auto-updates (string-append "-DFREETYPE_INCLUDE_DIR=" (assoc-ref %build-inputs "freetype") "/include/freetype2")))) (native-inputs (list pkg-config)) ;; TODO: Use a patched Allegro 4 that supports window resizing. This ;; patched version is bundled with Aseprite, but the patches should be ;; extracted and applied on top of a standalone Allegro 4 package. (inputs `(("allegro" ,allegro-4) ("curl" ,curl) ("freetype" ,freetype) ("giflib" ,giflib) ("libjpeg" ,libjpeg-turbo) ("libpng" ,libpng) ("libwebp" ,libwebp) ("libx11" ,libx11) ("libxext" ,libxext) ("libxxf86vm" ,libxxf86vm) ("pixman" ,pixman) ("tinyxml" ,tinyxml) ("zlib" ,zlib))) (synopsis "Animated sprite editor and pixel art tool") (description "Aseprite is a tool for creating 2D pixel art for video games. In addition to basic pixel editing features, Aseprite can assist in the creation of animations, tiled graphics, texture atlases, and more.") (home-page "https://www.aseprite.org/") (license license:gpl2+))) (define-public libresprite (package (name "libresprite") (version "1.0") ;; TODO: Unbundle third party software. ;; - duktape is bundled inside the project but it's hard to unbundle: ;; there are many differences from a version to the next and it is not ;; really designed to work as a shared lib. (source (origin (method git-fetch) (uri (git-reference (url "https://github.com/LibreSprite/LibreSprite") (commit (string-append "v" version)) (recursive? #t))) (file-name (git-file-name name version)) (sha256 (base32 "0djbjjh21ahlxzh0b0jp4mpfycam8h9157i4wbxkd618fraadhbp")))) (build-system cmake-build-system) (arguments '(#:configure-flags (list "-DWITH_WEBP_SUPPORT=1" "-DWITH_DESKTOP_INTEGRATION=1") ;; Tests are unmaintained #:tests? #f)) (native-inputs `(("pkg-config" ,pkg-config))) (inputs `(("curl" ,curl) ("freetype" ,freetype) ("giflib" ,giflib) ("googletest" ,googletest) ("libjpeg" ,libjpeg-turbo) ("libpng" ,libpng) ("libwebp" ,libwebp) ("libx11" ,libx11) ("libxext" ,libxext) ("libxxf86dga" ,libxxf86dga) ("libxxf86vm" ,libxxf86vm) ("lua" ,lua) ; Optional ("pixman" ,pixman) ("sdl2" ,sdl2) ("sdl2-image" ,sdl2-image) ("tinyxml" ,tinyxml) ("zlib" ,zlib))) (synopsis "Animated sprite editor and pixel art tool") (description "LibreSprite is a tool for creating 2D pixel art for video games. In addition to basic pixel editing features, it can assist in the creation of animations, tiled graphics, texture atlases, and more. LibreSprite is a fork of the latest GPLv2 commit of Aseprite.") (home-page "https://libresprite.github.io/") (license license:gpl2+))) (define-public qqwing (package (name "qqwing") (version "1.3.4") (source (origin (method url-fetch) (uri (string-append "https://qqwing.com/" name "-" version ".tar.gz")) (sha256 (base32 "0bw0papyqjg22z6irf36gs54y8236wa37b6gyn2h1spy65n76lqp")))) (build-system gnu-build-system) (native-inputs (list pkg-config)) (home-page "https://qqwing.com/") (synopsis "Sudoku puzzle solver and generator") (description "QQWing is a Sudoku puzzle generator and solver. It offers the following features: @enumerate @item Can solve 1000 puzzles in 1 second and generate 1000 puzzles in 25 seconds. @item Uses logic. Uses as many solve techniques as possible when solving puzzles rather than guessing. @item Rates puzzles. Most generators don't give an indication of the difficulty of a Sudoku puzzle. QQwing does. @item Can print solve instructions for any puzzle. @item Customizable output style, including a CSV style that is easy to import into a database. @end enumerate") (license license:gpl2+))) (define-public quesoglc (package (name "quesoglc") (version "0.7.2") (source (origin (method url-fetch) (uri (string-append "mirror://sourceforge/" name "/" version "/" name "-" version "-free.tar.bz2")) (sha256 (base32 "08ddhywdy2qg17m592ng3yr0p1ih96irg8wg729g75hsxxq9ipks")))) (build-system gnu-build-system) (native-inputs (list pkg-config)) (inputs (list fontconfig freeglut fribidi glew)) (home-page "https://quesoglc.sourceforge.net") (synopsis "Implementation of the OpenGL Character Renderer (GLC)") (description "The OpenGL Character Renderer (GLC) is a state machine that provides OpenGL programs with character rendering services via an application programming interface (API).") (license (list license:expat license:lgpl2.1+)))) (define-public python-pygame (package (name "python-pygame") (version "2.5.2") (source (origin (method url-fetch) (uri (pypi-uri "pygame" version)) (sha256 (base32 "0jn2n70hmgr33yc6xzdi33cs5w7jnmgi44smyxfarrrrsnsrxf61")))) (build-system python-build-system) (arguments (list #:tests? #f ; tests require pygame to be installed first #:phases #~(modify-phases %standard-phases (add-after 'unpack 'fix-build-config (lambda _ (substitute* "buildconfig/config_unix.py" (("origincdirs = \\[.*\\]") "origincdirs = os.environ['C_INCLUDE_PATH'].split(\":\")") (("ORIGLIBDIRS") "LIBRARY_PATH") (("incdirs = \\[\\]") "incdirs = origincdirs") (("libdirs = \\[\\]") "libdirs = origlibdirs")))) (add-after 'unpack 'fix-sdl2-headers (lambda _ (substitute* "buildconfig/config_unix.py" (("SDL_ttf.h") "SDL2/SDL_ttf.h") (("SDL_image.h") "SDL2/SDL_image.h") (("SDL_mixer.h") "SDL2/SDL_mixer.h")) (substitute* "src_c/imageext.c" (("SDL_image.h") "SDL2/SDL_image.h")) (substitute* "src_c/font.h" (("SDL_ttf.h") "SDL2/SDL_ttf.h")) (substitute* "src_c/mixer.h" (("SDL_mixer.h") "SDL2/SDL_mixer.h")) (substitute* "src_c/_sdl2/mixer.c" (("SDL_mixer.h") "SDL2/SDL_mixer.h"))))))) (native-inputs (list pkg-config)) (inputs (list freetype sdl2 sdl2-image sdl2-mixer sdl2-ttf sdl2-gfx libjpeg-turbo libpng libx11 libsmpeg portmidi v4l-utils)) (home-page "https://www.pygame.org") (synopsis "SDL wrapper for Python") (description "Pygame is a set of Python modules designed for writing games. It adds functionality on top of the SDL library, allowing you to create games and multimedia programs in the Python language.") (license (list license:bsd-2 ;; python numeric license as listed by Debian looks like ;; an Expat-style license with a warranty disclaimer for ;; the U.S. government and the University of California. license:expat license:lgpl2.0+ license:lgpl2.1+ license:gpl3+ license:psfl license:public-domain license:lgpl2.1+)))) (define-public python-pygame-sdl2 (let ((real-version "2.1.0") (renpy-version "8.3.0")) (package (inherit python-pygame) (name "python-pygame-sdl2") (version (string-append real-version "+renpy" renpy-version)) (source (origin (method url-fetch) (uri (string-append "https://www.renpy.org/dl/" renpy-version "/pygame_sdl2-" version ".tar.gz")) (sha256 (base32 "1p8a4v3r5vjxhiwxdmqqhkl38zav6c4a6w6v2nixzdhzyfkgk16n")) (modules '((guix build utils))) (snippet '(begin ;; drop generated sources (delete-file-recursively "gen") (delete-file-recursively "gen3") (delete-file-recursively "gen-static"))))) (build-system python-build-system) (arguments (list #:tests? #f ; tests require pygame to be installed first #:phases #~(modify-phases %standard-phases (add-after 'set-paths 'set-sdl-vars (lambda* (#:key inputs #:allow-other-keys) (setenv "PYGAME_SDL2_CFLAGS" (string-append "-I" (assoc-ref inputs "sdl-union") "/include/SDL2 -D_REENTRANT")) (setenv "PYGAME_SDL2_LDFLAGS" (string-append "-L" (assoc-ref inputs "sdl-union") "/lib -Wl,-rpath," (assoc-ref inputs "sdl-union") "/lib -Wl,--enable-new-dtags -lSDL2"))))))) (inputs (list (sdl-union (list sdl2 sdl2-image sdl2-mixer sdl2-ttf)))) (native-inputs (list python-cython)) (home-page "https://www.renpy.org/") (synopsis "Reimplementation of the Pygame API using SDL2") (description "Pygame_SDL2 reimplements the Pygame API using SDL2, staying close to the original, but also adding some SDL2-specific features. While it aims to be used as a drop-in replacement, it appears to be developed mainly for Ren'py.") (license (list license:lgpl2.1 license:zlib))))) (define-public python-renpy (package (name "python-renpy") (version "8.3.0") (source (origin (method url-fetch) (uri (string-append "https://www.renpy.org/dl/" version "/renpy-" version "-source.tar.bz2")) (sha256 (base32 "1xb9ixb73nm271frkchrqpf64bcrdvrk3n4281dxzm4k4wj60rwb")) (modules '((guix build utils))) (snippet #~(begin ;; Build without sync service. ;; Encryption is only used for enabling this service and requires ;; libhydrogen, which doesn't have a public release, so drop it ;; as well (for-each delete-file '("renpy/encryption.pyx" "renpy/common/00sync.rpy")) (substitute* "module/setup.py" (("cython\\(\"renpy\\.encryption\"\\)") "")) (substitute* "renpy/__init__.py" (("import renpy\\.encryption") "")) ;; Trust vc_version.py when it comes to detecting whether a ;; version is official. (substitute* "renpy/__init__.py" (("official = official and .*") "")))))) (build-system python-build-system) (arguments (list #:tests? #f ; Ren'py doesn't seem to package tests #:phases #~(modify-phases %standard-phases (add-after 'unpack 'fix-commands (lambda* (#:key inputs #:allow-other-keys) (substitute* "renpy/editor.py" (("xdg-open") (string-append (assoc-ref inputs "xdg-utils") "/bin/xdg-open"))))) (add-after 'set-paths 'set-build-vars (lambda* (#:key inputs native-inputs #:allow-other-keys) (setenv "RENPY_CYTHON" (search-input-file (or native-inputs inputs) "/bin/cython")) (setenv "RENPY_DEPS_INSTALL" (string-join (map cdr inputs) ":")))) (replace 'build (lambda* (#:key inputs outputs #:allow-other-keys #:rest args) ;; The "module" subdirectory contains a python (really cython) ;; project, which is built using a script, that is thankfully ;; named "setup.py". (with-directory-excursion "module" (apply (assoc-ref %standard-phases 'build) args)) ;; The above only builds the cython modules, but nothing else, ;; so we do that here. (invoke "python" "-m" "compileall" "renpy"))) (replace 'install (lambda* (#:key inputs outputs #:allow-other-keys #:rest args) ;; Again, we have to wrap the module installation. ;; Additionally, we want to install the python code ;; (both source and compiled) in the same directory. (let* ((out (assoc-ref outputs "out")) (site (string-append "/lib/python" (python-version (assoc-ref inputs "python")) "/site-packages"))) (with-directory-excursion "module" (apply (assoc-ref %standard-phases 'install) args)) (copy-recursively "renpy" (string-append out site "/renpy")) (delete-file-recursively (string-append out site "/renpy/common")))))))) (native-inputs (list python-cython)) (inputs (list ffmpeg freetype fribidi glew libpng (sdl-union (list sdl2 sdl2-image sdl2-mixer sdl2-ttf)) xdg-utils)) (propagated-inputs (list python-ecdsa python-future python-pygame-sdl2)) (home-page "https://www.renpy.org/") (synopsis "Ren'py python module") (description "This package contains the shared libraries and Python modules of Ren'py. While functional, they are not meaningful on their own without the launcher and common Ren'py code provided by the @code{renpy} package and are only used to bootstrap it.") (license license:expat))) (define-public renpy (package (inherit python-renpy) (name "renpy") (build-system python-build-system) (arguments (list #:tests? #f ; see python-renpy #:modules '((srfi srfi-1) (guix build python-build-system) (guix build utils)) #:imported-modules `((srfi srfi-1) ,@%python-build-system-modules) #:phases #~(modify-phases %standard-phases (add-after 'unpack 'fix-commands (lambda* (#:key inputs outputs #:allow-other-keys) (substitute* "launcher/game/choose_directory.rpy" (("/usr/bin/python") (search-input-file inputs "/bin/python3"))) (substitute* "launcher/game/front_page.rpy" (("xdg-open") (search-input-file inputs "/bin/xdg-open"))) (substitute* "launcher/game/project.rpy" (("cmd = \\[ executable, \"-EO\", sys.argv\\[0\\] \\]") (string-append "cmd = [ \"" (assoc-ref outputs "out") "/bin/renpy\" ]")) ;; Projects are still created in the usual style, so we need ;; to adjust the path. (("cmd.append\\(self.path\\)") "cmd.append(self.path + \"/game\")")))) (add-after 'unpack 'drop-game-from-paths (lambda _ (substitute* (list "launcher/game/gui7.rpy" "launcher/game/gui7/images.py") ((", \"game\", \"gui7\",") ", \"gui7\",")) #t)) (add-before 'build 'start-xserver (lambda* (#:key inputs native-inputs #:allow-other-keys) (let ((Xvfb (search-input-file (or native-inputs inputs) "/bin/Xvfb"))) (setenv "HOME" (getcwd)) (system (format #f "~a :1 &" Xvfb)) (setenv "DISPLAY" ":1")))) (replace 'build (lambda _ (invoke "python" "renpy.py" "launcher" "quit") (invoke "python" "renpy.py" "the_question" "quit") (invoke "python" "renpy.py" "tutorial" "quit"))) (replace 'install (lambda* (#:key inputs outputs #:allow-other-keys) ;; Here we install our custom renpy program. ;; After finishing this step, "out" will have the following: ;; |-- bin/renpy ;; `-- share/renpy ; i.e. path_to_renpy_base() ;; |-- common ;; `-- gui ;; ;; Note that common shares the source files that would be installed ;; by python2-renpy (which are instead deleted from that package), ;; but also contains their byte-compiled versions. ;; On other systems, renpy_base would point to site-packages or ;; even somewhere in /opt. ;; The former approach is not as straightforward as it seems ;; -- it causes renpy to load files twice for some weird reason -- ;; and the latter is impossible on Guix. Hence the detour through ;; share/renpy and the custom renpy program. ;; ;; As a convention, other games should be installed as ;; subdirectories of share/renpy in their respective outputs as ;; well. This differs from the traditional layout, which is ;; roughly the following: ;; `-- Super Awesome Game ;; |-- game ; <- the folder we actually want ;; |-- lib ; compiled renpy module and dependencies ;; |-- renpy ; yet another copy of Ren'py's code ;; | |-- common ; the common folder from above ;; | `-- ... ; Python code (source + compiled) ;; |-- Super Awesome Game.py ;; `-- Super Awesome Game.sh (let* ((out (assoc-ref outputs "out")) (bin/renpy (string-append out "/bin/renpy"))) (copy-recursively "renpy/common" (string-append out "/share/renpy/common")) (copy-recursively "gui" (string-append out "/share/renpy/gui")) (copy-recursively "sdk-fonts" (string-append out "/share/renpy/sdk-fonts")) (mkdir-p (string-append out "/bin")) (copy-file #$(local-file (search-auxiliary-file "renpy/renpy.in")) bin/renpy) (substitute* bin/renpy (("@PYTHON@") (search-input-file inputs "bin/python3")) (("@RENPY_BASE@") (string-append out "/share/renpy"))) (chmod bin/renpy #o755)))) (add-after 'install 'install-games (lambda* (#:key inputs outputs #:allow-other-keys) (define renpy (assoc-ref outputs "out")) ;; TODO: We should offer a renpy-build-system to make the ;; installation of Ren'py games easier. (define* (install-renpy-game #:key output game name (renpy renpy) #:allow-other-keys) (let* ((name (or name (basename game))) (launcher (string-append output "/bin/renpy-" name)) (share (string-append output "/share/renpy/" name))) (copy-recursively (string-append game "/game") share) (mkdir-p (string-append output "/bin")) (with-output-to-file launcher (lambda () (format #t "#!~a~%~a ~a \"$@\"" (search-input-file inputs "/bin/bash") (string-append renpy "/bin/renpy") share))) (chmod launcher #o755))) (install-renpy-game #:output (assoc-ref outputs "out") #:game "launcher") (install-renpy-game #:output (assoc-ref outputs "the-question") #:game "the_question" #:name "the-question") (install-renpy-game #:output (assoc-ref outputs "tutorial") #:game "tutorial"))) (replace 'wrap (lambda* (#:key inputs outputs #:allow-other-keys) (let ((out (assoc-ref outputs "out")) (site (string-append "/lib/python" (python-version (assoc-ref inputs "python")) "/site-packages"))) (wrap-program (string-append out "/bin/renpy") `("GUIX_PYTHONPATH" = (,@(delete-duplicates (map (lambda (store-path) (string-append store-path site)) (cons (assoc-ref outputs "out") (map cdr (filter (lambda (input) (string-prefix? "python" (car input))) inputs)))))))))))))) (inputs (list bash-minimal python python-pefile python-requests python-renpy python-six `(,python "tk") xdg-utils)) (propagated-inputs '()) (native-inputs (list xorg-server-for-tests)) (outputs (list "out" "tutorial" "the-question")) (home-page "https://www.renpy.org/") (synopsis "Visual Novel Engine") (description "Ren'Py is a visual novel engine that helps you use words, images, and sounds to tell interactive stories that run on computers and mobile devices. These can be both visual novels and life simulation games. The easy to learn script language allows anyone to efficiently write large visual novels, while its Python scripting is enough for complex simulation games.") (license license:expat))) (define-public python-pyxel ;; Note to updaters: Use commit and revision even if you're bumping ;; to a release, as upstream is known to "reuse" tags. ;; See <https://bugs.gnu.org/66015> for more information. (let ((commit "be75b724cae9e10e56a82a5421f9dd65390f1a06") (revision "2")) (package (name "python-pyxel") ;; This is the latest version to not require Rust… (version (git-version "1.4.3" revision commit)) (source (origin (method git-fetch) (uri (git-reference (url "https://github.com/kitao/pyxel") (commit commit))) (file-name (git-file-name name version)) (sha256 (base32 "03ch79cmh9fxvq6c2f3zc2snzczhqi2n01f254lsigckc7d5wz08")) (modules '((guix build utils))) (snippet #~(begin (substitute* "pyxel/__init__.py" (("from collections import MutableSequence") "from collections.abc import MutableSequence")))))) (build-system python-build-system) (arguments `(#:tests? #f ; "Tests" are actually example programs that never halt. #:phases (modify-phases %standard-phases (add-after 'unpack 'patch-build-files (lambda* (#:key inputs #:allow-other-keys) (substitute* "setup.py" (("\"pyxel\\.core\\.bin\\.(.*)\"," all arch) (if (string=? arch "linux") all ""))) (substitute* "pyxel/core/Makefile" (("`sdl2-config") (string-append "`sdl2-config --prefix=" (assoc-ref inputs "sdl2")))))) (add-before 'build 'prebuild (lambda _ (invoke "make" "-C" "pyxel/core")))))) (inputs `(("gifsicle" ,gifsicle) ("sdl2" ,(sdl-union (list sdl2 sdl2-image))))) (home-page "https://github.com/kitao/pyxel") (synopsis "Retro game engine for Python") (description "Pyxel is a game engine inspired by retro gaming consoles. It has a fixed 16-color palette, can hold up to 3 image banks and 8 tilemaps (256x256 pixels each) and 4 sound channels with 64 definable sounds. It also comes with a built-in image and sound editor.") (license license:expat)))) (define-public grafx2 (package (name "grafx2") (version "2.4") (source (origin (method url-fetch) ;; XXX: There is no URL that contains the version. :( (uri "http://pulkomandy.tk/projects/GrafX2/downloads/21") (file-name (string-append "grafx2-" version ".tgz")) (sha256 (base32 "0svsy6rqmdj11b400c242i2ixihyz0hds0dgicqz6g6dcgmcl62q")))) (build-system gnu-build-system) (arguments '(#:phases (modify-phases %standard-phases (delete 'configure) ; no configure script (add-before 'build 'change-to-src-directory (lambda _ (chdir "src") #t))) #:make-flags ;; SDL header files are referenced without the preceeding "SDL/". (list (string-append "CFLAGS=-I" (assoc-ref %build-inputs "sdl-union") "/include/SDL" " -fcommon") (string-append "prefix=" (assoc-ref %outputs "out"))) #:tests? #f)) ; no check target (native-inputs (list pkg-config)) (inputs (list libpng lua-5.1 (sdl-union (list sdl sdl-image sdl-ttf)))) (synopsis "Bitmap paint program") (description "GrafX2 is a bitmap paint program inspired by the Amiga programs Deluxe Paint and Brilliance. Specializing in 256-color drawing, it includes a very large number of tools and effects that make it particularly suitable for pixel art, game graphics, and generally any detailed graphics painted with a mouse.") (home-page "http://pulkomandy.tk/projects/GrafX2") (license license:gpl2))) ; GPLv2 only (define-public ois (package (name "ois") (version "1.5.1") (source (origin (method git-fetch) (uri (git-reference (url "https://github.com/wgois/OIS") (commit (string-append "v" version)))) (file-name (git-file-name name version)) (sha256 (base32 "0nkh0zrsbyv47c0i0vhdna3jsnvs69pb1svg75avxw6z7kwskgla")))) (build-system cmake-build-system) (arguments `(#:tests? #f)) ; no test suite (inputs (list libx11)) (synopsis "Object Oriented Input System") (description "Cross Platform Object Oriented Input Lib System is a cross platform, simple solution for using all kinds of Input Devices (Keyboards, Mice, Joysticks, etc) and feedback devices (e.g. force feedback). Meant to be very robust and compatible with many systems and operating systems.") (home-page "https://github.com/wgois/OIS") (license license:zlib))) (define-public mygui (package (name "mygui") (version "3.4.2") (source (origin (method git-fetch) (uri (git-reference (url "https://github.com/MyGUI/mygui") (commit (string-append "MyGUI" version)))) (file-name (git-file-name name version)) (sha256 (base32 "0gkfahz118gpqa2906cjb3d4w8g13rv8v3ma7s0ml9l5cci785f8")))) (build-system cmake-build-system) (arguments '(#:tests? #f ; No test target #:configure-flags (list "-DMYGUI_INSTALL_DOCS=TRUE" (string-append "-DOGRE_INCLUDE_DIR=" (assoc-ref %build-inputs "ogre") "/include/OGRE") ;; Demos and tools are Windows-specific: ;; https://github.com/MyGUI/mygui/issues/24. "-DMYGUI_BUILD_DEMOS=FALSE" "-DMYGUI_BUILD_TOOLS=FALSE"))) (native-inputs (list boost doxygen pkg-config)) (inputs (list font-dejavu freetype graphviz libx11 ogre ois)) (synopsis "Fast, flexible and simple GUI") (description "MyGUI is a library for creating Graphical User Interfaces (GUIs) for games and 3D applications. The main goals of mygui are: speed, flexibility and ease of use.") (home-page "http://mygui.info/") (license license:expat))) (define-public mygui-gl ;; Closure size is reduced by some 800 MiB. (package/inherit mygui (name "mygui-gl") (arguments (substitute-keyword-arguments (package-arguments mygui) ((#:configure-flags _) `(cons* "-DMYGUI_RENDERSYSTEM=4" ; 3 is Ogre, 4 is OpenGL. ;; We can't reuse the flags because of the mention to Ogre. (list "-DMYGUI_INSTALL_DOCS=TRUE" ;; Demos and tools are Windows-specific: ;; https://github.com/MyGUI/mygui/issues/24. "-DMYGUI_BUILD_DEMOS=FALSE" "-DMYGUI_BUILD_TOOLS=FALSE"))))) (inputs (modify-inputs (package-inputs mygui) (delete "ogre") (prepend glu libglvnd ; for find_package(… GLX) mesa ; for find_package(… OpenGL …) (sdl-union (list sdl2 sdl2-image))))) (synopsis "Fast, flexible and simple GUI (OpenGL backend)"))) (define-public openmw (package (name "openmw") (version "0.48.0") (source (origin (method git-fetch) (uri (git-reference (url "https://github.com/OpenMW/openmw") (commit (string-append "openmw-" version)))) (file-name (git-file-name name version)) (sha256 (base32 "0amkxfylk1l67d2igihnhhql62xr89wvg1sxbq2rnhczf6vxaj6f")))) (build-system cmake-build-system) (arguments `(#:tests? #f ;No test target #:configure-flags (list "-DDESIRED_QT_VERSION=5" "-DOPENMW_USE_SYSTEM_RECASTNAVIGATION=ON"))) (native-inputs (list boost doxygen pkg-config)) (inputs (list bullet ffmpeg libxt lz4 mygui-gl ;OpenMW does not need Ogre. openal openmw-openscenegraph qtbase-5 recastnavigation sdl2 unshield icu4c yaml-cpp luajit sqlite)) (synopsis "Re-implementation of the RPG Morrowind engine") (description "OpenMW is a game engine which reimplements and extends the one that runs the 2002 open-world RPG Morrowind. The engine comes with its own editor, called OpenMW-CS which allows the user to edit or create their own original games.") (home-page "https://openmw.org") (license license:gpl3))) (define-public godot-lts (package (name "godot") (version "3.5.3") (source (origin (method git-fetch) (uri (git-reference (url "https://github.com/godotengine/godot") (commit (string-append version "-stable")))) (file-name (git-file-name name version)) (sha256 (base32 "0zibc6am9axbbm8l57jf2d324a2m44pf6ncp2i4h1b219jjq89l6")) (modules '((guix build utils) (ice-9 ftw) (srfi srfi-1))) (snippet '(begin ;; Keep only those bundled files we have not (yet) replaced ;; with Guix versions. Note that some of these may be ;; modified; see "thirdparty/README.md". (with-directory-excursion "thirdparty" (let* ((preserved-files '("README.md" "certs" "cvtt" "embree" "enet" "etc2comp" "fonts" "glad" "jpeg-compressor" "libsimplewebm" "minimp3" "miniupnpc" "minizip" "misc" "nanosvg" "oidn" "pvrtccompressor" "recastnavigation" "rvo2" "squish" "stb_rect_pack" "tinyexr" "vhacd" "xatlas"))) (for-each delete-file-recursively (lset-difference string=? (scandir ".") (cons* "." ".." preserved-files))))))))) (build-system scons-build-system) (arguments (list ;; Avoid using many of the bundled libs. ;; Note: These options can be found in the SConstruct file. #:scons-flags #~(list "platform=x11" "target=release_debug" "builtin_bullet=no" "builtin_freetype=no" "builtin_glew=no" "builtin_libmpdec=no" "builtin_libogg=no" "builtin_libpng=no" "builtin_libtheora=no" "builtin_libvorbis=no" "builtin_libvpx=no" "builtin_libwebp=no" "builtin_mbedtls=no" "builtin_opus=no" "builtin_pcre2=no" "builtin_wslay=no" "builtin_zlib=no" "builtin_zstd=no") #:tests? #f ; There are no tests #:phases #~(modify-phases %standard-phases (add-after 'unpack 'scons-use-env (lambda _ ;; Scons does not use the environment variables by default, ;; but this substitution makes it do so. (substitute* "SConstruct" (("env_base = Environment\\(tools=custom_tools\\)") (string-append "env_base = Environment(tools=custom_tools)\n" "env_base = Environment(ENV=os.environ)"))))) ;; Build headless tools, to package games without depending on X. (add-after 'build 'build-headless (lambda* (#:key scons-flags #:allow-other-keys) (apply invoke "scons" `(,(string-append "-j" (number->string (parallel-job-count))) "platform=server" ,@(delete "platform=x11" scons-flags))))) (replace 'install (lambda* (#:key inputs outputs #:allow-other-keys) (let* ((out (assoc-ref outputs "out")) (headless (assoc-ref outputs "headless")) (zenity (assoc-ref inputs "zenity"))) ;; Strip build info from filenames. (with-directory-excursion "bin" (for-each (lambda (file) (let ((dest (car (string-split (basename file) #\.)))) (rename-file file dest))) (find-files "." "godot.*\\.x11\\.opt\\.tools.*")) (install-file "godot" (string-append out "/bin")) (install-file "godot_server" (string-append headless "/bin"))) ;; Tell the editor where to find zenity for OS.alert(). (wrap-program (string-append out "/bin/godot") `("PATH" ":" prefix (,(string-append zenity "/bin"))))))) (add-after 'install 'wrap-ld-path (lambda* (#:key inputs outputs #:allow-other-keys) (let* ((out (assoc-ref outputs "out")) (pulseaudio_path (string-append (assoc-ref inputs "pulseaudio") "/lib")) (alas_lib_path (string-append (assoc-ref inputs "alsa-lib") "/lib"))) (wrap-program (string-append out "/bin/godot") `("LD_LIBRARY_PATH" ":" prefix (,pulseaudio_path ,alas_lib_path)))))) (add-after 'install 'install-godot-desktop (lambda* (#:key outputs #:allow-other-keys) (let* ((out (assoc-ref outputs "out")) (applications (string-append out "/share/applications")) (icons (string-append out "/share/icons/hicolor"))) (mkdir-p applications) (copy-file "misc/dist/linux/org.godotengine.Godot.desktop" (string-append applications "/godot.desktop")) (for-each (lambda (icon dest) (mkdir-p (dirname dest)) (copy-file icon dest)) '("icon.png" "icon.svg") `(,(string-append icons "/256x256/apps/godot.png") ,(string-append icons "/scalable/apps/godot.svg"))))))))) (outputs '("out" "headless")) (native-inputs (list pkg-config)) (inputs (list alsa-lib bash-minimal bullet freetype-with-brotli glew glu libtheora libvorbis libvpx libwebp libx11 libxcursor libxi libxinerama libxrandr mbedtls-lts mesa opusfile pcre2 pulseaudio eudev wslay zenity `(,zstd "lib"))) (home-page "https://godotengine.org/") (synopsis "Advanced 2D and 3D game engine") (description "Godot is an advanced multi-platform game engine written in C++. If features design tools such as a visual editor, can import 3D models and provide high-quality 3D rendering, it contains an animation editor, and can be scripted in a Python-like language.") (license license:expat))) (define-public godot (package (name "godot") (version "4.2.2") (source (origin (method git-fetch) (uri (git-reference (url "https://github.com/godotengine/godot") (commit (string-append version "-stable")))) (file-name (git-file-name name version)) (sha256 (base32 "0wm0pla6f6gvk21gbm5kiihinn05dvvprk0242m6s8c78wy60wka")) (modules '((guix build utils) (ice-9 ftw) (srfi srfi-1))) (snippet '(begin ;; Keep only those bundled files we have not (yet) replaced ;; with Guix versions. Note that some of these may be ;; modified; see "thirdparty/README.md". (with-directory-excursion "thirdparty" (let* ((preserved-files '("README.md" "amd-fsr" "amd-fsr2" "assimp" "astcenc" "basis_universal" ;; Godot needs ca-certificates.crt, but that is ;; not available in build environment "certs" "clipper2" "cvtt" "linuxbsd_headers" "etc2comp" "etcpak" "fonts" "glad" ;; TODO: Remove once Godot once again builds ;; with our glslang package, or with a ;; workaround. Currently it looks for a Types.h ;; which is no longer in the glslang output ;; after the most recent update. "glslang" "jpeg-compressor" "libktx" "libsimplewebm" "meshoptimizer" "minimp3" "miniupnpc" "minizip" "misc" "msdfgen" "nanosvg" "noise" "oidn" "openxr" "pvrtccompressor" "recastnavigation" "rvo2" "spirv-reflect" "squish" "stb_rect_pack" "thorvg" "tinyexr" "vhacd" "volk" "vulkan" "xatlas"))) (for-each delete-file-recursively (lset-difference string=? (scandir ".") (cons* "." ".." preserved-files))))))))) (build-system scons-build-system) (arguments (list #:scons-flags #~`("platform=linuxbsd" "target=editor" "production=yes" ;; XXX: There may be advantages to enabling volk, ;; requiring unbundling and patching to use our input. "use_volk=no" ;; Avoid using many of the bundled libs. ;; Note: These options can be found in the SConstruct file. "builtin_brotli=no" "builtin_embree=no" "builtin_enet=no" "builtin_freetype=no" ;; TODO: Uncomment this option when the todo for ;; glslang in the snippet is resolved. ;; "builtin_glslang=no" "builtin_graphite=no" "builtin_harfbuzz=no" "builtin_icu4c=no" "builtin_libogg=no" "builtin_libpng=no" "builtin_libtheora=no" "builtin_libvorbis=no" "builtin_libwebp=no" "builtin_mbedtls=no" "builtin_pcre2=no" "builtin_pcre2_with_jit=no" "builtin_wslay=no" "builtin_zlib=no" "builtin_zstd=no") #:tests? #f ; There are no tests #:phases #~(modify-phases %standard-phases (add-after 'unpack 'scons-use-env (lambda _ ;; Scons does not use the environment variables by default, ;; but this substitution makes it do so. (substitute* "SConstruct" (("env_base = Environment\\(tools=custom_tools\\)") (string-append "env_base = Environment(tools=custom_tools)\n" "env_base = Environment(ENV=os.environ)"))))) (add-after 'scons-use-env 'fix-dlopen-paths (lambda* (#:key inputs #:allow-other-keys) (let ((files '("drivers/alsa/asound-so_wrap.c" "drivers/pulseaudio/pulse-so_wrap.c" "platform/linuxbsd/dbus-so_wrap.c" "platform/linuxbsd/fontconfig-so_wrap.c" "platform/linuxbsd/libudev-so_wrap.c" "platform/linuxbsd/speechd-so_wrap.c" "platform/linuxbsd/x11/display_server_x11.cpp" "platform/linuxbsd/x11/dynwrappers/xcursor-so_wrap.c" "platform/linuxbsd/x11/dynwrappers/xext-so_wrap.c" "platform/linuxbsd/x11/dynwrappers/xinerama-so_wrap.c" "platform/linuxbsd/x11/dynwrappers/xinput2-so_wrap.c" "platform/linuxbsd/x11/dynwrappers/xlib-so_wrap.c" "platform/linuxbsd/x11/dynwrappers/xrandr-so_wrap.c" "platform/linuxbsd/x11/dynwrappers/xrender-so_wrap.c" "platform/linuxbsd/xkbcommon-so_wrap.c" "thirdparty/volk/volk.c" "thirdparty/volk/volk.c")) (libs '("libasound.so.2" "libpulse.so.0" "libdbus-1.so.3" "libfontconfig.so.1" "libudev.so.1" "libspeechd.so.2" "libXrandr.so.2" "libXcursor.so.1" "libXext.so.6" "libXinerama.so.1" "libXi.so.6" "libX11.so.6" "libXrandr.so.2" "libXrender.so.1" "libxkbcommon.so.0" "libvulkan.so.1" "libvulkan.so"))) (for-each (lambda (file lib) (substitute* file (((string-append "dlopen\\(\"" lib "\"")) (string-append "dlopen(\"" (search-input-file inputs (string-append "lib/" lib)) "\"")))) files libs)) (substitute* "thirdparty/glad/gl.c" (("libGL.so") ; for both .so and .so.1 (string-append (search-input-file inputs "lib/libGL.so")))) (substitute* "thirdparty/glad/glx.c" (("libGL.so") ; for both .so and .so.1 (string-append (search-input-file inputs "lib/libGL.so")))))) (add-after 'fix-dlopen-paths 'unbundle-xkbcommon (lambda* (#:key inputs #:allow-other-keys) (substitute* "platform/linuxbsd/xkbcommon-so_wrap.c" (("./thirdparty/linuxbsd_headers/xkbcommon/xkbcommon.h") (string-append (search-input-file inputs "include/xkbcommon/xkbcommon.h"))) (("./thirdparty/linuxbsd_headers/xkbcommon/xkbcommon-compose.h") (string-append (search-input-file inputs "include/xkbcommon/xkbcommon-compose.h"))) (("./thirdparty/linuxbsd_headers/xkbcommon/xkbcommon-keysyms.h") (string-append (search-input-file inputs "include/xkbcommon/xkbcommon-keysyms.h")))))) (replace 'install (lambda* (#:key inputs #:allow-other-keys) (let ((zenity (search-input-file inputs "bin/zenity"))) ;; Strip build info from filenames. (with-directory-excursion "bin" (for-each (lambda (file) (let ((dest (car (string-split (basename file) #\.)))) (rename-file file dest))) (find-files "." "godot.*\\.linuxbsd\\.editor.*")) (install-file "godot" (string-append #$output "/bin"))) ;; Tell the editor where to find zenity for OS.alert(). ;; TODO: This could be changed in ;; platform/linuxbsd/os_linuxbsd.cpp directly, along with the ;; other alert programs. (wrap-program (string-append #$output "/bin/godot") `("PATH" ":" prefix (,(string-append zenity "/bin"))))))) (add-after 'install 'install-godot-desktop (lambda _ (let ((applications (string-append #$output "/share/applications")) (icons (string-append #$output "/share/icons/hicolor"))) (mkdir-p applications) (copy-file "misc/dist/linux/org.godotengine.Godot.desktop" (string-append applications "/godot.desktop")) (for-each (lambda (icon dest) (mkdir-p (dirname dest)) (copy-file icon dest)) '("icon.png" "icon.svg") `(,(string-append icons "/256x256/apps/godot.png") ,(string-append icons "/scalable/apps/godot.svg"))))))))) (native-inputs (list pkg-config)) (inputs (list alsa-lib bash-minimal brotli dbus embree enet eudev fontconfig freetype-with-brotli glew glslang glu libpng harfbuzz icu4c libtheora libvorbis libvpx libwebp libx11 libxcursor libxi libxinerama libxkbcommon libxrandr mbedtls-lts mesa openxr opusfile pcre2 pulseaudio speech-dispatcher vulkan-loader wslay zenity zlib `(,zstd "lib"))) (home-page "https://godotengine.org/") (synopsis "Advanced 2D and 3D game engine") (description "Godot is an advanced multi-platform game engine written in C++. If features design tools such as a visual editor, can import 3D models and provide high-quality 3D rendering, it contains an animation editor, and can be scripted in a Python-like language.") (license license:expat))) (define-public entt (package (name "entt") (version "3.7.1") (source (origin (method git-fetch) (uri (git-reference (url "https://github.com/skypjack/entt") (commit (string-append "v" version)))) (file-name (git-file-name name version)) (sha256 (base32 "151jg3m262xwaywl2rqnc90yr6p48rhmgi5mxyv6bwqvmfli2m5p")))) (build-system cmake-build-system) (arguments `(#:configure-flags (list "-DENTT_BUILD_TESTING=ON" "-DENTT_FIND_GTEST_PACKAGE=ON" "-DENTT_BUILD_DOCS=ON") ;; Only tests are compiled, and they need assertions to work correctly. #:build-type "Debug")) (native-inputs (list ;; for testing googletest ;; for documentation doxygen graphviz)) (synopsis "Entity component system") (description "EnTT is a header-only library, containing (among other things) @itemize @item an entity component system based on sparse sets, @item a configuration system using the monostate pattern, @item a static reflection system, @item and a cooperative scheduler. @end itemize") (home-page "https://github.com/skypjack/entt") (license (list license:expat ; code license:cc-by4.0)))) ; documentation (define-public eureka (package (name "eureka") (version "1.24") (source (origin (method url-fetch) (uri (string-append "mirror://sourceforge/eureka-editor/Eureka/" version "/eureka-" ;; version without dots e.g 1.21 => 121 (string-join (string-split version #\.) "") "-source.tar.gz")) (sha256 (base32 "1x4idjniz9sma3j9ss6ni7fafmz22zs2jnpsqw4my9rsnmra5d9v")))) (build-system gnu-build-system) (arguments '(#:tests? #f #:make-flags (let ((out (assoc-ref %outputs "out"))) (list (string-append "PREFIX=" out))) #:phases (modify-phases %standard-phases (delete 'configure) (add-before 'build 'prepare-install-directories (lambda* (#:key outputs #:allow-other-keys) (let ((out (assoc-ref outputs "out"))) (mkdir-p (string-append out "/bin")) (mkdir-p (string-append out "/share")) (with-fluids ((%default-port-encoding #f)) (substitute* "./src/main.cc" (("/usr/local") out))) (substitute* "Makefile" (("-o root") "")))))))) (inputs `(("mesa" ,mesa) ("libxft" ,libxft) ("libxinerama" ,libxinerama) ("libfontconfig" ,fontconfig) ("libjpeg" ,libjpeg-turbo) ("libpng" ,libpng) ("fltk" ,fltk) ("zlib" ,zlib))) (native-inputs (list pkg-config xdg-utils)) (synopsis "Doom map editor") (description "Eureka is a map editor for the classic DOOM games, and a few related games such as Heretic and Hexen. It comes with a 3d preview mode and a 2D editor view.") (home-page "https://eureka-editor.sourceforge.net/") (license license:gpl2+))) (define-public guile-chickadee (package (name "guile-chickadee") (version "0.10.0") (source (origin (method url-fetch) (uri (string-append "https://files.dthompson.us/chickadee/" "chickadee-" version ".tar.gz")) (sha256 (base32 "0x8g0bsvir2z3876ynslfgnmfr5p92ic4666v73526lswnv56bqk")))) (build-system gnu-build-system) (arguments '(#:make-flags '("GUILE_AUTO_COMPILE=0"))) (propagated-inputs `(("guile-opengl" ,guile3.0-opengl) ("guile-sdl2" ,guile-sdl2))) (inputs (list freetype guile-3.0-latest libjpeg-turbo libpng libvorbis mpg123 openal readline)) (native-inputs (list guile-3.0-latest pkg-config texinfo)) (home-page "https://dthompson.us/projects/chickadee.html") (synopsis "Game development toolkit for Guile Scheme with SDL2 and OpenGL") (description "Chickadee is a game development toolkit for Guile Scheme built on top of SDL2 and OpenGL. Chickadee aims to provide all the features that parenthetically inclined game developers need to make 2D (and eventually 3D) games in Scheme, such as: @enumerate @item extensible, fixed-timestep game loop @item OpenGL-based rendering engine @item keyboard, mouse, controller input @item REPL-driven development model @end enumerate\n") (license license:asl2.0))) (define-public bennu-game-development (package (name "bennu-game-development") (version "353") (source (origin (method svn-fetch) (uri (svn-reference (url "http://svn.code.sf.net/p/bennugd/code") (revision (string->number version)))) (file-name (string-append name "-" version)) (sha256 (base32 "1iri58ryk9lbqn585cbccnvrfkj8qxlbcsk8rpih40jhvs1j101l")) (modules '((guix build utils))) (snippet '(begin (delete-file-recursively "3rdparty") #t)))) (build-system gnu-build-system) (arguments '(#:phases (modify-phases %standard-phases (add-after 'unpack 'patch-configure-to-use-openssl (lambda* (#:key outputs #:allow-other-keys) (chdir "core") (delete-file "configure") (substitute* "configure.in" (("i\\*86\\)") "*) COMMON_CFLAGS=\"$COMMON_CFLAGS -DUSE_OPENSSL\" COMMON_LDFLAGS=\"$COMMON_LDFLAGS\" LIBSSL=\"crypto\" USE_OPENSSL=yes ;; i*86)")) #t))))) (inputs (list openssl zlib)) (native-inputs (list pkg-config autoconf automake libtool)) (synopsis "Programming language to create games") (description "Bennu Game Development, also known as bennudg, is a programming language tailored at game development. It is the successor of Fenix.") (home-page "https://sourceforge.net/projects/bennugd/") (license license:zlib))) (define-public bennu-game-development-modules (package (inherit bennu-game-development) (name "bennu-game-development-modules") (arguments '(#:phases (modify-phases %standard-phases (add-after 'unpack 'patch-conflicting-definitions (lambda _ (with-fluids ((%default-port-encoding #f)) (substitute* "core/include/fmath.h" (("extern fixed fmul\\( int x, int y \\);") "") (("extern fixed fdiv\\( int x, int y \\);") ""))) (chdir "modules")))))) (inputs (list zlib libpng openssl sdl-mixer bennu-game-development)) (synopsis "Modules for the Bennu Game Development programming language") (description "This package contains a collection of modules for the Bennu Game Development programming language, from CD handling through SDL to joystick support."))) (define-public plib (package (name "plib") (version "1.8.5") (source (origin (method url-fetch) (uri (string-append "http://plib.sourceforge.net/dist/" "plib-" version ".tar.gz")) (sha256 (base32 "0cha71mflpa10vh2l7ipyqk67dq2y0k5xbafwdks03fwdyzj4ns8")) (patches (search-patches "plib-CVE-2011-4620.patch" "plib-CVE-2012-4552.patch")))) (build-system gnu-build-system) (inputs (list mesa libxi libxmu)) (native-inputs (list pkg-config)) (home-page "https://plib.sourceforge.net/") (synopsis "Suite of portable game libraries") (description "PLIB is a set of libraries that will permit programmers to write games and other realtime interactive applications that are 100% portable across a wide range of hardware and operating systems. PLIB includes sound effects, music, a complete 3D engine, font rendering, a simple Windowing library, a game scripting language, a GUI, networking, 3D math library and a collection of handy utility functions. All are 100% portable across nearly all modern computing platforms. Each library component is fairly independent of the others") (license license:lgpl2.0+))) (define-public ioquake3 ;; We follow master since it seems that there won't be releases after 1.3.6. (let ((revision "2") (commit "29b0cc3a4d037046eb3247fc04f4b703f6a33452")) (package (name "ioquake3") (version (git-version "1.3.6" revision commit)) (source (origin (method git-fetch) (uri (git-reference (url "https://github.com/ioquake/ioq3") (commit commit))) (file-name (git-file-name name version)) (sha256 (base32 "0fqq2qpnrgpgf3gs71wvxlkcihxcrvhvllh88ii4ip134c1qbs9q")))) (build-system gnu-build-system) (inputs (list curl freetype libjpeg-turbo libogg libvorbis openal opus opusfile sdl2)) (native-inputs (list which ; else SDL_version.h won't be found. pkg-config)) (arguments (list #:tests? #f ; no tests #:make-flags #~(list (string-append "CC=" #$(cc-for-target)) "USE_INTERNAL_LIBS=0" "USE_FREETYPE=1" "USE_RENDERER_DLOPEN=0" "USE_OPENAL_DLOPEN=0" "USE_CURL_DLOPEN=0") #:phases #~(modify-phases %standard-phases (delete 'configure) ; no configure-script (replace 'install (lambda* (#:key make-flags outputs #:allow-other-keys) (apply invoke "make" "copyfiles" (string-append "COPYDIR=" (assoc-ref outputs "out") "/bin") make-flags)))))) (home-page "https://ioquake3.org/") (synopsis "FPS game engine based on Quake 3") (description "ioquake3 is a free software first person shooter engine based on the Quake 3: Arena and Quake 3: Team Arena source code. Compared to the original, ioquake3 has been cleaned up, bugs have been fixed and features added. The permanent goal is to create a Quake 3 distribution upon which people base their games, ports to new platforms, and other projects.") (license license:gpl2)))) (define-public inform ;; The latest release does not yet have a build system. ;; This commit is the earliest to have one. (let ((commit "20cbfff96015938809d0e3da6cd0d83b76d27f14") (revision "0")) (package (name "inform") (version (git-version "6.41" revision commit)) (source (origin (method git-fetch) (uri (git-reference (url "https://jxself.org/git/inform.git") (commit commit))) (file-name (git-file-name name version)) (sha256 (base32 "19z8pgrj1s2irany5s6xxwsm3bdnri1as46fdi16zdp4aah523jy")))) (build-system gnu-build-system) (native-inputs (list autoconf automake)) (synopsis "The Inform 6 compiler") (description "Inform 6 is a programming language designed for interactive fiction. This version of the compiler has been modified slightly to work better when the Inform standard library is in a non-standard location.") (home-page "https://jxself.org/git/inform.git") (license license:gpl3+)))) (define-public informlib (package (name "informlib") (version "6.12.6") (source (origin (method git-fetch) (uri (git-reference (url "https://jxself.org/git/informlib.git") (commit (string-append "v" version)))) (file-name (git-file-name name version)) (sha256 (base32 "0fcnw4jjzln402qk097n2s8y24vw1p3mmlmh6k1mbr2zfajjcn5r")))) (build-system copy-build-system) (arguments (list #:install-plan #~'(("." "lib")))) (synopsis "Inform 6 standard library") (description "This package provides the standard library for Inform 6.") (home-page "https://jxself.org/git/informlib.git") (license license:agpl3+))) (define-public instead (package (name "instead") (version "3.3.5") (build-system cmake-build-system) (source (origin (method git-fetch) (uri (git-reference (url "https://github.com/instead-hub/instead") (commit version))) (file-name (git-file-name name version)) (sha256 (base32 "02j8cw623j51qmr4991i5hsbrzmnp0qfzds8m6nwwr15sjv3hv1g")) (patches (search-patches "instead-use-games-path.patch")) (modules '((guix build utils))) (snippet '(begin (delete-file-recursively "src/zlib"))))) (arguments '(#:configure-flags (list (string-append "-DLUA_INCLUDE_DIR=" (assoc-ref %build-inputs "luajit") "/include/luajit-2.1/") "-DWITH_LUAJIT=1" "-DWITH_GTK3=1") #:tests? #f)) (inputs `(("gtk+",gtk+) ("lua" ,lua) ("luajit" ,luajit) ("pkg-config" ,pkg-config) ("sdl2-images" ,sdl2-image) ("sdl2-ttf" ,sdl2-ttf) ("sdl2-mixer" ,sdl2-mixer) ("zlib" ,zlib))) (home-page "https://instead3.syscall.ru/") (synopsis "Text adventure interpreter") (description "The STEAD (Simple TExt ADventures) interpreter provides functionality to play games that mix elements of visual novels, interactive fiction and classic point-and-click adventures.") (native-search-paths (list (search-path-specification (variable "INSTEAD_GAMES_PATH") (separator #f) ;single entry (files '("share/instead/games"))))) (license license:expat))) (define-public openvr (package (name "openvr") (version "1.26.7") (home-page "https://github.com/ValveSoftware/openvr/") (source (origin (method git-fetch) (uri (git-reference (url home-page) (commit (string-append "v" version)))) (file-name (git-file-name name version)) (sha256 (base32 "09rvrja3pz6ggs41ra71p4dwjl4n0rpqrqw8jiy92xl33hhxbsmx")))) (build-system cmake-build-system) (arguments ;; No tests. '(#:tests? #f #:configure-flags (list "-DBUILD_SHARED=1"))) (synopsis "Virtual reality software development kit") (description "OpenVR is an API and runtime that allows access to VR hardware from multiple vendors without requiring that applications have specific knowledge of the hardware they are targeting.") (license license:bsd-3))) (define-public flatzebra (package (name "flatzebra") (version "0.2.0") (source (origin (method url-fetch) (uri (string-append "http://perso.b2b2c.ca/~sarrazip/dev/" "flatzebra-" version ".tar.gz")) (sha256 (base32 "1p1igi757m9a46v29mm7r40x61kdj7j66b9dbn53l5yfhnwa4w93")))) (build-system gnu-build-system) (native-inputs (list pkg-config)) (inputs (list sdl2 sdl2-gfx sdl2-image sdl2-mixer sdl2-ttf)) (home-page "http://perso.b2b2c.ca/~sarrazip/dev/burgerspace.html") (synopsis "Generic game engine for 2D double-buffering animation") (description "Flatzebra is a simple, generic C++ game engine library supporting 2D double-buffering.") (license license:gpl2+))) (define-public libccd (package (name "libccd") (version "2.1") (source (origin (method git-fetch) (uri (git-reference (url "https://github.com/danfis/libccd") (commit (string-append "v" version)))) (file-name (git-file-name name version)) (sha256 (base32 "0sfmn5pd7k5kyhbxnd689xmsa5v843r7sska96dlysqpljd691jc")))) (build-system cmake-build-system) (arguments `(#:configure-flags '("-DBUILD_DOCUMENTATION=ON" "-DBUILD_TESTING=ON" "-DENABLE_DOUBLE_PRECISION=ON"))) (native-inputs (list python-sphinx)) (home-page "https://github.com/danfis/libccd") (synopsis "Library for collision detection between two convex shapes") (description "@code{libccd} is library for a collision detection between two convex shapes. @code{libccd} implements variation on Gilbert–Johnson–Keerthi algorithm plus Expand Polytope Algorithm (EPA) and also implements algorithm Minkowski Portal Refinement (MPR, a.k.a. XenoCollide) as described in Game Programming Gems 7.") (license license:expat))) (define-public ode (package (name "ode") (version "0.16.5") (source (origin (method url-fetch) (uri (string-append "https://bitbucket.org/odedevs/ode/downloads/" "ode-" version ".tar.gz")) (sha256 (base32 "0ya6slmy2iysx3fql7w7r56c7gsk93qp1apfjn3raw252vfmx1xs")) (modules '((guix build utils))) (snippet '(begin (delete-file-recursively "libccd"))))) (build-system cmake-build-system) (arguments (list ;; XXX: The sole test is failing on i686 due to a rounding error. #:tests? (not (or (target-x86-32?) (%current-target-system))) #:configure-flags #~(list "-DODE_WITH_LIBCCD_SYSTEM=ON") #:phases #~(modify-phases %standard-phases (add-after 'unpack 'unbundle-libccd (lambda _ (substitute* "CMakeLists.txt" (("configure_file\\(libccd/.*") ""))))))) (inputs (list glu libccd mesa)) (home-page "https://www.ode.org/") (synopsis "High performance library for simulating rigid body dynamics") (description "ODE is a high performance library for simulating rigid body dynamics. It is fully featured, stable, mature and platform independent with an easy to use C/C++ API. It has advanced joint types and integrated collision detection with friction. ODE is useful for simulating vehicles, objects in virtual reality environments and virtual creatures. It is currently used in many computer games, 3D authoring tools and simulation tools.") ;; Software is dual-licensed. (license (list license:lgpl2.1+ license:expat)))) (define-public chipmunk (let ((commit "d0239ef4599b3688a5a336373f7d0a68426414ba") (revision "1")) (package (name "chipmunk") (version (git-version "7.0.3" revision commit)) (source (origin (method git-fetch) (uri (git-reference (url "https://github.com/slembcke/Chipmunk2D") (commit commit))) (file-name (git-file-name name version)) (sha256 (base32 "1910rfnanhna99bhfiyny3ki7aip2i9p4jzmwsfcg16m9gip5fd6")) (modules '((guix build utils))))) (build-system cmake-build-system) (arguments (list #:tests? #f ;no test #:configure-flags #~(list "-DBUILD_STATIC=OFF" "-DBUILD_DEMOS=OFF"))) (inputs (list freeglut libxmu libxrandr)) (home-page "https://chipmunk-physics.net/") (synopsis "Fast and lightweight 2D game physics library") (description "Chipmunk is a simple, lightweight, fast and portable 2D rigid body physics library written in C.") (license license:expat)))) (define-public box2d (package (name "box2d") (version "2.4.1") (source (origin (method git-fetch) (uri (git-reference (url "https://github.com/erincatto/box2d") (commit (string-append "v" version)))) (file-name (git-file-name name version)) (sha256 (base32 "1ja9cahf3z9zzrdaqcw44lpjmqf2ir2g4chwz0iwqwlkckwhpgvh")) (modules '((guix build utils))) (snippet '(begin ;; Remove bundled code only used for the testbed. (delete-file-recursively "extern") ;; Remove bundled copy of doctest, and adjust tests accordingly. (delete-file "unit-test/doctest.h") (substitute* "unit-test/CMakeLists.txt" (("doctest\\.h") "")) (substitute* (find-files "unit-test" "\\.cpp$") (("include \"doctest\\.h\"") "include <doctest/doctest.h>")))))) (build-system cmake-build-system) (arguments `(#:test-target "unit_test" #:configure-flags '("-DBUILD_SHARED_LIBS=ON" "-DBOX2D_BUILD_TESTBED=OFF"))) (native-inputs (list doctest)) ;for tests (inputs (list libx11)) (home-page "https://box2d.org/") (synopsis "2D physics engine for games") (description "Box2D is a 2D rigid body simulation library for games. Programmers can use it in their games to make objects move in realistic ways and make the game world more interactive. From the game engine's point of view, a physics engine is just a system for procedural animation.") (license license:expat))) (define-public libtcod (package (name "libtcod") (version "1.15.1") (source (origin (method git-fetch) (uri (git-reference (url "https://github.com/libtcod/libtcod") (commit version))) (file-name (git-file-name name version)) (sha256 (base32 "0pzr8ajmbqvh43ldjajx962xirj3rf8ayh344p6mqlrmb8gxrfr5")) (modules '((guix build utils))) (snippet '(begin (delete-file-recursively "src/vendor/utf8proc") (delete-file-recursively "src/vendor/zlib") (delete-file "src/vendor/stb_truetype.h") (delete-file "src/vendor/stb_sprintf.h") (delete-file "src/vendor/lodepng.cpp") (delete-file "src/vendor/lodepng.h") (substitute* "buildsys/autotools/sources.am" (("\\.\\./\\.\\./src/vendor/lodepng\\.cpp \\\\\n") "") (("\\.\\./\\.\\./src/vendor/stb\\.c \\\\") "../../src/vendor/stb.c") (("\\.\\./\\.\\./src/vendor/utf8proc/utf8proc\\.c") "")) (substitute* "src/libtcod/sys_sdl_img_png.cpp" (("\\.\\./vendor/") "")) (substitute* '("src/libtcod/color/canvas.cpp" "src/libtcod/sys_sdl_img_png.cpp" "src/libtcod/tileset/truetype.cpp" "src/libtcod/tileset/tilesheet.cpp") (("\\.\\./\\.\\./vendor/") "")) (substitute* "src/libtcod/console/printing.cpp" (("\\.\\./\\.\\./vendor/utf8proc/") "")) #t)))) (build-system gnu-build-system) (arguments `(#:configure-flags '("--with-gnu-ld" "LIBS=-lutf8proc -llodepng") #:phases (modify-phases %standard-phases (add-after 'unpack 'change-to-build-dir (lambda _ (chdir "buildsys/autotools") (patch-shebang "get_version.py")))))) (native-inputs (list autoconf automake libtool python pkg-config stb-sprintf stb-truetype)) (inputs (list lodepng sdl2 utf8proc zlib)) (home-page "https://github.com/libtcod/libtcod") (synopsis "Library specifically designed for writing roguelikes") (description "libtcod is a fast, portable and uncomplicated API for roguelike developers providing an advanced true color console, input, and lots of other utilities frequently used in roguelikes.") (license license:bsd-3))) (define-public warsow-qfusion ;; As of 2020-04-09, the latest stable version 2.1.0 is deprecated. ;; The 2.5 beta as published on the homepage is commit ;; c4de15df559410aff0ca6643724e24cddb0ecbbd (let ((commit "c4de15df559410aff0ca6643724e24cddb0ecbbd")) (package (name "warsow-qfusion") (version (git-version "2.5" "1" commit)) ; 2.5-beta (source (origin (method git-fetch) (uri (git-reference (url "https://github.com/Warsow/qfusion/") (commit commit) (recursive? #t))) (file-name (git-file-name name version)) (sha256 (base32 "0xv2yycr43p3xmq7lm6j6zb3cpcr6w00x7qg918faq0mw9j7v48g")) ;; Issue reported here: https://github.com/Warsow/qfusion/issues/46 (patches (search-patches "warsow-qfusion-fix-bool-return-type.patch")) (modules '((guix build utils))) (snippet '(begin (delete-file-recursively "platforms") (delete-file-recursively "debian") (delete-file-recursively "libsrcs") #t)))) (build-system cmake-build-system) (arguments `(#:tests? #f ; No tests. #:configure-flags '("-DQFUSION_GAME=Warsow") #:modules ((guix build utils) (guix build cmake-build-system) (ice-9 match)) #:phases (modify-phases %standard-phases (add-after 'unpack 'change-to-build-dir (lambda _ (chdir "source") #t)) (add-after 'install 'really-install (lambda* (#:key outputs system #:allow-other-keys) (let ((arch (match system ("x86_64-linux" "x86_64") ("i686-linux" "i386"))) (out (assoc-ref outputs "out"))) (install-file (string-append "../source/build/basewsw/libgame_" arch ".so") (string-append out "/lib/")) (install-file (string-append "../source/build/libui_" arch ".so") (string-append out "/lib/")) (for-each (lambda (file) (install-file file (string-append out "/bin/"))) (append (find-files "../source/build" "warsow") (find-files "../source/build" "wsw_server.")))) #t))))) (inputs `(("alsa-lib" ,alsa-lib) ("curl" ,curl) ("freetype" ,freetype) ("ffmpeg" ,ffmpeg-4) ("libjpeg" ,libjpeg-turbo) ("libogg" ,libogg) ("libpng" ,libpng) ("libtheora" ,libtheora) ("libvorbis" ,libvorbis) ("mesa" ,mesa) ("openal" ,openal) ("pulseaudio" ,pulseaudio) ("qtbase" ,qtbase-5) ("qtdeclarative-5" ,qtdeclarative-5) ("sdl2" ,sdl2) ("uuid.h" ,util-linux "lib") ("zlib" ,zlib))) (native-inputs (list pkg-config)) (home-page "https://github.com/Warsow/qfusion") (supported-systems '("i686-linux" "x86_64-linux")) (synopsis "Warsow's fork of qfusion, the id Tech 2 derived game engine") (description "This package contains the game engine of Warsow, a first-person shooter video game. The engine is based on qfusion, the id Tech 2 derived game engine. id Tech 2 is the engine originally behind Quake 2.") (license license:gpl2+)))) (define-public dhewm3 (package (name "dhewm3") (version "1.5.3") (source (origin (method git-fetch) (uri (git-reference (url "https://github.com/dhewm/dhewm3") (commit version))) (file-name (git-file-name name version)) (sha256 (base32 "1zbwhrngmgb0969izmxididyx892qk7591aa9mbigakw6dvmlm84")))) (build-system cmake-build-system) (arguments (list #:tests? #f ; No tests. #:phases #~(modify-phases %standard-phases (add-after 'unpack 'change-to-build-dir (lambda _ (chdir "neo")))))) (inputs (list curl libx11 openal sdl2 zlib)) (home-page "https://dhewm3.org/") (synopsis "Port of the original Doom 3 engine") (description "@command{dhewm3} is a source port of the original Doom 3 engine (not Doom 3: BFG Edition), also known as id Tech 4. Compared to the original version of the Doom 3 engine, dhewm3 has many bugfixes, supports EAX-like sound effects on all operating systems and hardware (via OpenAL Softs EFX support), has much better support for widescreen resolutions and has 64bit support.") (license license:gpl3))) (define-public tesseract-engine (let ((svn-revision 2411)) (package (name "tesseract-engine") (version (string-append "20200615-" (number->string svn-revision))) (source (origin (method svn-fetch) (uri (svn-reference (url "svn://svn.tuxfamily.org/svnroot/tesseract/main") (revision svn-revision))) (file-name (git-file-name name version)) (sha256 (base32 "1av9jhl2ivbl7wfszyhyna84llvh1z2d8khkmadm8d105addj10q")) (modules '((guix build utils))) (snippet '(begin (for-each delete-file-recursively '("bin" "bin64" ;; Remove "media" since some files such as ;; media/sound/game/soundsnap/info.txt refer to a ;; non-commercial license. "media" "server.bat" "tesseract.bat" "src/lib" "src/lib64")) #t)))) (build-system gnu-build-system) (arguments `(#:make-flags (list "CC=gcc") #:tests? #f ; No tests. #:phases (modify-phases %standard-phases (delete 'configure) (add-after 'unpack 'cd-src (lambda _ (chdir "src") #t)) (add-before 'build 'fix-env (lambda* (#:key inputs #:allow-other-keys) (setenv "CPATH" (string-append (search-input-directory inputs "include/SDL2") ":" (or (getenv "CPATH") ""))))) (add-after 'install 'really-install (lambda* (#:key outputs #:allow-other-keys) (let* ((out (assoc-ref outputs "out")) (share (string-append out "/share/tesseract")) (bin (string-append out "/bin/tesseract")) (client (string-append out "/bin/tesseract-client"))) (chdir "..") ; Back to root. (for-each (lambda (dir) (mkdir-p (string-append share "/" dir)) (copy-recursively dir (string-append share "/" dir))) '("config")) (mkdir-p (string-append out "/bin/")) (copy-file "bin_unix/native_client" client) (copy-file "bin_unix/native_server" (string-append out "/bin/tesseract-server")) (call-with-output-file bin (lambda (p) (format p "#!~a TESS_DATA=~a TESS_BIN=~a TESS_OPTIONS=\"-u$HOME/.tesseract\" cd \"$TESS_DATA\" exec \"$TESS_BIN\" \"$TESS_OPTIONS\" \"$@\"" (which "bash") share client))) (chmod bin #o755) (install-file "src/readme_tesseract.txt" (string-append out "/share/licenses/tesseract/LICENSE"))) #t))))) (inputs `(("sdl2-union" ,(sdl-union (list sdl2 sdl2-mixer sdl2-image))) ("zlib" ,zlib) ("libpng" ,libpng) ("libgl" ,mesa))) (home-page "http://tesseract.gg/") (synopsis "First-person shooter engine with map editing, instagib, DM and CTF") (description "This package contains the game engine of Tesseract, a first-person shooter focused on cooperative in-game map editing. The engine is derived from @emph{Cube 2: Sauerbraten} technology but with upgraded modern rendering techniques. The new rendering features include fully dynamic omnidirectional shadows, global illumination, HDR lighting, deferred shading, morphological / temporal / multisample anti-aliasing, and much more.") (license license:zlib)))) (define-public recastnavigation (package (name "recastnavigation") (version "1.6.0") (source (origin (method git-fetch) (uri (git-reference (url "https://github.com/recastnavigation/recastnavigation") (commit (string-append "v" version)))) (file-name (git-file-name name version)) (sha256 (base32 "0rdz3qmp4b961zjah2ax82h471j14w2rcf576gcyx7vldrg8dmj8")))) (build-system cmake-build-system) (arguments `(#:configure-flags (list "-DBUILD_SHARED_LIBS=ON" "-DRECASTNAVIGATION_DEMO=OFF" "-DRECASTNAVIGATION_TESTS=ON" "-DRECASTNAVIGATION_EXAMPLES=OFF"))) (synopsis "Navigation system for games") (description "Recast is state of the art navigation mesh construction toolset for games. @itemize @item It is automatic, which means that you can throw any level geometry at it and you will get robust mesh out. @item It is fast which means swift turnaround times for level designers. @end itemize The Recast process starts with constructing a voxel mold from a level geometry and then casting a navigation mesh over it. The process consists of three steps, building the voxel mold, partitioning the mold into simple regions, peeling off the regions as simple polygons. Recast is accompanied with Detour, path-finding and spatial reasoning toolkit. You can use any navigation mesh with Detour, but of course the data generated with Recast fits perfectly. Detour offers simple static navigation mesh which is suitable for many simple cases, as well as tiled navigation mesh which allows you to plug in and out pieces of the mesh. The tiled mesh allows you to create systems where you stream new navigation data in and out as the player progresses the level, or you may regenerate tiles as the world changes.") (home-page "https://github.com/recastnavigation/recastnavigation") (license license:zlib))) (define-public raylib (package (name "raylib") (version "5.0") (source (origin (method git-fetch) (uri (git-reference (url "https://github.com/raysan5/raylib/") (commit version))) (file-name (git-file-name name version)) ;; TODO: Unbundle src/external (sha256 (base32 "0327licmylwlh5iyzw35pq7ci2d15rp3jms5i9p0vfg1rlv2sjw0")))) (build-system cmake-build-system) (arguments (list #:tests? #f ;no test #:configure-flags #~(list "-DBUILD_SHARED_LIBS=ON" "-DUSE_EXTERNAL_GLFW=ON" "-DCMAKE_C_FLAGS=-lpulse") #:phases #~(modify-phases %standard-phases (add-before 'configure 'configure-miniaudio ;; Use PulseAudio as raudio backend. (lambda _ (substitute* "src/raudio.c" (("^#include \"external/miniaudio\\.h\"") " #define MA_NO_RUNTIME_LINKING #define MA_ENABLE_ONLY_SPECIFIC_BACKENDS #define MA_ENABLE_PULSEAUDIO #include \"external/miniaudio.h\" "))))))) (inputs (list glfw pulseaudio)) (native-inputs (list pkg-config)) (synopsis "C library for videogame programming") (description "raylib is a high-level library for video game programming. It aims to abstract away platform and graphics details, allowing you to focus on writing your game.") (home-page "https://www.raylib.com/") (license license:zlib))) (define-public bbcsdl (package (name "bbcsdl") (version "1.39a") (source (origin (method git-fetch) (uri (git-reference (url "https://github.com/rtrussell/BBCSDL/") (commit "93b0ffae960f4c4f45fdc2202bc6e83ee5ca277c"))) (file-name (git-file-name name version)) (sha256 (base32 "03ga14k2hbhflnaynbyx9lwlbxlzx3rv6zqq21yhl183s6d4c0wa")))) (build-system gnu-build-system) (arguments (list #:tests? #f ; XXX: tests not automated #:phases #~(modify-phases %standard-phases (delete 'configure) ; no configure script (replace 'build (lambda* (#:key outputs #:allow-other-keys) ;; 'makefile' expects the source directory to be named 'BBCSDL'. (symlink "source" "../BBCSDL") ;; 'bbcsdl' finds 'libstb.so' in its RPATH. (substitute* "bin/linux/makefile" (("-Wl,-R,'\\$\\$ORIGIN'") (string-append "-Wl,-rpath=" (assoc-ref outputs "out") "/opt/bbcsdl"))) ;; Build 'bbcbasic' and 'bbcsdl'. (invoke "make" "-C" "console/linux") (invoke "make" "-C" "bin/linux"))) (replace 'install (lambda* (#:key inputs outputs #:allow-other-keys) (let* ((out (assoc-ref outputs "out")) (opt (string-append out "/opt/bbcsdl")) (bin (string-append out "/bin"))) (for-each (lambda (f) (copy-recursively f (string-append opt "/" f))) ;; Those files need to be installed into the same difertory. '("lib" "examples" "bbcsdl.bbc" "libstb.so" "bbcsdl" "bbcbasic")) ;; Replace bundled fonts. (for-each (lambda (font) (delete-file (string-append opt "/lib/" font)) (symlink (search-input-file inputs (string-append "share/fonts/truetype/" font)) (string-append opt "/lib/" font))) '("DejaVuSans.ttf" "DejaVuSansMono.ttf" "DejaVuSans-Oblique.ttf" "FreeSans.ttf" "FreeMono.ttf" "FreeSerif.ttf")) (mkdir bin) (symlink (string-append opt "/bbcsdl") (string-append bin "/bbcsdl")) (symlink (string-append opt "/bbcbasic") (string-append bin "/bbcbasic")))))))) (native-inputs (list nasm)) (inputs (list sdl2 sdl2-ttf sdl2-net font-dejavu font-gnu-freefont)) (synopsis "BBC BASIC for SDL 2.0") (home-page "https://www.bbcbasic.co.uk/bbcsdl/") (description "BBC BASIC is the programming language originally specified and adopted by the British Broadcasting Corporation for its groundbreaking Computer Literacy Project of the early 1980s. BBC BASIC for SDL 2.0 combines the simplicity of BASIC with the sophistication of a modern structured language, allowing you to write utilities and games, use sound and graphics, perform calculations and create complete applications.") (license license:zlib)))