2019-05-10 13:20:40 +00:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
2019-07-26 14:51:06 +00:00
|
|
|
set -Eeu
|
2019-06-04 16:50:29 +00:00
|
|
|
|
2020-06-19 13:43:58 +00:00
|
|
|
_NIX_GCROOTS="${_NIX_GCROOTS:-/nix/var/nix/gcroots/per-user/${USER}/status-react}"
|
2020-02-19 13:15:28 +00:00
|
|
|
|
2019-06-04 17:00:19 +00:00
|
|
|
GIT_ROOT=$(cd "${BASH_SOURCE%/*}" && git rev-parse --show-toplevel)
|
2020-06-19 13:43:58 +00:00
|
|
|
source "${GIT_ROOT}/nix/scripts/source.sh"
|
|
|
|
source "${GIT_ROOT}/scripts/colors.sh"
|
2019-05-10 13:20:40 +00:00
|
|
|
|
2020-06-19 13:43:58 +00:00
|
|
|
TARGET="${1}"
|
|
|
|
if [[ -z "${TARGET}" ]]; then
|
|
|
|
echo -e "${RED}No target specified for gcroots.sh!${RST}" >&2
|
|
|
|
exit 1
|
|
|
|
fi
|
2019-05-10 13:20:40 +00:00
|
|
|
|
2020-06-19 13:43:58 +00:00
|
|
|
# Creates a symlink to derivation in _NIX_GCROOTS directory.
|
|
|
|
# This prevents it from being removed by 'gc-collect-garbage'.
|
|
|
|
nix-instantiate --attr "${TARGET}" \
|
|
|
|
--add-root "${_NIX_GCROOTS}/${TARGET}" \
|
|
|
|
"${GIT_ROOT}/default.nix" >/dev/null
|