From 90d517adf60b6f8a049b7619291eea6ee3749e99 Mon Sep 17 00:00:00 2001 From: Pedro Pombeiro Date: Fri, 10 May 2019 15:20:40 +0200 Subject: [PATCH] nix: Add add-gcroots target to Makefile to avoid garbage collection Signed-off-by: Pedro Pombeiro --- .gitignore | 3 ++- Makefile | 7 +++++-- nix/shell.sh | 2 +- scripts/add-gcroots.sh | 10 ++++++++++ scripts/lib/setup/platform.sh | 2 +- 5 files changed, 19 insertions(+), 5 deletions(-) create mode 100755 scripts/add-gcroots.sh diff --git a/.gitignore b/.gitignore index c7407880f5..865ea36ffd 100644 --- a/.gitignore +++ b/.gitignore @@ -161,4 +161,5 @@ conan.cmake .env.bkp # nix -/.ran-setup \ No newline at end of file +/.ran-setup +/.nix-gcroots/ \ No newline at end of file diff --git a/Makefile b/Makefile index 7ae7bb1aa8..33ff927e24 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -.PHONY: clean clean-nix react-native-android react-native-ios react-native-desktop test release _list +.PHONY: add-gcroots clean clean-nix react-native-android react-native-ios react-native-desktop test release _list help: ##@other Show this help @perl -e '$(HELP_FUN)' $(MAKEFILE_LIST) @@ -45,7 +45,10 @@ clean: ##@prepare Remove all output folders clean-nix: SHELL := /bin/sh clean-nix: ##@prepare Remove complete nix setup - sudo rm -rf /nix ~/.nix-profile ~/.nix-defexpr ~/.nix-channels ~/.cache/nix ~/.status + sudo rm -rf /nix ~/.nix-profile ~/.nix-defexpr ~/.nix-channels ~/.cache/nix ~/.status .nix-gcroots + +add-gcroots: ##@prepare Add Nix GC roots to avoid status-react expressions being garbage collected + scripts/add-gcroots.sh shell: ##@prepare Enter into a pre-configured shell ifndef IN_NIX_SHELL diff --git a/nix/shell.sh b/nix/shell.sh index 73cf36c769..75bbcc19c9 100755 --- a/nix/shell.sh +++ b/nix/shell.sh @@ -32,7 +32,7 @@ if command -v "nix" >/dev/null 2>&1; then exec nix-shell --show-trace --argstr target-os ${TARGET_OS} else is_pure='' - if [ "${TARGET_OS}" != 'ios' ] && [ "${TARGET_OS}" != 'windows' ]; then + if [ "${TARGET_OS}" != 'all' ] && [ "${TARGET_OS}" != 'ios' ] && [ "${TARGET_OS}" != 'windows' ]; then is_pure='--pure' pure_desc='pure ' fi diff --git a/scripts/add-gcroots.sh b/scripts/add-gcroots.sh new file mode 100755 index 0000000000..ffb81516ab --- /dev/null +++ b/scripts/add-gcroots.sh @@ -0,0 +1,10 @@ +#!/usr/bin/env bash + +GIT_ROOT=$(git rev-parse --show-toplevel) + +rm -rf .nix-gcroots +mkdir .nix-gcroots + +drv=$(nix-instantiate shell.nix) +refs=$(nix-store --query --references $drv) +nix-store -r $refs --indirect --add-root $GIT_ROOT/.nix-gcroots/shell.dep diff --git a/scripts/lib/setup/platform.sh b/scripts/lib/setup/platform.sh index 6a7981d011..0e4e869ac2 100755 --- a/scripts/lib/setup/platform.sh +++ b/scripts/lib/setup/platform.sh @@ -16,7 +16,7 @@ function is_nixos() { function exit_unless_os_supported() { if [ "$IN_NIX_SHELL" == 'pure' ]; then - cecho "@red[[This install script is not supported in a pure Nix shell]] + cecho "@red[[This install script is not supported in a pure Nix shell]]" echo