(define-module (hare) #:use-module (guix packages) #:use-module (guix utils) #:use-module (guix gexp) #:use-module (guix git-download) #:use-module (guix download) #:use-module ((guix licenses) #:prefix license:) #:use-module (guix build-system gnu) #:use-module (guix build-system trivial) #:use-module (gnu packages) #:use-module (gnu packages base) #:use-module (gnu packages c) #:use-module (gnu packages man) #:use-module (ice-9 match)) ;; Partially obtained from: ;; https://git.sr.ht/~whereiseveryone/guixrus/tree/master/item/guixrus/packages/hare.scm (define tzdata-list (package (inherit tzdata) (name "tzdata-list") (arguments (list #:tests? #f ;; This consists purely of (architecture-independent) data, so ;; ‘cross-compilation’ is pointless here! (The binaries zic, ;; dump, and tzselect are deleted in the post-install phase.) #:target #f #:make-flags #~(let ((out #$output) (tmp (getenv "TMPDIR"))) (list (string-append "TOPDIR=" out) (string-append "TZDIR=" out "/share/zoneinfo") (string-append "TZDEFAULT=" out "/share/zoneinfo/localtime") ;; Likewise for the C library routines. (string-append "LIBDIR=" tmp "/lib") (string-append "MANDIR=" tmp "/man") ;; XXX: tzdata 2020b changed the on-disk format ;; of the time zone files from 'fat' to 'slim'. ;; Many packages (particularly evolution-data-server) ;; can not yet handle the latter, so we stick with ;; 'fat' for now. #$@(if (version>=? (package-version this-package) "2020b") '("CPPFLAGS=-DZIC_BLOAT_DEFAULT='\"fat\"'") '()) "AWK=awk" "CC=gcc")) #:modules '((guix build utils) (guix build gnu-build-system) (srfi srfi-1)) #:phases #~(modify-phases %standard-phases (replace 'unpack (lambda* (#:key source inputs #:allow-other-keys) (invoke "tar" "xvf" source) (invoke "tar" "xvf" #$(match (package-inputs this-package) (((_ tzcode)) tzcode))))) (add-after 'install 'post-install (lambda* (#:key outputs #:allow-other-keys) ;; Move data in the right place. (let ((out (assoc-ref outputs "out"))) (copy-file "leap-seconds.list" (string-append out "/share/zoneinfo/leap-seconds.list")) (symlink (string-append out "/share/zoneinfo") (string-append out "/share/zoneinfo/posix")) (copy-recursively (string-append out "/share/zoneinfo-leaps") (string-append out "/share/zoneinfo/right"))))) (delete 'configure)))))) (define qbe-master (let ((commit "d023bdaa6b493686f7e9be7ac200ee4ac37d351f") (revision "1")) (package (inherit qbe) (name "qbe") (version (git-version "1.1" revision commit)) (source (origin (method git-fetch) (uri (git-reference (url "git://c9x.me/qbe") (commit commit))) (file-name (git-file-name name version)) (sha256 (base32 "11flr6mmxglidp4fr7whfzhwr1bjkiz0rcvpy541xmwm2isj5znm"))))))) (define-public harec (let ((revision "1") (commit "b4dd4275b24513d14e999bc35ea7d61ed02d1e08")) (package (name "harec") (version (git-version "0.0.1" revision commit)) (source (origin (method git-fetch) (uri (git-reference (url "https://git.sr.ht/~sircmpwn/harec") (commit commit))) (file-name (git-file-name name version)) (sha256 (base32 "1brb0qr6fsi2hx724rprkkwi6qs6ymqglng78gm9m8k6z7c61j8b")))) (build-system gnu-build-system) (arguments `(#:phases (modify-phases %standard-phases (add-before 'configure 'setenv (lambda _ (setenv "AR" ,(ar-for-target)) (setenv "AS" ,(as-for-target)) (setenv "LD" ,(ld-for-target)) (setenv "CC" ,(cc-for-target)))) (add-after 'configure 'configure-better (lambda* (#:key outputs #:allow-other-keys) (invoke "./configure" (string-append "--prefix=" (assoc-ref outputs "out"))))) (delete 'configure)))) (inputs (list qbe-master scdoc)) (synopsis "Bootstrapping compiler for Hare") (description "This package provides @code{harec}, the Hare language's bootstrap written in C. Currently, the self-hosting @code{harec} rewrite is incomplete, so this is used as the default compiler in the build driver.") (home-page "https://git.sr.ht/~sircmpwn/harec") (license license:gpl3)))) (define-public hare (let ((revision "1") (commit "b35f4bc1551bf561de2e0e1fcd7367c20fa21216")) (package (name "hare") (version (git-version "0.0.1" revision commit)) (source (origin (method git-fetch) (uri (git-reference (url "https://git.sr.ht/~sircmpwn/hare") (commit commit))) (file-name (git-file-name name version)) (sha256 (base32 "0v5r7007dyy75qagffkhag1pqigdsv2qgbgwrn44d51ws695phzi")))) (inputs (list scdoc qbe-master harec tzdata-list)) (build-system gnu-build-system) (arguments (list #:make-flags #~(list "HARECACHE=./cache" (string-append "PREFIX=" #$output)) #:phases #~(modify-phases %standard-phases (add-before 'configure 'configure-make (lambda _ (substitute* "time/chrono/+linux.ha" (("/usr/share/zoneinfo/leap-seconds.list") (string-append #$tzdata-list "/share/zoneinfo/leap-seconds.list")) (("/usr/share/zoneinfo/") (string-append #$tzdata-list "/share/zoneinfo/"))) (copy-file "config.example.mk" "config.mk") ;; We don't need to do this if we are using the toolchain ;; below... #;(substitute* "config.mk" (("AS = as") (string-append "AS = "#$(as-for-target))) (("LD = ld") (string-append "LD = "#$(ld-for-target))) (("QBE = qbe") (string-append "QBE = " #$qbe-master "/bin/qbe")) (("SCDOC = scdoc") (string-append "SD =" #$scdoc "/bin/scdoc")) (("HAREC = harec") (string-append "HAREC =" #$harec "/bin/harec"))) #;(substitute* "cmd/hare/build.ha" (("\"qbe\"") (string-append "\"" #$qbe-master "/bin/qbe" "\"")) (("\"harec\"") (string-append "\"" #$harec "/bin/harec" "\""))) )) (delete 'configure)))) (synopsis "Hare build driver") (description "Hare is a systems programming language designed to be simple, stable, and robust. Hare uses a static type system, manual memory management, and a minimal runtime. It is well-suited to writing operating systems, system tools, compilers, networking software, and other low-level, high performance tasks.") (home-page "https://git.sr.ht/~sircmpwn/hare") (license license:gpl3)))) (define-public hare-toolchain (package (name "hare-toolchain") (version (package-version hare)) (source #f) (build-system trivial-build-system) (arguments `(#:builder (begin (mkdir %output)))) (propagated-inputs (list binutils hare harec qbe-master)) (native-search-paths (package-native-search-paths hare)) (home-page (package-home-page hare)) (synopsis "Complete @code{hare} toolchain for Hare development") (description "This package provides a toolchain for the Hare language. It allows you to conveniently install all the required packages (such as @code{binutils} and @code{qbe}) into your profile.") (license (package-license hare))))