Skip to content

Commit 867a5e1

Browse files
committed
guix: Register garbage collector root for containers
By registering the container profiles as garbage collector roots, it will prevent `guix gc` from garbage collecting derivations which our container needs and inconvieniencing the user with a rebuild.
1 parent 8f8b96f commit 867a5e1

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

contrib/guix/guix-build

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ time-machine() {
207207
# Precious directories are those which should not be cleaned between successive
208208
# guix builds
209209
depends_precious_dir_names='SOURCES_PATH BASE_CACHE SDK_PATH'
210-
precious_dir_names="${depends_precious_dir_names} OUTDIR_BASE"
210+
precious_dir_names="${depends_precious_dir_names} OUTDIR_BASE PROFILES_BASE"
211211

212212
# Usage: contains IFS-SEPARATED-LIST ITEM
213213
contains() {
@@ -275,6 +275,14 @@ outdir_for_host() {
275275
echo "${OUTDIR_BASE}/${1}"
276276
}
277277

278+
# Usage: profiledir_for_host HOST COMMAND
279+
#
280+
# HOST: The current platform triple we're building for
281+
#
282+
profiledir_for_host() {
283+
echo "${PROFILES_BASE}/${2}-${1}"
284+
}
285+
278286

279287
#########
280288
# BUILD #
@@ -404,6 +412,7 @@ EOF
404412
--keep-failed \
405413
--fallback \
406414
--link-profile \
415+
--root="$(profiledir_for_host "${HOST}" build)" \
407416
${SUBSTITUTE_URLS:+--substitute-urls="$SUBSTITUTE_URLS"} \
408417
${ADDITIONAL_GUIX_COMMON_FLAGS} ${ADDITIONAL_GUIX_ENVIRONMENT_FLAGS} \
409418
-- env HOST="$host" \

contrib/guix/libexec/prelude.bash

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,3 +61,6 @@ OUTDIR_BASE="${OUTDIR_BASE:-${VERSION_BASE}/output}"
6161

6262
var_base_basename="var"
6363
VAR_BASE="${VAR_BASE:-${VERSION_BASE}/${var_base_basename}}"
64+
65+
profiles_base_basename="profiles"
66+
PROFILES_BASE="${PROFILES_BASE:-${VAR_BASE}/${profiles_base_basename}}"

0 commit comments

Comments
 (0)