diff options
| -rw-r--r-- | Makefile.am | 2 | ||||
| -rw-r--r-- | guix/build-system/hare.scm | 144 | ||||
| -rw-r--r-- | guix/build/hare-build-system.scm | 63 |
3 files changed, 209 insertions, 0 deletions
diff --git a/Makefile.am b/Makefile.am index a4e7277d6d4..459f3f4b6b7 100644 --- a/Makefile.am +++ b/Makefile.am | |||
| @@ -170,6 +170,7 @@ MODULES = \ | |||
| 170 | guix/build-system/gnu.scm \ | 170 | guix/build-system/gnu.scm \ |
| 171 | guix/build-system/go.scm \ | 171 | guix/build-system/go.scm \ |
| 172 | guix/build-system/guile.scm \ | 172 | guix/build-system/guile.scm \ |
| 173 | guix/build-system/hare.scm \ | ||
| 173 | guix/build-system/haskell.scm \ | 174 | guix/build-system/haskell.scm \ |
| 174 | guix/build-system/julia.scm \ | 175 | guix/build-system/julia.scm \ |
| 175 | guix/build-system/linux-module.scm \ | 176 | guix/build-system/linux-module.scm \ |
| @@ -240,6 +241,7 @@ MODULES = \ | |||
| 240 | guix/build/gnu-build-system.scm \ | 241 | guix/build/gnu-build-system.scm \ |
| 241 | guix/build/gnu-dist.scm \ | 242 | guix/build/gnu-dist.scm \ |
| 242 | guix/build/guile-build-system.scm \ | 243 | guix/build/guile-build-system.scm \ |
| 244 | guix/build/hare-build-system.scm \ | ||
| 243 | guix/build/luanti-build-system.scm \ | 245 | guix/build/luanti-build-system.scm \ |
| 244 | guix/build/maven-build-system.scm \ | 246 | guix/build/maven-build-system.scm \ |
| 245 | guix/build/minetest-build-system.scm \ | 247 | guix/build/minetest-build-system.scm \ |
diff --git a/guix/build-system/hare.scm b/guix/build-system/hare.scm new file mode 100644 index 00000000000..6b5f7096804 --- /dev/null +++ b/guix/build-system/hare.scm | |||
| @@ -0,0 +1,144 @@ | |||
| 1 | ;;; GNU Guix --- Functional package management for GNU | ||
| 2 | ;;; Copyright © 2025 Lilah Tascheter <lilah@lunabee.space> | ||
| 3 | ;;; | ||
| 4 | ;;; This file is part of GNU Guix. | ||
| 5 | ;;; | ||
| 6 | ;;; GNU Guix is free software; you can redistribute it and/or modify it | ||
| 7 | ;;; under the terms of the GNU General Public License as published by | ||
| 8 | ;;; the Free Software Foundation; either version 3 of the License, or (at | ||
| 9 | ;;; your option) any later version. | ||
| 10 | ;;; | ||
| 11 | ;;; GNU Guix is distributed in the hope that it will be useful, but | ||
| 12 | ;;; WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 13 | ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 14 | ;;; GNU General Public License for more details. | ||
| 15 | ;;; | ||
| 16 | ;;; You should have received a copy of the GNU General Public License | ||
| 17 | ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>. | ||
| 18 | |||
| 19 | (define-module (guix build-system hare) | ||
| 20 | #:use-module (guix build-system) | ||
| 21 | #:use-module (guix build-system gnu) | ||
| 22 | #:use-module (guix gexp) | ||
| 23 | #:use-module (guix monads) | ||
| 24 | #:use-module (guix packages) | ||
| 25 | #:use-module (guix search-paths) | ||
| 26 | #:use-module (guix store) | ||
| 27 | #:use-module (guix utils) | ||
| 28 | #:export (%hare-supported-systems | ||
| 29 | target->hare-arch | ||
| 30 | %default-hare-imported-modules | ||
| 31 | %default-hare-modules | ||
| 32 | hare-build-system)) | ||
| 33 | |||
| 34 | (define %hare-supported-systems | ||
| 35 | '("x86_64-linux" "aarch64-linux" "riscv64-linux")) | ||
| 36 | |||
| 37 | (define* (target->hare-arch #:optional (target (or (%current-target-system) | ||
| 38 | (%current-system)))) | ||
| 39 | ;; Only error on supported systems, so we don't break guix pull. | ||
| 40 | (if (member (%current-system) %hare-supported-systems) | ||
| 41 | (cond ((target-x86-64? target) "x86_64") | ||
| 42 | ((target-aarch64? target) "aarch64") | ||
| 43 | ((target-riscv64? target) "riscv64") | ||
| 44 | (else (error "unsupported hare target" target))) | ||
| 45 | "UNKNOWN")) | ||
| 46 | |||
| 47 | (define %default-hare-imported-modules | ||
| 48 | (cons '(guix build hare-build-system) %default-gnu-imported-modules)) | ||
| 49 | (define %default-hare-modules | ||
| 50 | '((guix build hare-build-system) (guix build utils))) | ||
| 51 | |||
| 52 | (define* (lower name #:key source inputs native-inputs outputs system target | ||
| 53 | (implicit-inputs? #t) (implicit-cross-inputs? #t) | ||
| 54 | #:allow-other-keys #:rest arguments) | ||
| 55 | (let* ((hare (module-ref (resolve-interface '(gnu packages hare)) 'hare)) | ||
| 56 | (private-arguments '(#:inputs #:native-inputs #:target | ||
| 57 | #:build-inputs #:target-inputs #:host-inputs | ||
| 58 | #:implicit-inputs? #:implicit-cross-inputs?))) | ||
| 59 | (bag | ||
| 60 | (name name) | ||
| 61 | (system system) | ||
| 62 | (target target) | ||
| 63 | (arguments (strip-keyword-arguments private-arguments arguments)) | ||
| 64 | (build-inputs (append (if source `(("source" ,source)) '()) | ||
| 65 | native-inputs | ||
| 66 | (if implicit-inputs? `(("hare" ,hare)) '()) | ||
| 67 | (if (and implicit-cross-inputs? target) | ||
| 68 | (standard-cross-packages target 'host) '()) | ||
| 69 | (if implicit-inputs? | ||
| 70 | (standard-packages system) '()))) | ||
| 71 | (host-inputs inputs) | ||
| 72 | (target-inputs (if (and implicit-cross-inputs? target) | ||
| 73 | (standard-cross-packages target 'target) '())) | ||
| 74 | (outputs outputs) | ||
| 75 | (build (if target hare-build (lambda (name inputs . rest) | ||
| 76 | (apply hare-build name | ||
| 77 | #:host-inputs inputs rest))))))) | ||
| 78 | |||
| 79 | (define* (hare-build name #:key guile system (target #f) source | ||
| 80 | (build-inputs '()) (target-inputs '()) (host-inputs '()) | ||
| 81 | (phases '%standard-phases) (outputs '("out")) | ||
| 82 | (imported-modules %default-hare-imported-modules) | ||
| 83 | (modules %default-hare-modules) | ||
| 84 | |||
| 85 | (search-paths '()) (native-search-paths '()) | ||
| 86 | (make-flags ''()) (hare-arch #f) | ||
| 87 | (parallel-builds? #t) | ||
| 88 | (tests? #t) (test-target "check") (parallel-tests? #t) | ||
| 89 | (binary-output (if (member "bin" outputs) "bin" "out")) | ||
| 90 | (module-output (if (member "lib" outputs) "lib" "out")) | ||
| 91 | (validate-runpath? #t) | ||
| 92 | |||
| 93 | (substitutable? #t) | ||
| 94 | allowed-references disallowed-references) | ||
| 95 | (define builder | ||
| 96 | (with-imported-modules imported-modules | ||
| 97 | #~(begin (use-modules #$@modules) | ||
| 98 | (define %build-host-inputs #+(input-tuples->gexp build-inputs)) | ||
| 99 | (define %build-target-inputs | ||
| 100 | (append #$(input-tuples->gexp host-inputs) | ||
| 101 | #+(input-tuples->gexp target-inputs))) | ||
| 102 | (define %build-inputs | ||
| 103 | (append %build-host-inputs %build-target-inputs)) | ||
| 104 | |||
| 105 | (define %outputs #$(outputs->gexp outputs)) | ||
| 106 | (define %binary-output (assoc-ref %outputs #$binary-output)) | ||
| 107 | (define %module-output (assoc-ref %outputs #$module-output)) | ||
| 108 | |||
| 109 | (hare-build | ||
| 110 | #:source #+source | ||
| 111 | #:system #$system | ||
| 112 | #:target #$target | ||
| 113 | #:phases #$phases | ||
| 114 | #:inputs %build-target-inputs | ||
| 115 | #:native-inputs %build-host-inputs | ||
| 116 | #:outputs %outputs | ||
| 117 | #:search-paths '#$(map search-path-specification->sexp search-paths) | ||
| 118 | #:native-search-paths '#$(map search-path-specification->sexp | ||
| 119 | native-search-paths) | ||
| 120 | #:hare-arch #$(or hare-arch (target->hare-arch (or target system))) | ||
| 121 | #:binary-output %binary-output | ||
| 122 | #:module-output %module-output | ||
| 123 | #:make-flags #$make-flags | ||
| 124 | #:parallel-builds? #$parallel-builds? | ||
| 125 | #:tests? #$tests? | ||
| 126 | #:test-target #$test-target | ||
| 127 | #:parallel-tests? #$parallel-tests? | ||
| 128 | #:validate-runpath? #$validate-runpath?)))) | ||
| 129 | (mlet %store-monad ((guile (package->derivation (or guile (default-guile)) | ||
| 130 | system #:graft? #f))) | ||
| 131 | (gexp->derivation name builder | ||
| 132 | #:system system | ||
| 133 | #:target target | ||
| 134 | #:graft? #f ; same as gnu-build-system | ||
| 135 | #:substitutable? substitutable? | ||
| 136 | #:allowed-references allowed-references | ||
| 137 | #:disallowed-references disallowed-references | ||
| 138 | #:guile-for-build guile))) | ||
| 139 | |||
| 140 | (define hare-build-system | ||
| 141 | (build-system | ||
| 142 | (name 'hare) | ||
| 143 | (description "Hare de facto build systems") | ||
| 144 | (lower lower))) | ||
diff --git a/guix/build/hare-build-system.scm b/guix/build/hare-build-system.scm new file mode 100644 index 00000000000..9853011e22f --- /dev/null +++ b/guix/build/hare-build-system.scm | |||
| @@ -0,0 +1,63 @@ | |||
| 1 | ;;; GNU Guix --- Functional package management for GNU | ||
| 2 | ;;; Copyright © 2025 Lilah Tascheter <lilah@lunabee.space> | ||
| 3 | ;;; | ||
| 4 | ;;; This file is part of GNU Guix. | ||
| 5 | ;;; | ||
| 6 | ;;; GNU Guix is free software; you can redistribute it and/or modify it | ||
| 7 | ;;; under the terms of the GNU General Public License as published by | ||
| 8 | ;;; the Free Software Foundation; either version 3 of the License, or (at | ||
| 9 | ;;; your option) any later version. | ||
| 10 | ;;; | ||
| 11 | ;;; GNU Guix is distributed in the hope that it will be useful, but | ||
| 12 | ;;; WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 13 | ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 14 | ;;; GNU General Public License for more details. | ||
| 15 | ;;; | ||
| 16 | ;;; You should have received a copy of the GNU General Public License | ||
| 17 | ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>. | ||
| 18 | |||
| 19 | (define-module (guix build hare-build-system) | ||
| 20 | #:use-module ((guix build gnu-build-system) #:prefix gnu:) | ||
| 21 | #:use-module (guix build utils) | ||
| 22 | #:export (%standard-phases | ||
| 23 | hare-build)) | ||
| 24 | |||
| 25 | (define (invoke-gnu-phase name args) | ||
| 26 | (apply (assoc-ref gnu:%standard-phases name) args)) | ||
| 27 | |||
| 28 | (define* (set-paths #:key inputs #:allow-other-keys #:rest args) | ||
| 29 | "Sets proper PATH, HAREPATH, and pulled-in search paths." | ||
| 30 | (invoke-gnu-phase 'set-paths args) | ||
| 31 | ;; XXX: bag->derivation doesn't consider non-native search paths | ||
| 32 | (set-path-environment-variable "HAREPATH" '("share/hare") | ||
| 33 | (map cdr (alist-delete "source" inputs)))) | ||
| 34 | |||
| 35 | (define* (build #:key hare-arch (make-flags '()) #:allow-other-keys #:rest args) | ||
| 36 | "Builds Hare binaries through a provided Makefile." | ||
| 37 | ;; HAREFLAGS seems to be typically supported, but we have to just guess. | ||
| 38 | ;; Later args override earlier ones, so packages can override HAREFLAGS. | ||
| 39 | (let* ((hareflags (format #f "HAREFLAGS=-a ~a" hare-arch)) | ||
| 40 | (flags (cons* hareflags make-flags))) | ||
| 41 | (invoke-gnu-phase 'build (append args (list #:make-flags flags))))) | ||
| 42 | |||
| 43 | (define* (install #:key (make-flags '()) binary-output module-output | ||
| 44 | #:allow-other-keys #:rest args) | ||
| 45 | "Install Hare modules and binaries through a provided Makefile." | ||
| 46 | ;; Same deal here as in build. These seem to be the most common relevant | ||
| 47 | ;; variables. Packages can override as needed. | ||
| 48 | (let* ((prefix (format #f "PREFIX=~a" binary-output)) ; for manpages mostly | ||
| 49 | (bindir (format #f "BINDIR=~a/bin" binary-output)) | ||
| 50 | (srcdir (format #f "SRCDIR=~a/share/hare" module-output)) | ||
| 51 | (moddir (format #f "THIRDPARTYDIR=~a/share/hare" module-output)) | ||
| 52 | (flags (cons* prefix bindir srcdir moddir make-flags))) | ||
| 53 | (invoke-gnu-phase 'install (append args (list #:make-flags flags))))) | ||
| 54 | |||
| 55 | (define %standard-phases | ||
| 56 | (modify-phases gnu:%standard-phases | ||
| 57 | (replace 'set-paths set-paths) | ||
| 58 | (delete 'bootstrap) | ||
| 59 | (delete 'configure) | ||
| 60 | (replace 'build build) | ||
| 61 | (replace 'install install))) | ||
| 62 | |||
| 63 | (define hare-build gnu:gnu-build) | ||
