Skip to content

Commit

Permalink
Specify build dependencies with nix
Browse files Browse the repository at this point in the history
This adds the file default.nix & instructions for use to README.
  • Loading branch information
lukego committed Mar 15, 2017
1 parent 78f9acf commit 60aa095
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 0 deletions.
29 changes: 29 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
19 changes: 19 additions & 0 deletions default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{ pkgs ? (import <nixpkgs> {})
, 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
'';
}

0 comments on commit 60aa095

Please sign in to comment.