2019-05-10 13:20:40 +00:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
2020-08-06 12:08:36 +00:00
|
|
|
set -Ee
|
2019-06-04 16:50:29 +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
|
|
|
|
2024-04-25 14:57:48 +00:00
|
|
|
_NIX_GCROOTS="${_NIX_GCROOTS:-${GIT_ROOT}/.nix-gcroots}"
|
|
|
|
|
2020-06-19 13:43:58 +00:00
|
|
|
TARGET="${1}"
|
2020-08-06 12:08:36 +00:00
|
|
|
shift
|
2020-06-19 13:43:58 +00:00
|
|
|
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}" \
|
2020-08-06 12:08:36 +00:00
|
|
|
"${@}" "${GIT_ROOT}/default.nix" >/dev/null
|