interplane.Get Omega
Read in your language

omega-packages

aien-dev/omega-packages

Brought by drakestapleton

branch main Branches Tags History

omega-packages / flake.nix

65 lines · 2282 bytes Raw Blame History
1{
2 description = "omc, the Omega compiler, born from the 408-byte seed of aien-dev/omega-mv (aarch64-linux only)";
3
4 inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
5
6 outputs = { self, nixpkgs }:
7 let
8 system = "aarch64-linux";
9 pkgs = nixpkgs.legacyPackages.${system};
10 commit = "e5b32567a7aff3ce594e3254a622a846a6cd190b";
11 omcSha256 = "2c82480596bbdc50cda9626866209ef662d5834f278f839ff4ce0250c495029f";
12
13 omc = pkgs.stdenvNoCC.mkDerivation {
14 pname = "omc";
15 version = "0.0.0+git.${builtins.substring 0 8 commit}";
16 src = pkgs.fetchurl {
17 url = "https://github.com/aien-dev/omega-mv/archive/${commit}.tar.gz";
18 hash = "sha256-xiG2zv5yjWeholOp2JkUlUBkYNNl3ZHqNWRR6yJUqVw=";
19 };
20 # The seed chain needs only sh, printf, cat, stat, sed, sha256sum and cmp (all in stdenv).
21 dontConfigure = true;
22 buildPhase = ''
23 runHook preBuild
24 sh seed/omega-from-seed.sh
25 echo "${omcSha256} seed/out/omc" | sha256sum -c -
26 runHook postBuild
27 '';
28 doCheck = true;
29 checkPhase = ''
30 runHook preCheck
31 ./seed/out/omc < ${./examples/hello.om} > hello
32 chmod +x hello
33 test "$(./hello)" = "omega 55"
34 runHook postCheck
35 '';
36 installPhase = ''
37 runHook preInstall
38 install -Dm755 seed/out/omc $out/bin/omc
39 runHook postInstall
40 '';
41 # omc is a static ELF whose bytes are pinned; strip/patchelf must not touch it.
42 dontFixup = true;
43 meta = {
44 description = "Omega compiler, born from a 408-byte hand-written seed";
45 homepage = "https://github.com/aien-dev/omega-mv";
46 license = pkgs.lib.licenses.asl20;
47 platforms = [ "aarch64-linux" ];
48 mainProgram = "omc";
49 };
50 };
51 in
52 {
53 packages.${system} = {
54 inherit omc;
55 default = omc;
56 };
57 apps.${system} = rec {
58 omc = { type = "app"; program = "${self.packages.${system}.omc}/bin/omc"; };
59 default = omc;
60 };
61 checks.${system}.omc-hash = pkgs.runCommand "omc-hash" { } ''
62 echo "${omcSha256} ${omc}/bin/omc" | sha256sum -c - > $out
63 '';
64 };
65}