blob: e1b9b99e0f2bd2b7213ef6f038217f570d53188f (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
|
#!/bin/sh
# Copyright (C) 2026 Doan Luu Duc Tai <doan@luuduct.ai>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
set -eu
ROOT=$(CDPATH= cd -- "$(dirname -- "$0")/.." && pwd)
if [ -f "$ROOT/bin/guix-runtime.tar.gz" ]; then
DIGEST=$(sha256sum "$ROOT/bin/guix-runtime.tar.gz")
DIGEST=${DIGEST%% *}
RUNTIME="$ROOT/var/guix/$DIGEST"
if [ ! -d "$RUNTIME" ]; then
umask 077
mkdir -p "$ROOT/var/guix"
STAGE=$(mktemp -d "$ROOT/var/guix/.unpack.XXXXXX")
trap 'chmod -R u+w -- "$STAGE"; rm -rf -- "$STAGE"' EXIT HUP INT TERM
tar -xzf "$ROOT/bin/guix-runtime.tar.gz" --no-same-owner -C "$STAGE"
[ -x "$STAGE/bin/podman" ] && [ -x "$STAGE/bin/gpg" ] || {
echo 'Guix closure unavailable; run the trusted recovery capsule bootstrap as root first.' >&2; exit 1;
}
mv -T -- "$STAGE" "$RUNTIME"
trap - EXIT HUP INT TERM
fi
[ -x "$RUNTIME/bin/podman" ] && [ -x "$RUNTIME/bin/gpg" ] || {
echo 'Guix closure unavailable; run the trusted recovery capsule bootstrap as root first.' >&2; exit 1;
}
PATH="$RUNTIME/bin:$PATH"
CONTAINERS_CONF="$ROOT/infra/guix/containers.conf"
export PATH CONTAINERS_CONF
SSL_CERT_DIR="$RUNTIME/etc/ssl/certs"
SSL_CERT_FILE="$SSL_CERT_DIR/ca-certificates.crt"
export SSL_CERT_DIR SSL_CERT_FILE
fi
exec "$ROOT/bin/stack" --root "$ROOT" "$@"
|