Include docker configs to build nixos images

This commit is contained in:
Erica Marigold 2025-02-05 16:58:16 +00:00
parent 6437d85e39
commit f479a5bbad
Signed by: DevComp
SSH key fingerprint: SHA256:jD3oMT4WL3WHPJQbrjC3l5feNCnkv7ndW8nYaHX5wFw
4 changed files with 51 additions and 0 deletions

13
vendor/docker-nixos/Dockerfile vendored Normal file
View file

@ -0,0 +1,13 @@
FROM nixos/nix:2.24.11
# Enable flakes
RUN echo -e "experimental-features = nix-command flakes\n\
builders-use-substitutes = true\n" >> /etc/nix/nix.conf
# Enable remote builders substitutes
# https://nix.dev/manual/nix/2.18/command-ref/conf-file.html?highlight=builders-use-substitutes#conf-builders-use-substitutes
RUN echo "builders-use-substitutes = true" >> /etc/nix/nix.conf
# Trust all directory to run flake commands as root on different volumes
RUN git config --global --add safe.directory '*'
# Copy the setup script
COPY --chown=root:root --chmod=700 ./setup-remote.sh /setup-remote.sh

1
vendor/docker-nixos/README.txt vendored Normal file
View file

@ -0,0 +1 @@
Slightly modified from [joshuachp/containers](https://github.com/joshuachp/containers/tree/e55ba5e5b8a3a39438e34f18459e358210742724/nixos).

24
vendor/docker-nixos/build.sh vendored Normal file
View file

@ -0,0 +1,24 @@
#!/usr/bin/env bash
set -exEuo pipefail
git fetch --tags
nixos_tag="$(
git tag |
grep '^nixos-' |
sed -e 's/^nixos-//' |
sort -V |
tail -n1
)"
if [ -z "$NIXOS_TAG" ]; then
echo "Error: NIXOS_TAG is not set or is empty."
exit 1
fi
docker build \
--platform=linux/amd64,linux/arm64 \
-t "git.devcomp.xyz/devcomp/nixos:$NIXOS_TAG" \
-f Dockerfile \
--push .

13
vendor/docker-nixos/setup-remote.sh vendored Normal file
View file

@ -0,0 +1,13 @@
#!/usr/bin/env bash
set -exEuo pipefail
mkdir -p ~/.ssh
echo "$BUILDER_KEY" >>~/.ssh/id_ed25519
echo "$BUILDER_HOST_KEYS" >>~/.ssh/known_hosts
chmod -R 600 ~/.ssh
# Check the remote builder
nix store info --store "$BUILDERS"
echo "$BUILDERS" >>/etc/nix/machines