mirror of
https://github.com/status-im/status-react.git
synced 2025-01-14 04:55:13 +00:00
Jakub Sokołowski
46bd2b2e4c
Changes: - Add missing lazy assignment for OS_NAME, fixes double Nix shells - Moved `scripts/add-nix-gcroots.sh` to `nix/scripts/gcroots.sh` - Moved Nix package manager setup to `nix/scripts/setup.sh` - Created `nix/scripts/source.sh` to reuse in all Nix scripts - Created `STARTING_GUIDE.md` with instructions for contributors - Created `scripts/colors.sh` for definition of shell colors - Removed `scripts/setup` in favor of `nix/scripts/setup.sh` - Removed all of `scripts/lib` since it was useless Signed-off-by: Jakub Sokołowski <jakub@status.im>
71 lines
1.8 KiB
Bash
Executable File
71 lines
1.8 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
|
|
set -e
|
|
|
|
GIT_ROOT=$(cd "${BASH_SOURCE%/*}" && git rev-parse --show-toplevel)
|
|
resultPath="${GIT_ROOT}/result/"
|
|
source "${GIT_ROOT}/scripts/colors.sh"
|
|
source "${GIT_ROOT}/nix/scripts/source.sh"
|
|
|
|
# cleanup for artifacts created during builds
|
|
function cleanup() {
|
|
# clear trapped signals
|
|
trap - EXIT ERR INT QUIT
|
|
# do the actual cleanup, ignore failure
|
|
if ${GIT_ROOT}/nix/scripts/clean.sh "${nixResultPath}"; then
|
|
echo -e "${GRN}Successful cleanup!${RST}"
|
|
elif [[ -n "${JENKINS_URL}" ]]; then
|
|
# in CI removing some paths can fail due to parallel builds
|
|
echo -e "${YLW}Ignoring cleanup failure in CI.${RST}"
|
|
else
|
|
echo -e "${RED}Failed cleanup!${RST}"
|
|
exit 1
|
|
fi
|
|
}
|
|
|
|
trap cleanup EXIT ERR INT QUIT
|
|
|
|
# build output will end up under /nix, we have to extract it
|
|
function extractResults() {
|
|
local nixResultPath="$1"
|
|
mkdir -p "${resultPath}"
|
|
cp -vfr ${nixResultPath}/* "${resultPath}"
|
|
chmod -R u+w "${resultPath}"
|
|
ls -l "${resultPath}"
|
|
}
|
|
|
|
targetAttr="${1}"
|
|
shift
|
|
|
|
if [[ -z "${targetAttr}" ]]; then
|
|
echo -e "${RED}First argument is mandatory and has to specify the Nix attribute!${RST}"
|
|
exit 1
|
|
fi
|
|
|
|
# Some defaults flags, --pure could be optional in the future.
|
|
# NOTE: The --keep-failed flag can be used for debugging issues.
|
|
nixOpts=(
|
|
"--pure"
|
|
"--fallback"
|
|
"--no-out-link"
|
|
"--show-trace"
|
|
"--attr ${targetAttr}"
|
|
"${@}"
|
|
"default.nix"
|
|
)
|
|
|
|
# This variable allows specifying which env vars to keep for Nix pure shell
|
|
# The separator is a semicolon
|
|
if [[ -n "${_NIX_KEEP}" ]]; then
|
|
nixOpts+=("--keep ${_NIX_KEEP//;/ --keep }")
|
|
fi
|
|
|
|
# Run the actual build
|
|
echo "Running: nix-build ${nixOpts[@]}"
|
|
nixResultPath=$(nix-build ${nixOpts[@]})
|
|
|
|
echo "Extracting result: ${nixResultPath}"
|
|
extractResults "${nixResultPath}"
|
|
|
|
echo -e "${GRN}SUCCESS${RST}"
|