omega-packages
aien-dev/omega-packages
Brought by drakestapleton
omega-packages / guix / aien / omega.scm
| 1 | ;;; omega.scm -- omc, the Omega compiler, born from the 408-byte seed of aien-dev/omega-mv. |
| 2 | ;;; Copyright 2026 Drake Stapleton |
| 3 | ;;; SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
| 4 | ;;; |
| 5 | ;;; Guix builds its own world from a small audited seed; this package does the same for omc. |
| 6 | ;;; The build runs omega-mv's seed/omega-from-seed.sh (seed0 -> hex1 -> asm2 -> om4 -> omc -> |
| 7 | ;;; omc -> omc) with only sh, printf, sed, stat, cmp and sha256sum, then refuses any omc whose |
| 8 | ;;; sha256 is not the pinned one. No C compiler, assembler or linker writes a byte of omc. |
| 9 | |
| 10 | (define-module (aien omega) |
| 11 | #:use-module (guix packages) |
| 12 | #:use-module (guix download) |
| 13 | #:use-module (guix gexp) |
| 14 | #:use-module (guix git-download) |
| 15 | #:use-module (guix build-system gnu) |
| 16 | #:use-module ((guix licenses) #:prefix license:)) |
| 17 | |
| 18 | (define %omega-mv-commit "e5b32567a7aff3ce594e3254a622a846a6cd190b") |
| 19 | (define %omc-sha256 "2c82480596bbdc50cda9626866209ef662d5834f278f839ff4ce0250c495029f") |
| 20 | |
| 21 | (define-public omc |
| 22 | (package |
| 23 | (name "omc") |
| 24 | (version (git-version "0.0.0" "0" %omega-mv-commit)) |
| 25 | (source |
| 26 | (origin |
| 27 | (method url-fetch) |
| 28 | (uri (string-append "https://github.com/aien-dev/omega-mv/archive/" |
| 29 | %omega-mv-commit ".tar.gz")) |
| 30 | (file-name (string-append "omega-mv-" %omega-mv-commit ".tar.gz")) |
| 31 | (sha256 |
| 32 | (base32 "0p59ahifnlb46pm93pb5sdh68h4m2jcxiaaklahng3bjzv7bc8f6")))) |
| 33 | (build-system gnu-build-system) |
| 34 | (arguments |
| 35 | (list |
| 36 | #:strip-binaries? #f |
| 37 | #:validate-runpath? #f |
| 38 | #:phases |
| 39 | #~(modify-phases %standard-phases |
| 40 | (delete 'configure) |
| 41 | (delete 'patch-source-shebangs) |
| 42 | (replace 'build |
| 43 | (lambda _ |
| 44 | (invoke "sh" "seed/omega-from-seed.sh") |
| 45 | (invoke "sh" "-c" |
| 46 | (string-append "echo '" #$%omc-sha256 |
| 47 | " seed/out/omc' | sha256sum -c -")))) |
| 48 | (replace 'check |
| 49 | (lambda* (#:key tests? #:allow-other-keys) |
| 50 | (when tests? |
| 51 | (call-with-output-file "hello.om" |
| 52 | (lambda (port) |
| 53 | (display "global out uchar 4 |
| 54 | fn main to int |
| 55 | put out 0 111 |
| 56 | put out 1 107 |
| 57 | put out 2 10 |
| 58 | w = write 1 out 0 3 |
| 59 | ret 0 |
| 60 | end |
| 61 | " port))) |
| 62 | (invoke "sh" "-c" "./seed/out/omc < hello.om > hello && chmod +x hello") |
| 63 | (invoke "sh" "-c" "test \"$(./hello)\" = ok")))) |
| 64 | (replace 'install |
| 65 | (lambda _ |
| 66 | (install-file "seed/out/omc" (string-append #$output "/bin"))))))) |
| 67 | (supported-systems '("aarch64-linux")) |
| 68 | (home-page "https://github.com/aien-dev/omega-mv") |
| 69 | (synopsis "Omega compiler, born from a 408-byte hand-written seed") |
| 70 | (description |
| 71 | "omc compiles Omega (@file{.om}) source read on standard input into a |
| 72 | static AArch64 Linux ELF written to standard output. This package builds it |
| 73 | from the 408-byte hand-written seed0 of omega-mv through hex1, asm2 and om4, |
| 74 | then has omc rebuild itself to a fixpoint, and checks the result against a |
| 75 | pinned sha256. It runs and emits code for AArch64 Linux only.") |
| 76 | (license license:asl2.0))) |