2019-12-20 14:39:39 +00:00
|
|
|
# This file is based on https://github.com/turboMaCk/bs-platform.nix/blob/master/build-bs-platform.nix
|
|
|
|
# to make potential future updates simpler
|
|
|
|
|
|
|
|
{ stdenv, fetchFromGitHub, ninja, runCommand, nodejs, python3,
|
|
|
|
ocaml-version, version, src,
|
|
|
|
ocaml ? (import ./ocaml.nix {
|
2019-12-05 19:41:34 +00:00
|
|
|
version = ocaml-version;
|
|
|
|
inherit stdenv;
|
|
|
|
src = "${src}/ocaml";
|
2019-12-20 14:39:39 +00:00
|
|
|
}),
|
|
|
|
custom-ninja ? (ninja.overrideAttrs (attrs: {
|
|
|
|
src = runCommand "ninja-patched-source" {} ''
|
|
|
|
mkdir -p $out
|
|
|
|
tar zxvf ${src}/vendor/ninja.tar.gz -C $out
|
|
|
|
'';
|
|
|
|
patches = [];
|
|
|
|
}))
|
|
|
|
}:
|
2019-12-05 19:41:34 +00:00
|
|
|
stdenv.mkDerivation {
|
|
|
|
inherit src version;
|
|
|
|
pname = "bs-platform";
|
|
|
|
BS_RELEASE_BUILD = "true";
|
2019-12-20 14:39:39 +00:00
|
|
|
buildInputs = [ nodejs python3 custom-ninja ];
|
2019-12-05 19:41:34 +00:00
|
|
|
|
|
|
|
patchPhase = ''
|
|
|
|
sed -i 's:./configure.py --bootstrap:python3 ./configure.py --bootstrap:' ./scripts/install.js
|
|
|
|
mkdir -p ./native/${ocaml-version}/bin
|
2019-12-20 14:39:39 +00:00
|
|
|
ln -sf ${ocaml}/bin/* ./native/${ocaml-version}/bin
|
2019-12-05 19:41:34 +00:00
|
|
|
rm -f vendor/ninja/snapshot/ninja.linux
|
2019-12-20 14:39:39 +00:00
|
|
|
cp ${custom-ninja}/bin/ninja vendor/ninja/snapshot/ninja.linux
|
2019-12-05 19:41:34 +00:00
|
|
|
'';
|
|
|
|
|
|
|
|
configurePhase = ''
|
|
|
|
node scripts/ninja.js config
|
|
|
|
'';
|
|
|
|
|
|
|
|
buildPhase = ''
|
|
|
|
node scripts/ninja.js build
|
|
|
|
'';
|
|
|
|
|
|
|
|
installPhase = ''
|
|
|
|
node scripts/install.js
|
|
|
|
mkdir -p $out/bin
|
|
|
|
cp -rf jscomp lib vendor odoc_gen native $out
|
|
|
|
cp bsconfig.json package.json $out
|
|
|
|
ln -s $out/lib/bsb $out/bin/bsb
|
|
|
|
ln -s $out/lib/bsc $out/bin/bsc
|
|
|
|
ln -s $out/lib/bsrefmt $out/bin/bsrefmt
|
|
|
|
'';
|
|
|
|
}
|