fix nix-clean for MacOS
Signed-off-by: Jakub Sokołowski <jakub@status.im>
This commit is contained in:
parent
89d09c4ba5
commit
7d1812cc94
22
Makefile
22
Makefile
|
@ -32,14 +32,24 @@ ifndef BUILD_TAG
|
|||
export BUILD_TAG := $(shell git rev-parse --short HEAD)
|
||||
endif
|
||||
|
||||
# Defines which variables will be kept for Nix pure shell, use semicolon as divider
|
||||
export _NIX_KEEP ?= TMPDIR,BUILD_ENV,STATUS_GO_SRC_OVERRIDE
|
||||
export NIX_CONF_DIR = $(PWD)/nix
|
||||
# We don't want to use /run/user/$UID because it runs out of space too easilly
|
||||
export TMPDIR = /tmp/tmp-status-react-$(BUILD_TAG)
|
||||
# this has to be specified for both the Node.JS server process and the Qt process
|
||||
export REACT_SERVER_PORT ?= 5001
|
||||
|
||||
# Our custom config is located in nix/nix.conf
|
||||
export NIX_CONF_DIR = $(PWD)/nix
|
||||
# Defines which variables will be kept for Nix pure shell, use semicolon as divider
|
||||
export _NIX_KEEP ?= TMPDIR,BUILD_ENV,STATUS_GO_SRC_OVERRIDE
|
||||
export _NIX_ROOT = /nix
|
||||
|
||||
# MacOS root is read-only, read nix/README.md for details
|
||||
UNAME_S := $(shell uname -s)
|
||||
ifeq ($(UNAME_S),Darwin)
|
||||
export NIX_IGNORE_SYMLINK_STORE=1
|
||||
export _NIX_ROOT = /opt/nix
|
||||
endif
|
||||
|
||||
#----------------
|
||||
# Nix targets
|
||||
#----------------
|
||||
|
@ -63,7 +73,7 @@ nix-clean: ##@nix Remove all status-react build artifacts from /nix/store
|
|||
|
||||
nix-purge: SHELL := /bin/sh
|
||||
nix-purge: ##@nix Completely remove the complete Nix setup
|
||||
sudo rm -rf /nix ~/.nix-profile ~/.nix-defexpr ~/.nix-channels ~/.cache/nix ~/.status .nix-gcroots
|
||||
sudo rm -rf $(_NIX_ROOT) ~/.nix-profile ~/.nix-defexpr ~/.nix-channels ~/.cache/nix ~/.status .nix-gcroots
|
||||
|
||||
nix-add-gcroots: export TARGET_OS := none
|
||||
nix-add-gcroots: ##@nix Add Nix GC roots to avoid status-react expressions being garbage collected
|
||||
|
@ -253,6 +263,10 @@ endif
|
|||
# Tests
|
||||
#--------------
|
||||
|
||||
lint: export _NIX_ATTR := targets.leiningen.shell
|
||||
lint: ##@test Run code style checks
|
||||
lein cljfmt check
|
||||
|
||||
test: export _NIX_ATTR := targets.leiningen.shell
|
||||
test: ##@test Run tests once in NodeJS
|
||||
lein with-profile test doo node test once
|
||||
|
|
19
nix/clean.sh
19
nix/clean.sh
|
@ -15,19 +15,30 @@ function findRelated() {
|
|||
path="${1}"
|
||||
found+=("${path}")
|
||||
if [[ "${path}" =~ .*.chroot ]]; then
|
||||
log " ! Chroot: ${path}"
|
||||
continue
|
||||
log " ! Chroot: ${path}"
|
||||
return
|
||||
elif [[ "${path}" =~ .*.lock ]]; then
|
||||
log " ! Lock: ${path}"
|
||||
return
|
||||
elif [[ "${path}" =~ .*status-react-shell.drv ]]; then
|
||||
echo -n "${path}"
|
||||
return
|
||||
fi
|
||||
log " ? Checking: ${path}"
|
||||
drv=$(getDrvFiles "${path}")
|
||||
# if drv is unknown-deriver then path is a source
|
||||
if [[ "${drv}" == "unknown-deriver" ]]; then
|
||||
drv=$(getReferrers "${path}")
|
||||
drv=$(getReferrers "${path}" | head -n1)
|
||||
src="${path}"
|
||||
elif [[ -f "${drv}" ]]; then
|
||||
src=$(getSources "${drv}")
|
||||
fi
|
||||
if [ $(getRoots "${drv}" | wc -l) -eq 0 ]; then
|
||||
# empty paths means this is a source
|
||||
if [[ -z "${drv}" ]]; then
|
||||
echo -n "${src}"
|
||||
return
|
||||
fi
|
||||
if [[ $(getRoots "${drv}" | wc -l) -eq 0 ]]; then
|
||||
log " - Derivation: ${drv}"
|
||||
log " - Source: ${src}"
|
||||
found+=("${drv}" "${src}")
|
||||
|
|
|
@ -41,7 +41,7 @@ shellArgs=(
|
|||
if [[ -n "${TARGET_OS}" ]]; then
|
||||
shellArgs+=("--argstr target-os ${TARGET_OS}")
|
||||
else
|
||||
echo -e "${YELLOW}Env is missing TARGET_OS, assuming no target platform.${NC} See nix/README.md for more details." > /dev/stderr
|
||||
echo -e "${YELLOW}Env is missing TARGET_OS, assuming no target platform.${NC} See nix/README.md for more details." 1>&2
|
||||
fi
|
||||
|
||||
if [[ "$TARGET_OS" =~ (linux|windows|darwin|macos) ]]; then
|
||||
|
@ -65,7 +65,7 @@ fi
|
|||
# ENTER_NIX_SHELL is the fake command used when `make shell` is run.
|
||||
# It is just a special string, not a variable, and a marker to not use `--run`.
|
||||
if [[ $@ == "ENTER_NIX_SHELL" ]]; then
|
||||
echo -e "${GREEN}Configuring ${_NIX_ATTR:-default} Nix shell for target '${TARGET_OS:-none}'...${NC}" > /dev/stderr
|
||||
echo -e "${GREEN}Configuring ${_NIX_ATTR:-default} Nix shell for target '${TARGET_OS:-none}'...${NC}" 1>&2
|
||||
exec nix-shell ${shellArgs[@]} ${entryPoint}
|
||||
else
|
||||
# Not all builds are ready to be run in a pure environment
|
||||
|
@ -78,6 +78,6 @@ else
|
|||
if [[ -n "${_NIX_KEEP}" ]]; then
|
||||
shellArgs+=("--keep ${_NIX_KEEP//;/ --keep }")
|
||||
fi
|
||||
echo -e "${GREEN}Configuring ${pureDesc}${_NIX_ATTR:-default} Nix shell for target '${TARGET_OS}'...${NC}" > /dev/stderr
|
||||
echo -e "${GREEN}Configuring ${pureDesc}${_NIX_ATTR:-default} Nix shell for target '${TARGET_OS}'...${NC}" 1>&2
|
||||
exec nix-shell ${shellArgs[@]} --run "$@" ${entryPoint}
|
||||
fi
|
||||
|
|
Loading…
Reference in New Issue