From accf2b991a774036df2b4b9d8e98393e0aeef941 Mon Sep 17 00:00:00 2001 From: Lilah Tascheter Date: Wed, 6 Aug 2025 12:01:42 -0500 Subject: [PATCH] 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 --- gnu/local.mk | 1 + gnu/packages/hare.scm | 107 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 108 insertions(+) create mode 100644 gnu/packages/hare.scm diff --git a/gnu/local.mk b/gnu/local.mk index ed51c6dc82aec764ce51e260806e8e6e5b65cb5b..c81ed7f5f2df34241f01d9a11fd81329823bb3b4 100644 --- a/gnu/local.mk +++ b/gnu/local.mk @@ -356,6 +356,7 @@ GNU_SYSTEM_MODULES = \ %D%/packages/gv.scm \ %D%/packages/gxmessage.scm \ %D%/packages/hardware.scm \ + %D%/packages/hare.scm \ %D%/packages/haskell.scm \ %D%/packages/haskell-apps.scm \ %D%/packages/haskell-check.scm \ diff --git a/gnu/packages/hare.scm b/gnu/packages/hare.scm new file mode 100644 index 0000000000000000000000000000000000000000..90ce1493e683753e84ded115bc350104c1bc6fc0 --- /dev/null +++ b/gnu/packages/hare.scm @@ -0,0 +1,107 @@ +;;; GNU Guix --- Functional package management for GNU +;;; Copyright © 2025 Lilah Tascheter +;;; +;;; 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 . + +(define-module (gnu packages hare) + #:use-module (gnu packages) + #:use-module (gnu packages base) + #:use-module (gnu packages c) + #:use-module (gnu packages commencement) + #:use-module (gnu packages cross-base) + #:use-module (gnu packages less) + #:use-module (gnu packages man) + #:use-module (guix build-system gnu) + #:use-module (guix gexp) + #:use-module (guix git-download) + #:use-module ((guix licenses) #:prefix license:) + #:use-module (guix packages) + #:use-module (guix search-paths) + #:use-module (guix utils) + #:export (hare-supported-systems + target->hare-arch)) + +(define hare-supported-systems + '("x86_64-linux" "aarch64-linux" "riscv64-linux")) + +(define* (target->hare-arch #:optional (target (or (%current-target-system) + (%current-system)))) + (cond ((target-x86-64? target) "x86_64") + ((target-aarch64? target) "aarch64") + ((target-riscv64? target) "riscv64") + (else (error "unsupported hare target" target)))) + +(define (cross-target? target) ; only has to work for supported arches + (and target (not (if (%current-target-system) + (string=? (%current-target-system) target) + (string-prefix? (%current-system) target))))) + +(define (tools-for-target target) + (let* ((cross? (and=> target cross-target?)) + (with-target (lambda (f) (if cross? (f target) (f)))) + (prefix (string-upcase (with-target target->hare-arch))) + (prefix-for (lambda (v) (if target (string-append prefix "_" v) v))) + (toolchain (if cross? (cross-gcc-toolchain target) gcc-toolchain)) + (bin-for (lambda (t) (file-append toolchain "/bin/" (with-target t))))) + #~((#$(prefix-for "CC") #$(bin-for cc-for-target)) + (#$(prefix-for "AS") #$(bin-for as-for-target)) + (#$(prefix-for "LD") #$(bin-for ld-for-target))))) + +(define hare-config ; unified build config for hare packages + (computed-file "hare-config.mk" + #~(begin (use-modules (ice-9 format)) + (call-with-output-file #$output + (lambda (port) + (format port "include configs/linux.mk~%~:{~a=~a~%~}" + `(("ARCH" ,#$(target->hare-arch)) + ("DEFAULT_TARGET" "$(ARCH)") + ("STDLIB" "$(PREFIX)/share/hare") + ("HAREPATH" "$(PREFIX)/share/hare") + #$@(tools-for-target #f) + #$@(tools-for-target "aarch64-linux-gnu") + #$@(tools-for-target "riscv64-linux-gnu") + #$@(tools-for-target "x86_64-linux-gnu")))))))) + +(define-public harec + (package + (name "harec") + (version "0.25.2") + (source (origin + (method git-fetch) + (uri (git-reference + (url "https://git.sr.ht/~sircmpwn/harec") + (commit version))) + (file-name (git-file-name name version)) + (sha256 + (base32 + "0qyhni011116wc194kkybmiphmi1cak0n8kxgiq7v174xsh9irp7")))) + (build-system gnu-build-system) + (arguments + (list #:modules `((ice-9 format) ,@%default-gnu-modules) + #:make-flags #~(list (string-append "PREFIX=" #$output) + (string-append "VERSION=" #$version)) + #:phases + #~(modify-phases %standard-phases + (replace 'configure + (lambda _ (copy-file #$hare-config "config.mk")))))) + (native-inputs (list qbe)) + (supported-systems hare-supported-systems) + (home-page "https://harelang.org") + (synopsis "Harelang bootstrap compiler") + (description "@code{harec} is a bootstrap compiler written in C for the Hare +programming language. For general Hare programming, see the @code{hare} +package.") + (license license:gpl3)))