diff options
| author | Lilah Tascheter <lilah@lunabee.space> | 2025-08-06 12:01:42 -0500 |
|---|---|---|
| committer | Liliana Marie Prikler <liliana.prikler@gmail.com> | 2025-09-02 10:46:11 +0200 |
| commit | accf2b991a774036df2b4b9d8e98393e0aeef941 (patch) | |
| tree | 497817343c8e61310c4fc0e436403e122b69d1c1 | |
| parent | 24c6db8b7ea47ea05c57a0f3927ef7daa6ae0bdb (diff) | |
gnu: packages: Add harec.
* gnu/packages/hare.scm: New file.
* gnu/local.mk (GNU_SYSTEM_MODULES): Add above file.
Change-Id: I8c10e3e5cfcdccc6b7b47a35426d66c4b77d3f14
Signed-off-by: Liliana Marie Prikler <liliana.prikler@gmail.com>
| -rw-r--r-- | gnu/local.mk | 1 | ||||
| -rw-r--r-- | gnu/packages/hare.scm | 107 |
2 files changed, 108 insertions, 0 deletions
diff --git a/gnu/local.mk b/gnu/local.mk index ed51c6dc82a..c81ed7f5f2d 100644 --- a/gnu/local.mk +++ b/gnu/local.mk | |||
| @@ -356,6 +356,7 @@ GNU_SYSTEM_MODULES = \ | |||
| 356 | %D%/packages/gv.scm \ | 356 | %D%/packages/gv.scm \ |
| 357 | %D%/packages/gxmessage.scm \ | 357 | %D%/packages/gxmessage.scm \ |
| 358 | %D%/packages/hardware.scm \ | 358 | %D%/packages/hardware.scm \ |
| 359 | %D%/packages/hare.scm \ | ||
| 359 | %D%/packages/haskell.scm \ | 360 | %D%/packages/haskell.scm \ |
| 360 | %D%/packages/haskell-apps.scm \ | 361 | %D%/packages/haskell-apps.scm \ |
| 361 | %D%/packages/haskell-check.scm \ | 362 | %D%/packages/haskell-check.scm \ |
diff --git a/gnu/packages/hare.scm b/gnu/packages/hare.scm new file mode 100644 index 00000000000..90ce1493e68 --- /dev/null +++ b/gnu/packages/hare.scm | |||
| @@ -0,0 +1,107 @@ | |||
| 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 (gnu packages hare) | ||
| 20 | #:use-module (gnu packages) | ||
| 21 | #:use-module (gnu packages base) | ||
| 22 | #:use-module (gnu packages c) | ||
| 23 | #:use-module (gnu packages commencement) | ||
| 24 | #:use-module (gnu packages cross-base) | ||
| 25 | #:use-module (gnu packages less) | ||
| 26 | #:use-module (gnu packages man) | ||
| 27 | #:use-module (guix build-system gnu) | ||
| 28 | #:use-module (guix gexp) | ||
| 29 | #:use-module (guix git-download) | ||
| 30 | #:use-module ((guix licenses) #:prefix license:) | ||
| 31 | #:use-module (guix packages) | ||
| 32 | #:use-module (guix search-paths) | ||
| 33 | #:use-module (guix utils) | ||
| 34 | #:export (hare-supported-systems | ||
| 35 | target->hare-arch)) | ||
| 36 | |||
| 37 | (define hare-supported-systems | ||
| 38 | '("x86_64-linux" "aarch64-linux" "riscv64-linux")) | ||
| 39 | |||
| 40 | (define* (target->hare-arch #:optional (target (or (%current-target-system) | ||
| 41 | (%current-system)))) | ||
| 42 | (cond ((target-x86-64? target) "x86_64") | ||
| 43 | ((target-aarch64? target) "aarch64") | ||
| 44 | ((target-riscv64? target) "riscv64") | ||
| 45 | (else (error "unsupported hare target" target)))) | ||
| 46 | |||
| 47 | (define (cross-target? target) ; only has to work for supported arches | ||
| 48 | (and target (not (if (%current-target-system) | ||
| 49 | (string=? (%current-target-system) target) | ||
| 50 | (string-prefix? (%current-system) target))))) | ||
| 51 | |||
| 52 | (define (tools-for-target target) | ||
| 53 | (let* ((cross? (and=> target cross-target?)) | ||
| 54 | (with-target (lambda (f) (if cross? (f target) (f)))) | ||
| 55 | (prefix (string-upcase (with-target target->hare-arch))) | ||
| 56 | (prefix-for (lambda (v) (if target (string-append prefix "_" v) v))) | ||
| 57 | (toolchain (if cross? (cross-gcc-toolchain target) gcc-toolchain)) | ||
| 58 | (bin-for (lambda (t) (file-append toolchain "/bin/" (with-target t))))) | ||
| 59 | #~((#$(prefix-for "CC") #$(bin-for cc-for-target)) | ||
| 60 | (#$(prefix-for "AS") #$(bin-for as-for-target)) | ||
| 61 | (#$(prefix-for "LD") #$(bin-for ld-for-target))))) | ||
| 62 | |||
| 63 | (define hare-config ; unified build config for hare packages | ||
| 64 | (computed-file "hare-config.mk" | ||
| 65 | #~(begin (use-modules (ice-9 format)) | ||
| 66 | (call-with-output-file #$output | ||
| 67 | (lambda (port) | ||
| 68 | (format port "include configs/linux.mk~%~:{~a=~a~%~}" | ||
| 69 | `(("ARCH" ,#$(target->hare-arch)) | ||
| 70 | ("DEFAULT_TARGET" "$(ARCH)") | ||
| 71 | ("STDLIB" "$(PREFIX)/share/hare") | ||
| 72 | ("HAREPATH" "$(PREFIX)/share/hare") | ||
| 73 | #$@(tools-for-target #f) | ||
| 74 | #$@(tools-for-target "aarch64-linux-gnu") | ||
| 75 | #$@(tools-for-target "riscv64-linux-gnu") | ||
| 76 | #$@(tools-for-target "x86_64-linux-gnu")))))))) | ||
| 77 | |||
| 78 | (define-public harec | ||
| 79 | (package | ||
| 80 | (name "harec") | ||
| 81 | (version "0.25.2") | ||
| 82 | (source (origin | ||
| 83 | (method git-fetch) | ||
| 84 | (uri (git-reference | ||
| 85 | (url "https://git.sr.ht/~sircmpwn/harec") | ||
| 86 | (commit version))) | ||
| 87 | (file-name (git-file-name name version)) | ||
| 88 | (sha256 | ||
| 89 | (base32 | ||
| 90 | "0qyhni011116wc194kkybmiphmi1cak0n8kxgiq7v174xsh9irp7")))) | ||
| 91 | (build-system gnu-build-system) | ||
| 92 | (arguments | ||
| 93 | (list #:modules `((ice-9 format) ,@%default-gnu-modules) | ||
| 94 | #:make-flags #~(list (string-append "PREFIX=" #$output) | ||
| 95 | (string-append "VERSION=" #$version)) | ||
| 96 | #:phases | ||
| 97 | #~(modify-phases %standard-phases | ||
| 98 | (replace 'configure | ||
| 99 | (lambda _ (copy-file #$hare-config "config.mk")))))) | ||
| 100 | (native-inputs (list qbe)) | ||
| 101 | (supported-systems hare-supported-systems) | ||
| 102 | (home-page "https://harelang.org") | ||
| 103 | (synopsis "Harelang bootstrap compiler") | ||
| 104 | (description "@code{harec} is a bootstrap compiler written in C for the Hare | ||
| 105 | programming language. For general Hare programming, see the @code{hare} | ||
| 106 | package.") | ||
| 107 | (license license:gpl3))) | ||
