Very much a work in progress but basic nix building works
to run the example you can run nix build .#examples-simple --print-build-logs
in the repo root
See this example for a simple roc app taken form roc-parser which builds a roc binary using 2 external deps
you can run the following to copy the template into your current folder
nix flake init --template github:JRMurr/roc2nix#quick-start --refresh
NOTE: goal is to eventually have a code gen step to reduce boiler plate like node2nix but for now its all manaul
- nix is given a list of urls of roc packages with their sha256 hash
downloadRocPackage
will callfetchUrl
on each package and extract the package into a directorymkRocDerivation
will replace all references to the package url with the now local path and build with the provided roc compiler
- TLC around how roc deps are replaced by the nix store paths. Right now its basically a regex is fine for the long urls but for local file paths there is a potential for collisions
- actually verify the blake3 checksum. (since we untar roc wont do this for us). Maybe roc could support local tar balls?
- A code gen tool to get all deps of a roc package for you
- Use the nix c abi to make a "nix platform" for roc. Potential for roc build to build the derivation or at least move more of this logic into roc.
- Expose an api to work with
evalModules
orflakeParts
to make it easier to compose all the needed builds + have better input validation
Lib setup is heavily inspired by crane
see https://github.com/JRMurr/roc/blob/3d8884a96d44e2101ce8932336b74e2b9416e029/crates/compiler/build/src/link.rs#L437 for how roc calls out to compile different platforms