nix: move nix-purge code to nix/scripts/purge.sh
Signed-off-by: Jakub Sokołowski <jakub@status.im>
This commit is contained in:
parent
4670ae7549
commit
918b03d459
15
Makefile
15
Makefile
|
@ -41,15 +41,11 @@ export REACT_SERVER_PORT ?= 5001
|
||||||
export NIX_CONF_DIR = $(PWD)/nix
|
export NIX_CONF_DIR = $(PWD)/nix
|
||||||
# Defines which variables will be kept for Nix pure shell, use semicolon as divider
|
# Defines which variables will be kept for Nix pure shell, use semicolon as divider
|
||||||
export _NIX_KEEP ?= TMPDIR,BUILD_ENV,STATUS_GO_SRC_OVERRIDE,NIMBUS_SRC_OVERRIDE
|
export _NIX_KEEP ?= TMPDIR,BUILD_ENV,STATUS_GO_SRC_OVERRIDE,NIMBUS_SRC_OVERRIDE
|
||||||
export _NIX_ROOT = /nix
|
|
||||||
# legacy TARGET_OS variable support
|
# legacy TARGET_OS variable support
|
||||||
ifdef TARGET_OS
|
ifdef TARGET_OS
|
||||||
export TARGET ?= $(TARGET_OS)
|
export TARGET ?= $(TARGET_OS)
|
||||||
endif
|
endif
|
||||||
|
|
||||||
# Useful for checking if we are on NixOS
|
|
||||||
OS_NAME := $(shell [ -f /etc/os-release ] && awk -F= '/^NAME/{print $2}' /etc/os-release)
|
|
||||||
|
|
||||||
# Useful for Andoird release builds
|
# Useful for Andoird release builds
|
||||||
TMP_BUILD_NUMBER := $(shell ./scripts/version/gen_build_no.sh | cut -c1-10)
|
TMP_BUILD_NUMBER := $(shell ./scripts/version/gen_build_no.sh | cut -c1-10)
|
||||||
|
|
||||||
|
@ -57,7 +53,6 @@ TMP_BUILD_NUMBER := $(shell ./scripts/version/gen_build_no.sh | cut -c1-10)
|
||||||
UNAME_S := $(shell uname -s)
|
UNAME_S := $(shell uname -s)
|
||||||
ifeq ($(UNAME_S),Darwin)
|
ifeq ($(UNAME_S),Darwin)
|
||||||
export NIX_IGNORE_SYMLINK_STORE=1
|
export NIX_IGNORE_SYMLINK_STORE=1
|
||||||
export _NIX_ROOT = /opt/nix
|
|
||||||
endif
|
endif
|
||||||
|
|
||||||
#----------------
|
#----------------
|
||||||
|
@ -78,19 +73,17 @@ else
|
||||||
@echo "${YELLOW}Nix shell is already active$(RESET)"
|
@echo "${YELLOW}Nix shell is already active$(RESET)"
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
nix-gc: export TARGET := default
|
||||||
nix-gc: ##@nix Garbage collect all packages older than 20 days from /nix/store
|
nix-gc: ##@nix Garbage collect all packages older than 20 days from /nix/store
|
||||||
nix-collect-garbage --delete-old --delete-older-than 20d
|
nix-collect-garbage --delete-old --delete-older-than 20d
|
||||||
|
|
||||||
|
nix-clean: export TARGET := default
|
||||||
nix-clean: ##@nix Remove all status-react build artifacts from /nix/store
|
nix-clean: ##@nix Remove all status-react build artifacts from /nix/store
|
||||||
nix/scripts/clean.sh
|
nix/scripts/clean.sh
|
||||||
|
|
||||||
nix-purge: SHELL := /bin/sh
|
nix-purge: SHELL := /bin/sh
|
||||||
nix-purge: ##@nix Completely remove the complete Nix setup
|
nix-purge: ##@nix Completely remove Nix setup, including /nix directory
|
||||||
ifeq ($(OS_NAME), NixOS)
|
nix/scripts/purge.sh
|
||||||
$(error $(RED)You should not purge Nix files on NixOS!$(RESET))
|
|
||||||
else
|
|
||||||
sudo rm -rf $(_NIX_ROOT)/* ~/.nix-profile ~/.nix-defexpr ~/.nix-channels ~/.cache/nix ~/.status .nix-gcroots
|
|
||||||
endif
|
|
||||||
|
|
||||||
nix-add-gcroots: export TARGET := default
|
nix-add-gcroots: export TARGET := default
|
||||||
nix-add-gcroots: ##@nix Add Nix GC roots to avoid status-react expressions being garbage collected
|
nix-add-gcroots: ##@nix Add Nix GC roots to avoid status-react expressions being garbage collected
|
||||||
|
|
|
@ -0,0 +1,24 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
set -e
|
||||||
|
|
||||||
|
GIT_ROOT=$(cd "${BASH_SOURCE%/*}" && git rev-parse --show-toplevel)
|
||||||
|
source "${GIT_ROOT}/scripts/colors.sh"
|
||||||
|
|
||||||
|
# Purging /nix on NixOS would be disasterous
|
||||||
|
if [[ -f "/etc/os-release" ]]; then
|
||||||
|
OS_NAME=$(awk -F= '/^NAME/{print $2}' /etc/os-release)
|
||||||
|
if [[ "$OS_NAME" == "NixOS" ]]; then
|
||||||
|
echo -e "${RED}You should not purge Nix files on NixOS!${RST}" >&2
|
||||||
|
exit
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
NIX_ROOT="/nix"
|
||||||
|
if [[ $(uname -s) == "Darwin" ]]; then
|
||||||
|
# Special case due to read-only root on MacOS Catalina
|
||||||
|
NIX_ROOT="/opt/nix"
|
||||||
|
fi
|
||||||
|
|
||||||
|
sudo rm -rf ${NIX_ROOT}/* ~/.nix-profile ~/.nix-defexpr ~/.nix-channels ~/.cache/nix ~/.status .nix-gcroots
|
||||||
|
echo -e "${GRN}Purged all Nix files from your system.${RST}" >&2
|
|
@ -15,14 +15,14 @@ function install_nix() {
|
||||||
if [ $? -eq 0 ]; then
|
if [ $? -eq 0 ]; then
|
||||||
echo -e "${GRN}The Nix package manager was successfully installed.${RST}"
|
echo -e "${GRN}The Nix package manager was successfully installed.${RST}"
|
||||||
else
|
else
|
||||||
echo -e "${RED}Failed to install Nix package manager!${RST}" > /dev/stderr
|
echo -e "${RED}Failed to install Nix package manager!${RST}" >&2
|
||||||
echo "Please see: https://nixos.org/nix/manual/#chap-installation" > /dev/stderr
|
echo "Please see: https://nixos.org/nix/manual/#chap-installation" >&2
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
if [[ ! -x "$(command -v git)" ]]; then
|
if [[ ! -x "$(command -v git)" ]]; then
|
||||||
echo -e "${RED}The 'curl' utility is required for Nix installation.${RST}" > /dev/stderr
|
echo -e "${RED}The 'curl' utility is required for Nix installation.${RST}" >&2
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue