blob: e5a0da8e0c1b2c61a8e154972da7ec70fbbc32d3 (
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
|
#!/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
umask 077
ROOT=$(CDPATH= cd -- "$(dirname -- "$0")/../.." && pwd)
[ "$(uname -s):$(uname -m)" = Linux:x86_64 ] || { echo 'Requires x86_64 Linux.' >&2; exit 1; }
command -v guix >/dev/null || { echo "Guix is required on the build machine." >&2; exit 1; }
mkdir -p "$ROOT/bin"
STAGE=$(mktemp -d "$ROOT/bin/.guix-build.XXXXXX")
trap 'chmod -R u+w -- "$STAGE"; rm -rf -- "$STAGE"' EXIT HUP INT TERM
guix describe --format=channels > "$STAGE/channels.scm"
PACK=$(guix time-machine -C "$STAGE/channels.scm" -- pack \
--system=x86_64-linux -S /bin=bin -S /etc=etc \
-m "$ROOT/infra/guix/manifest.scm")
cp -- "$PACK" "$STAGE/runtime.tar.gz"
mkdir "$STAGE/runtime"
tar -xzf "$STAGE/runtime.tar.gz" --no-same-owner -C "$STAGE/runtime"
PATH="$STAGE/runtime/bin:$PATH" CONTAINERS_CONF="$ROOT/infra/guix/containers.conf" \
podman --root "$STAGE/storage" \
--runroot "$STAGE/run" info >/dev/null
mv -- "$STAGE/runtime.tar.gz" "$ROOT/bin/guix-runtime.tar.gz"
mv -- "$STAGE/channels.scm" "$ROOT/bin/guix-channels.scm"
printf '%s\n' 'Guix runtime built. Full clean-host recovery test still required.'
|