From 60aa095ed9af44e5e18778b78454592e9ad61b65 Mon Sep 17 00:00:00 2001 From: Luke Gorrie Date: Wed, 15 Mar 2017 13:24:42 +0000 Subject: [PATCH] Specify build dependencies with nix This adds the file default.nix & instructions for use to README. --- README.md | 29 +++++++++++++++++++++++++++++ default.nix | 19 +++++++++++++++++++ 2 files changed, 48 insertions(+) create mode 100644 default.nix diff --git a/README.md b/README.md index 6d4eafa017..d446a53251 100644 --- a/README.md +++ b/README.md @@ -22,6 +22,35 @@ Initial changes (ongoing work): PRs welcome! Shock me with your radical ideas! :-) +### Compilation + +RaptorJIT is built using GNU Make, Clang (C compiler), and LuaJIT 2 (bootstrap Lua for DynASM etc.) The build environment is specified formally in `default.nix` and can be automatically provided using the [nix](http://nixos.org/nix/) package manager. + +Here is how to install nix: + +``` +$ curl https://nixos.org/nix/install | sh +``` + +Here is how to build raptorjit once nix is installed (note: the first +compilation takes time to download dependencies): + +```shell +$ nix-build # produces result/bin/raptorjit +``` + +Here is the interactive version: + +``` +$ nix-shell # start sub-shell with pristine build environment in $PATH +[nix-shell]$ make -j # build manually as many times as you like +[nix-shell]$ exit # quit when done +``` + +(You can also skip `nix` and install `clang` and `luajit` yourself if +you like. The nix approach is future proof to new dependencies and +allows for pinning specific versions.) + ### Quotes Here are some borrowed words to put this branch into context: diff --git a/default.nix b/default.nix new file mode 100644 index 0000000000..b8081e6303 --- /dev/null +++ b/default.nix @@ -0,0 +1,19 @@ +{ pkgs ? (import {}) +, source ? ./. +, version ? "dev" +}: + +with pkgs; +with clangStdenv; + +mkDerivation rec { + name = "raptorjit-${version}"; + inherit version; + src = lib.cleanSource source; + enableParallelBuilding = true; + buildInputs = [ luajit ]; + installPhase = '' + mkdir -p $out/bin + cp src/luajit $out/bin/raptorjit + ''; +}