2019-03-01 18:01:33 +00:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
2019-07-26 14:51:06 +00:00
|
|
|
if [[ -z "${IN_NIX_SHELL}" ]]; then
|
|
|
|
echo "Remember to call 'make shell'!"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2019-05-22 16:04:45 +00:00
|
|
|
#
|
|
|
|
# Run this file to regenerate the Nix files in ./output.
|
|
|
|
# Prerequisites: Node, npm, and node2nix (installed with npm i -g https://github.com/svanderburg/node2nix)
|
|
|
|
#
|
|
|
|
|
2019-06-04 17:00:19 +00:00
|
|
|
GIT_ROOT=$(cd "${BASH_SOURCE%/*}" && git rev-parse --show-toplevel)
|
2019-03-01 18:01:33 +00:00
|
|
|
SCRIPTPATH="$( cd "$(dirname "$0")" ; pwd -P )"
|
|
|
|
toolversion="${GIT_ROOT}/scripts/toolversion"
|
|
|
|
dir="$SCRIPTPATH"
|
|
|
|
input="${dir}/output/node-packages.json"
|
|
|
|
output_dir="${dir}/output"
|
2019-06-04 17:00:19 +00:00
|
|
|
supplement_input="${dir}/output/supplement.json"
|
2019-03-01 18:01:33 +00:00
|
|
|
|
|
|
|
rm -rf $output_dir && mkdir -p $output_dir
|
2019-05-22 16:04:45 +00:00
|
|
|
# Specify the package.json file containing the dependencies to install
|
2019-03-01 18:01:33 +00:00
|
|
|
cat << EOF > $input
|
|
|
|
[
|
2019-06-04 16:50:29 +00:00
|
|
|
{ "realm": "https://github.com/status-im/realm-js/archive/v2.20.1.tar.gz" }
|
|
|
|
]
|
|
|
|
EOF
|
|
|
|
|
|
|
|
# Specify the package.json file containing the build dependencies to install
|
|
|
|
cat << EOF > $supplement_input
|
|
|
|
[
|
|
|
|
"node-pre-gyp"
|
2019-03-01 18:01:33 +00:00
|
|
|
]
|
|
|
|
EOF
|
|
|
|
|
2019-06-04 17:00:19 +00:00
|
|
|
# Specify the package.json file containing the build dependencies to install
|
|
|
|
cat << EOF > $supplement_input
|
|
|
|
[
|
|
|
|
"node-pre-gyp"
|
|
|
|
]
|
|
|
|
EOF
|
|
|
|
|
2019-03-01 18:01:33 +00:00
|
|
|
node_required_version=$($toolversion node)
|
|
|
|
node_major_version=$(echo $node_required_version | cut -d. -f1,1)
|
2019-04-01 20:07:39 +00:00
|
|
|
|
2019-07-26 14:51:06 +00:00
|
|
|
if ! which node2nix > /dev/null; then
|
|
|
|
echo "Installing node2nix..."
|
|
|
|
nix-env -f '<nixpkgs>' -iA nodePackages.node2nix
|
|
|
|
fi
|
|
|
|
|
2019-05-22 16:04:45 +00:00
|
|
|
node2nix --nodejs-${node_major_version} --bypass-cache \
|
2019-06-04 17:00:19 +00:00
|
|
|
--input $input \
|
|
|
|
--output $output_dir/node-packages.nix \
|
|
|
|
--supplement-input $supplement_input \
|
|
|
|
--supplement-output $output_dir/supplement.nix \
|
|
|
|
--composition $output_dir/default.nix \
|
|
|
|
--node-env $output_dir/node-env.nix
|
|
|
|
rm $input $supplement_input
|