nix: Add add-gcroots target to Makefile to avoid garbage collection

Signed-off-by: Pedro Pombeiro <pombeirp@users.noreply.github.com>
This commit is contained in:
Pedro Pombeiro 2019-05-10 15:20:40 +02:00
parent 26390296b1
commit 90d517adf6
No known key found for this signature in database
GPG Key ID: C4A24185B2AA48A1
5 changed files with 19 additions and 5 deletions

3
.gitignore vendored
View File

@ -161,4 +161,5 @@ conan.cmake
.env.bkp
# nix
/.ran-setup
/.ran-setup
/.nix-gcroots/

View File

@ -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

View File

@ -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

10
scripts/add-gcroots.sh Executable file
View File

@ -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

View File

@ -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