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,
|
2020-08-07 18:59:51 +00:00
|
|
|
patches ? [],
|
2019-12-20 14:39:39 +00:00
|
|
|
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 = [];
|
|
|
|
}))
|
|
|
|
}:
|
2020-03-08 17:44:48 +00:00
|
|
|
|
|
|
|
let
|
|
|
|
bin_folder = if stdenv.isDarwin then "darwin" else "linux";
|
|
|
|
in
|
|
|
|
|
|
|
|
stdenv.mkDerivation rec {
|
2020-08-07 18:59:51 +00:00
|
|
|
inherit src version patches;
|
2019-12-05 19:41:34 +00:00
|
|
|
pname = "bs-platform";
|
2020-03-08 17:44:48 +00:00
|
|
|
|
2019-12-05 19:41:34 +00:00
|
|
|
BS_RELEASE_BUILD = "true";
|
2020-03-09 17:21:43 +00:00
|
|
|
|
|
|
|
# BuckleScript's idiosyncratic build process only builds artifacts required
|
|
|
|
# for editor-tooling to work when this environment variable is set:
|
|
|
|
# https://github.com/BuckleScript/bucklescript/blob/7.2.0/scripts/install.js#L225-L227
|
2020-03-08 17:44:48 +00:00
|
|
|
BS_TRAVIS_CI = "1";
|
|
|
|
|
2019-12-20 14:39:39 +00:00
|
|
|
buildInputs = [ nodejs python3 custom-ninja ];
|
2019-12-05 19:41:34 +00:00
|
|
|
|
2020-08-07 18:59:51 +00:00
|
|
|
prePatch = ''
|
2019-12-05 19:41:34 +00:00
|
|
|
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
|
|
|
'';
|
|
|
|
|
2020-02-02 18:51:21 +00:00
|
|
|
# avoid building the development version, will break aarch64 build
|
|
|
|
dontConfigure = true;
|
2019-12-05 19:41:34 +00:00
|
|
|
|
|
|
|
buildPhase = ''
|
2020-01-15 06:44:44 +00:00
|
|
|
# This is an unfortunate name, but it's actually how to build a release
|
|
|
|
# binary for BuckleScript
|
2020-08-07 18:59:51 +00:00
|
|
|
npm run postinstall
|
2019-12-05 19:41:34 +00:00
|
|
|
'';
|
|
|
|
|
|
|
|
installPhase = ''
|
|
|
|
mkdir -p $out/bin
|
2020-03-09 17:20:10 +00:00
|
|
|
cp -rf jscomp lib ${bin_folder} vendor odoc_gen native bsb bsc bsrefmt $out
|
2020-04-16 22:44:39 +00:00
|
|
|
mkdir -p $out/lib/ocaml
|
2020-03-08 17:44:48 +00:00
|
|
|
cp jscomp/runtime/js.* jscomp/runtime/*.cm* $out/lib/ocaml
|
|
|
|
cp jscomp/others/*.ml jscomp/others/*.mli jscomp/others/*.cm* $out/lib/ocaml
|
|
|
|
cp jscomp/stdlib-406/*.ml jscomp/stdlib-406/*.mli jscomp/stdlib-406/*.cm* $out/lib/ocaml
|
2019-12-05 19:41:34 +00:00
|
|
|
cp bsconfig.json package.json $out
|
2020-03-08 17:44:48 +00:00
|
|
|
ln -s $out/bsb $out/bin/bsb
|
|
|
|
ln -s $out/bsc $out/bin/bsc
|
2020-03-09 17:20:10 +00:00
|
|
|
ln -s $out/bsrefmt $out/bin/bsrefmt
|
2019-12-05 19:41:34 +00:00
|
|
|
'';
|
|
|
|
}
|