uiua-lang / uiua

A stack-based array programming language
https://www.uiua.org
MIT License
1.61k stars 117 forks source link

include Uiua386.tff in Nix builds #581

Closed prsteele closed 1 month ago

prsteele commented 1 month ago

This PR fixes builds on Nix by including the Uiua386.tff file in builds.

After merging this PR, it should be possible to run

nix run github:uiua-lang/uiua -- repl

to enter a Uiua REPL.

kaikalii commented 1 month ago

Why does this cause Nix builds to fail?

prsteele commented 1 month ago

On current main,

╭── 20:49:52 ┄ nixos@nixos ┄ ~/projects/uiua ┄ main ✓
╰─❯ nix build .
error: builder for '/nix/store/dg0bpnwlwih6kb4lrzhsp907pzikbql7-uiua-0.13.0-dev.3.drv' failed with exit code 101;
       last 10 log lines:
       >    Compiling uiua v0.13.0-dev.3 (/build/source)
       > error: couldn't read `src/algorithm/Uiua386.ttf`: No such file or directory (os error 2)
       >    --> src/algorithm/encode.rs:819:31
       >     |
       > 819 |             db.load_font_data(include_bytes!("Uiua386.ttf").to_vec());
       >     |                               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
       >     |
       >     = note: this error originates in the macro `include_bytes` (in Nightly builds, run with -Z macro-backtrace for more info)
       >
       > error: could not compile `uiua` (lib) due to 1 previous error
       For full logs, run 'nix log /nix/store/dg0bpnwlwih6kb4lrzhsp907pzikbql7-uiua-0.13.0-dev.3.drv'.

When building via Nix (but not in the Nix development shell) we don't have access to the full local directory because of the source file cleaning that occurs. The code

      fileset = lib.fileset.unions (
        [
          (lib.fileset.fromSource (craneLib.cleanCargoSource ./.))
          ./src/primitive/assets
        ]
        ++ lib.optionals doCheck [
          ./site/favicon.ico
          ./tests
        ]
      );

already has concessions to this; lib.fileset.fromSource (craneLib.cleanCargoSource ./.) includes just "Rust" files (I assume *.rs and *.toml).

prsteele commented 1 month ago

Thanks for merging! Just now,

nix run github:uiua-lang/uiua -- repl
Uiua 0.13.0-dev.3 (end with ctrl+C, type `help` for a list of commands)

    div len on /+ 1_2_3_4
    ÷ ⧻ ⟜/+ 1_2_3_4
2.5