Script to configure guix container on Fedora Kinoite

This commit is contained in:
Ray Miller 2024-10-11 09:56:06 +01:00
parent 7c9774e11a
commit 6b3eaac4e4

92
podman-guix-setup.sh Executable file
View file

@ -0,0 +1,92 @@
#!/usr/bin/env bash
#
set -e
systemctl --user stop guix.service || true
systemctl --user stop gnu-store-volume.service || true
systemctl --user stop guix-home-volume.service || true
systemctl --user stop guix-var-volume.service || true
(
cd $(mktemp -d)
cat > Containerfile <<EOF
FROM docker.io/library/debian:bookworm-slim
RUN apt-get -qq update && apt-get -qq install wget gpg xz-utils netbase
ADD --chmod=0755 https://git.savannah.gnu.org/cgit/guix.git/plain/etc/guix-install.sh /etc/guix-install.sh
RUN yes '' | /etc/guix-install.sh
RUN adduser --disabled-password --comment guix guix
VOLUME /gnu/store
VOLUME /var/guix
VOLUME /home/guix
ENTRYPOINT ["/root/.config/guix/current/bin/guix-daemon", "--build-users-group=guixbuild"]
EOF
podman build -t guix:latest .
)
QUADLETS="${HOME}/.config/containers/systemd/"
mkdir -p "${QUADLETS}"
cat > "${QUADLETS}/gnu-store.volume" <<EOF
[Unit]
Description = Create GNU Store data volume
[Service]
RemainAfterExit = yes
[Volume]
[Install]
WantedBy = multi-user.target default.target
EOF
cat > "${QUADLETS}/guix-var.volume" <<EOF
[Unit]
Description = Create GNU Guix var volume
[Service]
RemainAfterExit = yes
[Volume]
[Install]
WantedBy = multi-user.target default.target
EOF
cat > "${QUADLETS}/guix-home.volume" <<EOF
[Unit]
Description = Create Guix user home volume
[Service]
RemainAfterExit = yes
[Volume]
[Install]
WantedBy = multi-user.target default.target
EOF
cat > "${QUADLETS}/guix.container" <<EOF
[Unit]
Description = Guix Service
[Container]
Image = localhost/guix:latest
ContainerName = guix
Volume = guix-var.volume:/var/guix
Volume = guix-home.volume:/home/guix
Volume = gnu-store.volume:/gnu/store
PodmanArgs = --privileged
[Install]
WantedBy = multi-user.target default.target
EOF
systemctl --user daemon-reload
systemctl --user start guix-var-volume.service
systemctl --user start gnu-store-volume.service
systemctl --user start guix-home-volume.service
systemctl --user start guix.service